Compare commits

...
Sign in to create a new pull request.

163 commits

Author SHA1 Message Date
0fb2c05244 Merge pull request '[tumblr] Ward against unexpected response format in tumblr_fetch_tags()' (#1599) from MrPetovan/friendica-addons:bug/fatal-errors into develop
Reviewed-on: friendica/friendica-addons#1599
2025-02-08 16:57:13 +01:00
373c30b5d0 [tumblr] Ward against unexpected response format in tumblr_fetch_tags()
- Adress https://github.com/friendica/friendica/issues/14646#issuecomment-2628090487
2025-02-08 16:57:13 +01:00
4454ce5883 Merge pull request 'Implement monolog addon as LoggerFactory' (#1598) from Art4/friendica-addons:loggerfactory-in-monolog-addon into develop
Reviewed-on: friendica/friendica-addons#1598
Reviewed-by: Hypolite Petovan <hypolite@mrpetovan.com>
2025-02-08 04:16:47 +01:00
Art4
5701853d29 Remove config docs, format syntax 2025-02-06 11:35:10 +00:00
Art4
ed75360eb4 Setting the logger_config config is no longer needed 2025-02-06 09:27:22 +00:00
Art4
c4f8c65817 Remove wrong phpdoc 2025-02-05 15:32:24 +00:00
Art4
f7ec934893 bump version to 1.1 2025-02-05 15:20:22 +00:00
Art4
0bafcc78f8 Add READMD.md for monolog addon 2025-02-05 15:20:06 +00:00
Art4
e6d92cc94a Rewrite Monolog factory to implement LoggerFactory 2025-02-05 15:11:14 +00:00
16a8172c37 Merge pull request 'Accessibility: Use different id values for options' (#1597) from heluecht/friendica-addons:accessibility into develop
Reviewed-on: friendica/friendica-addons#1597
Reviewed-by: Hypolite Petovan <hypolite@mrpetovan.com>
2025-01-28 23:09:04 +01:00
16127854dd Accessibility: Use different id values for options 2025-01-28 20:27:52 +00:00
7e1bcbdedb Merge pull request 'Add additional theme-filter for disabling/enabling divs.' (#1596) from jakob/friendica-addons:fix-saml-display-settings into develop
Reviewed-on: friendica/friendica-addons#1596
Reviewed-by: Hypolite Petovan <hypolite@mrpetovan.com>
2025-01-25 14:06:07 +01:00
Jakobus Schürz
8384b74696 add condition for selected theme 2025-01-25 08:05:32 -05:00
c5e3d1f047 Merge pull request 'Issue 14692: Avoid loop situation' (#1595) from heluecht/friendica-addons:issue-14692 into develop
Reviewed-on: friendica/friendica-addons#1595
Reviewed-by: Hypolite Petovan <hypolite@mrpetovan.com>
2025-01-25 13:59:52 +01:00
cbfcfb3349 Issue 14692: Avoid loop situation 2025-01-25 02:44:54 +00:00
cdba300c7b Merge pull request 'Replace Logger class with DI::logger()' (#1594) from Art4/friendica-addons:replace-logger-with-loggerinterface into develop
Reviewed-on: friendica/friendica-addons#1594
Reviewed-by: Hypolite Petovan <hypolite@mrpetovan.com>
2025-01-24 14:34:43 +01:00
Art4
4c8c262b07 fix in googlemaps addon 2025-01-24 12:10:58 +00:00
Art4
dd775645d4 Replace call for Logger with DI::logger() in wppost addon 2025-01-24 11:58:32 +00:00
Art4
e4d14cab62 Replace call for Logger with DI::logger() in twitter addon 2025-01-24 11:58:10 +00:00
Art4
a7b26f6453 Replace call for Logger with DI::logger() in tesseract addon 2025-01-24 11:57:34 +00:00
Art4
763c5026f2 Replace call for Logger with DI::logger() in tumblr addon 2025-01-24 11:57:12 +00:00
Art4
bfdccb451c Replace call for Logger with DI::logger() in statusnet addon 2025-01-24 11:56:45 +00:00
Art4
ac6c1d7a49 Replace call for Logger with DI::logger() in saml addon 2025-01-24 11:56:29 +00:00
Art4
32a3160445 Replace call for Logger with DI::logger() in randplace addon 2025-01-24 11:56:09 +00:00
Art4
d50650b8cf Replace call for Logger with DI::logger() in pumpio addon 2025-01-24 11:55:13 +00:00
Art4
e32ba1ce7b Replace call for Logger with DI::logger() in public_server addon 2025-01-24 11:54:34 +00:00
Art4
119ba0a78e Replace call for Logger with DI::logger() in pnut addon 2025-01-24 11:48:21 +00:00
Art4
469d3e6d61 Replace call for Logger with DI::logger() in planets addon 2025-01-24 11:47:40 +00:00
Art4
757d72c360 Replace call for Logger with DI::logger() in openstreetmap addon 2025-01-24 11:47:24 +00:00
Art4
9ceff8f592 Replace call for Logger with DI::logger() in nominatim addon 2025-01-24 11:46:58 +00:00
Art4
9a91bae363 Replace call for Logger with DI::logger() in mailstream addon 2025-01-24 11:46:30 +00:00
Art4
9ed02034f1 Replace call for Logger with DI::logger() in ljpost addon 2025-01-24 11:46:04 +00:00
Art4
f08750199d Replace call for Logger with DI::logger() in libertree addon 2025-01-24 11:45:25 +00:00
Art4
a488f25131 Replace call for Logger with DI::logger() in ldapauth addon 2025-01-24 11:44:48 +00:00
Art4
5d51c5b56e Replace call for Logger with DI::logger() in js_upload addon 2025-01-24 11:42:25 +00:00
Art4
5002318089 Replace call for Logger with DI::logger() in ijpost addon 2025-01-24 11:41:02 +00:00
Art4
15a951235f Replace call for Logger with DI::logger() in ifttt addon 2025-01-24 11:40:32 +00:00
Art4
e7755584cb Replace call for Logger with DI::logger() in geocoordinates addon 2025-01-24 11:40:12 +00:00
Art4
1db552ead9 Replace call for Logger with DI::logger() in dwpost addon 2025-01-24 11:39:11 +00:00
Art4
b38c2d18be Replace call for Logger with DI::logger() in discourse addon 2025-01-24 11:38:48 +00:00
Art4
4881e6004a Replace call for Logger with DI::logger() in diaspora addon 2025-01-24 11:38:27 +00:00
Art4
1d1a00df27 Replace call for Logger with DI::logger() in cld addon 2025-01-24 11:37:58 +00:00
Art4
77ebaca281 Replace call for Logger with DI::logger() in ratioed addon 2025-01-24 11:37:28 +00:00
Art4
d78ea50516 Replace call for Logger with DI::logger() in bluesky addon 2025-01-24 11:36:23 +00:00
Art4
41f280f0c7 Replace call for Logger with DI::logger() in blockbot addon 2025-01-24 11:34:33 +00:00
Art4
4310c1355d Replace call for Logger with DI::logger() 2025-01-24 10:53:01 +00:00
1cc5a6688e Merge pull request 'rework saml addon' (#1588) from jakob/friendica-addons:fix-saml-display-settings into develop
Reviewed-on: friendica/friendica-addons#1588
Reviewed-by: Hypolite Petovan <hypolite@mrpetovan.com>
2025-01-23 14:31:49 +01:00
Jakobus Schürz
0b4aaac9fd translation for saml-hint 2025-01-23 14:31:49 +01:00
Jakobus Schürz
c506367273 replace password-handling with hint
also add hint to email-field
2025-01-23 14:31:49 +01:00
Jakobus Schürz
792f50f835 fix view in vier and frio 2025-01-23 14:31:49 +01:00
Jakobus Schürz
2b5764c132 rework saml addon
fix #1587
remove css-side hiding of elements, which was broken.
remove them or make them readonly via javascript
2025-01-23 14:31:49 +01:00
69e75ef88b Merge pull request 'Check PHPStan in addons' (#1592) from Art4/friendica-addons:fix-phpstan-error into develop
Reviewed-on: friendica/friendica-addons#1592
Reviewed-by: Hypolite Petovan <hypolite@mrpetovan.com>
2025-01-23 14:29:59 +01:00
Art4
7a7940a8ed Fix PHPStan errors 2025-01-23 08:29:13 -05:00
Art4
2741227bfa Add phpstan in woodpacker 2025-01-23 08:27:48 -05:00
13cffd76db Merge pull request 'Clean up phpstan warning' (#1591) from mexon/friendica-addons:mat/ratioed-fix-warning into develop
Reviewed-on: friendica/friendica-addons#1591
Reviewed-by: Hypolite Petovan <hypolite@mrpetovan.com>
2025-01-23 14:26:41 +01:00
Matthew Exon
0d0aae36cd Clean up phpstan warning 2025-01-23 08:26:23 -05:00
28d3041694 Merge pull request 'Fix codestyle' (#1590) from heluecht/friendica-addons:ratiod-fix into develop
Reviewed-on: friendica/friendica-addons#1590
2025-01-22 08:49:57 +01:00
cb70a4eaff Fix codestyle 2025-01-18 15:25:50 +00:00
0c96d0f4bb Merge pull request 'Ratioed: add statistics about reply likes and reply guy score' (#1589) from mexon/friendica-addons:mat/reply-guy-score into develop
Reviewed-on: friendica/friendica-addons#1589
2025-01-16 06:43:41 +01:00
Matthew Exon
ee8c852d38 Ratioed: remove action buttons 2025-01-15 19:33:11 +01:00
Matthew Exon
807598dbd0 Ratioed: wrap long lines 2025-01-15 19:32:55 +01:00
Matthew Exon
8ba4cd5f61 Ratioed: bump version number 2025-01-12 14:33:21 +01:00
Matthew Exon
3441c9bd0e Ratioed: add statistics about reply likes and reply guy score 2025-01-12 14:33:21 +01:00
44d2079da2 Merge pull request 'Ratioed: several fixes to functionality' (#1586) from mexon/friendica-addons:mat/ratioed-fixes into develop
Reviewed-on: friendica/friendica-addons#1586
2025-01-12 12:03:00 +01:00
Matthew Exon
b360b553ed Ratioed: remove actions 2025-01-12 12:03:00 +01:00
Matthew Exon
46b3836720 Ratioed: remove create user button 2025-01-12 12:03:00 +01:00
Matthew Exon
81639ff615 Ratioed: fix sorting by columns 2025-01-12 12:03:00 +01:00
Matthew Exon
d495810b2d Ratioed: allow both sorting directions 2025-01-12 12:03:00 +01:00
Matthew Exon
2ef9cb8add Ratioed: fill in zeroes for empty values 2025-01-12 12:03:00 +01:00
Matthew Exon
8e65141cb5 Ratioed: bump version number 2025-01-12 12:03:00 +01:00
Matthew Exon
d034e311cb Ratioed: add help link 2025-01-12 12:03:00 +01:00
db10da2f02 Merge pull request '[CI] Fix releaser' (#1585) from nupplaPhil/friendica-addons:ci/stable_pick into develop
Reviewed-on: friendica/friendica-addons#1585
2025-01-02 08:37:19 +01:00
995e81e951
[CI] Fix releaser 2025-01-01 20:22:42 +01:00
cb2ab0684e Merge branch 'stable' into develop 2024-12-31 18:57:15 +01:00
Art4
5f557ed0ab Merge branch '2024.09-rc' into merge-2024.09-rc-into-develop 2024-12-23 10:15:53 +00:00
a63fb08525 Merge remote-tracking branch '2024.09-rc' into develop
# Conflicts:
#	bluesky/bluesky.php
2024-12-16 09:12:09 -05:00
6cf388f141 Merge remote-tracking branch 'Art4/remove-app-usage' into develop 2024-12-16 09:04:45 -05:00
Art4
c4bea164c7 Merge branch 'develop' into remove-app-usage 2024-12-15 15:55:54 +00:00
04c402607b Merge branch 'Art4/fix-phpstan-error-level-2' into develop 2024-12-15 09:18:47 -05:00
Artur Weigandt
68ee5260b0
Merge branch 'develop' into fix-phpstan-error-level-2 2024-12-13 10:28:15 +01:00
81a84fb895 Merge pull request 'fix-phpstan-error-level-1' (#1579) from MrPetovan/friendica-addons:fix-phpstan-error-level-1 into develop
Reviewed-on: friendica/friendica-addons#1579
2024-12-12 22:37:42 +01:00
Artur Weigandt
729b6e5210 Update mailstream/phpmailer/class.phpmailer.php
Co-authored-by: Hypolite Petovan <hypolite@mrpetovan.com>
2024-12-12 22:37:42 +01:00
Art4
a71db771d9 Fix errors in wppost addon 2024-12-12 22:37:42 +01:00
Art4
2f89827dea fix errors in tictac addon 2024-12-12 22:37:42 +01:00
Art4
8e778593ca fix errors in statusnet addon 2024-12-12 22:37:42 +01:00
Art4
5b623c8368 fix errors in ratioed addon 2024-12-12 22:37:42 +01:00
Art4
bda683c56b fix errors in pumpio addon 2024-12-12 22:37:42 +01:00
Art4
7fa2dfc608 Fix errors in pnut addon 2024-12-12 22:37:42 +01:00
Art4
c0971779c6 Fix errors in nsfw addon 2024-12-12 22:37:42 +01:00
Art4
6b1b043dd8 fix errors in mailstream addon 2024-12-12 22:37:42 +01:00
Art4
984e7c5e5d Fix errors in ljpost addon 2024-12-12 22:37:42 +01:00
Art4
d08a280ba6 Fix errors in libravatar addon 2024-12-12 22:37:42 +01:00
Art4
ee1a917612 Fix errors in leistungsschutzrecht addon 2024-12-12 22:37:42 +01:00
Art4
a53d5ae29b Fix errors in langfilter addon 2024-12-12 22:37:42 +01:00
Art4
3cf53a334d Fix errors in keycloakpassword addon 2024-12-12 22:37:42 +01:00
Art4
81f232d57e Fix errors in js_upload addon 2024-12-12 22:37:42 +01:00
Art4
1860e732ae Fix errors in convert addon 2024-12-12 22:37:42 +01:00
Art4
cf8a7870f3 Fix errors in bluesky addon 2024-12-12 22:37:42 +01:00
Art4
31198294c7 Fix error in bluesky addon 2024-12-12 22:37:42 +01:00
Art4
84659fc1ad Replace DI::app() with DI::appHelper() 2024-12-11 21:47:10 +00:00
Art4
5f7482d081 Remove unused use statements for App 2024-12-11 21:42:48 +00:00
Art4
fff140ad43 Fix last 3 errors 2024-12-09 23:08:31 +00:00
Art4
cfb6b3123f Fix errors in statusnet addon 2024-12-08 23:06:51 +00:00
Art4
b99ac65c0b Fix errors in membersince addon 2024-12-08 22:49:23 +00:00
Art4
89a673cc11 Fix typo 2024-12-08 22:19:58 +00:00
Art4
2fe37c6d4a Fix errors in pnut addon 2024-12-08 21:24:03 +00:00
Art4
5b13274bed Fix class name collision 2024-12-08 21:02:07 +00:00
Art4
82ed43f507 Fix errors 2024-12-07 22:08:59 +00:00
Art4
43c71412e4 Merge branch 'develop' into fix-phpstan-error-level-1 2024-12-01 07:41:27 +00:00
fb9c10f8c5 Merge pull request 'Fix phpstan error level 0 part2' (#1577) from fix-phpstan-error-level-0-part2 into develop
Reviewed-on: friendica/friendica-addons#1577
Reviewed-by: Hypolite Petovan <hypolite@mrpetovan.com>
2024-12-01 03:20:18 +01:00
Art4
1e68417278 Fix classes in s3_storage addon 2024-12-01 03:20:18 +01:00
Art4
7d02c9b53c Fix errors in pumpio addon 2024-12-01 03:20:18 +01:00
Art4
b5c647bd5d fix errors in pnut addon, add support for PHP 7.4 2024-12-01 03:20:18 +01:00
Art4
1bd7cd6e71 fix error in PHPMailer 2024-12-01 03:20:18 +01:00
Art4
def43f3167 Fix errors in mailstream addon 2024-12-01 03:20:18 +01:00
Art4
b661448344 Fix errors in libravatar addon 2024-12-01 03:20:18 +01:00
Art4
922bace555 Fix errors in diaspora addon 2024-12-01 03:20:18 +01:00
Art4
4a2fc7884c remove wrong return tag 2024-12-01 03:20:18 +01:00
Art4
9d172b7082 refactor convert addon, replace each() calls with foreach loop 2024-12-01 03:20:18 +01:00
Art4
4527df602f Add checks for CLD2Detector ans CLD2Encoding classes 2024-12-01 03:20:18 +01:00
Art4
15c21cebb1 Fix errors in wppost addon 2024-11-30 20:36:58 +00:00
Art4
b6a47699bf fix errors in tictac addon 2024-11-30 20:36:07 +00:00
Art4
a41f8c13fe fix errors in statusnet addon 2024-11-30 20:27:57 +00:00
Art4
fccf361ef1 fix errors in ratioed addon 2024-11-30 20:13:41 +00:00
Art4
43ee267d38 fix errors in pumpio addon 2024-11-30 20:12:23 +00:00
Art4
3f89aa1806 Fix errors in pnut addon 2024-11-30 19:51:18 +00:00
Art4
50912fdc17 Fix errors in nsfw addon 2024-11-30 19:50:06 +00:00
Art4
c04016b7d3 fix errors in mailstream addon 2024-11-30 19:48:49 +00:00
Art4
5f6f374f09 Fix errors in ljpost addon 2024-11-30 19:42:40 +00:00
Art4
e86d15993b Fix errors in libravatar addon 2024-11-30 19:41:11 +00:00
Art4
ace19814d7 Fix errors in leistungsschutzrecht addon 2024-11-30 19:37:58 +00:00
Art4
fcec1a3d83 Fix errors in langfilter addon 2024-11-30 19:35:19 +00:00
Art4
04afbe36e3 Fix errors in keycloakpassword addon 2024-11-30 19:32:07 +00:00
Art4
07993f7098 Fix errors in js_upload addon 2024-11-30 19:30:39 +00:00
Art4
bee780552d Fix errors in convert addon 2024-11-30 19:28:38 +00:00
Art4
5664bc84fb Fix errors in bluesky addon 2024-11-30 19:27:50 +00:00
Art4
7246f3deda Merge branch 'fix-phpstan-error-level-0-part2' into fix-phpstan-error-level-1 2024-11-30 19:23:00 +00:00
Art4
0204f54b0e Merge branch 'develop' into fix-phpstan-error-level-0-part2 2024-11-30 06:51:49 +00:00
72e7e2a5b7 Merge remote-tracking branch 'friendica/2024.09-rc' into develop 2024-11-29 21:15:25 -05:00
Art4
5f2a9e9891 Fix error in bluesky addon 2024-11-29 22:36:09 +00:00
Art4
a6de4225c6 Merge branch 'port-rc-branch-into-develop' into fix-phpstan-error-level-0-part2 2024-11-27 23:19:19 +00:00
Art4
23227e5b0f Fix classes in s3_storage addon 2024-11-27 23:18:20 +00:00
Art4
7872400467 Fix errors in pumpio addon 2024-11-27 23:14:01 +00:00
Art4
a5aaea5211 fix errors in pnut addon, add support for PHP 7.4 2024-11-27 22:55:15 +00:00
Art4
7453c6f41a fix error in PHPMailer 2024-11-27 22:33:12 +00:00
Art4
9cb728d19a Merge branch 'develop' into fix-phpstan-error-level-0-part2 2024-11-27 22:25:42 +00:00
Art4
e488f597be Fix errors in mailstream addon 2024-11-27 11:52:59 +00:00
Art4
1346a92505 Fix errors in libravatar addon 2024-11-27 11:43:21 +00:00
Art4
9117626c6a Fix errors in diaspora addon 2024-11-27 11:40:45 +00:00
Art4
90ffd40d58 remove wrong return tag 2024-11-27 11:38:55 +00:00
93a91a95e9 Merge pull request 'Fix PHPStan errors on level 0' (#1575) from MrPetovan/friendica-addons:bug/Art4-1367 into develop
Reviewed-on: friendica/friendica-addons#1575
2024-11-27 08:36:08 +01:00
Art4
fc0dda0cd9 refactor convert addon, replace each() calls with foreach loop 2024-11-26 08:23:27 +00:00
Art4
d7d6a43655 Add checks for CLD2Detector ans CLD2Encoding classes 2024-11-26 07:55:01 +00:00
Art4
c58ca7dcc9 Merge branch '2024.09-rc' into port-rc-branch-into-develop 2024-11-26 07:33:57 +00:00
Art4
6df91dd37b Fix errors in statusnet addon 2024-11-24 19:55:54 +00:00
Art4
e9d3afb483 Fix errors in tictac addon 2024-11-24 19:51:37 +00:00
Art4
348c44c972 inline slim routes and middlewares into advancedcontentfilter addon 2024-11-24 15:36:37 +00:00
58180bd732 Merge pull request 'Remove unused parameter in saml addon' (#1572) from MrPetovan/friendica-addons:bug/Art4-1366 into develop
Reviewed-on: friendica/friendica-addons#1572
2024-11-24 10:17:44 +01:00
Artur Weigandt
bf679262b0 Remove unused parameter in saml addon 2024-11-24 10:17:44 +01:00
c4e24833eb Merge pull request 'Remove unused parameter webdav_storage addon' (#1570) from MrPetovan/friendica-addons:bug/Art4-1364 into develop
Reviewed-on: friendica/friendica-addons#1570
2024-11-24 10:16:47 +01:00
Artur Weigandt
ecf0edb520 Remove unused parameter webdav_storage addon 2024-11-24 10:16:47 +01:00
3a5acf95f7 Merge pull request 'Remove unused App paramter in securemail addon' (#1571) from MrPetovan/friendica-addons:bug/Art4-1365 into develop
Reviewed-on: friendica/friendica-addons#1571
2024-11-24 10:16:25 +01:00
Artur Weigandt
2ea40dc897 Remove unused App paramter in securemail addon 2024-11-23 21:24:34 -05:00
122 changed files with 1050 additions and 1022 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -33,16 +33,13 @@
*
*/
use Friendica\App;
use Friendica\BaseModule;
use Friendica\Content\Text\Markdown;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\Database\DBStructure;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Model\Tag;
use Friendica\Model\User;
@ -64,7 +61,7 @@ function advancedcontentfilter_install()
Hook::add('dbstructure_definition' , __FILE__, 'advancedcontentfilter_dbstructure_definition');
DBStructure::performUpdate();
Logger::notice('installed advancedcontentfilter');
DI::logger()->notice('installed advancedcontentfilter');
}
/*
@ -192,9 +189,30 @@ function advancedcontentfilter_init()
if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'api') {
$slim = \Slim\Factory\AppFactory::create();
require __DIR__ . '/src/middlewares.php';
/**
* The routing middleware should be added before the ErrorMiddleware
* Otherwise exceptions thrown from it will not be handled
*/
$slim->addRoutingMiddleware();
$slim->addErrorMiddleware(true, true, true, DI::logger());
// register routes
$slim->group('/advancedcontentfilter/api', function (\Slim\Routing\RouteCollectorProxy $app) {
$app->group('/rules', function (\Slim\Routing\RouteCollectorProxy $app) {
$app->get('', 'advancedcontentfilter_get_rules');
$app->post('', 'advancedcontentfilter_post_rules');
$app->get('/{id}', 'advancedcontentfilter_get_rules_id');
$app->put('/{id}', 'advancedcontentfilter_put_rules_id');
$app->delete('/{id}', 'advancedcontentfilter_delete_rules_id');
});
$app->group('/variables', function (\Slim\Routing\RouteCollectorProxy $app) {
$app->get('/{guid}', 'advancedcontentfilter_get_variables_guid');
});
});
require __DIR__ . '/src/routes.php';
$slim->run();
exit;
@ -252,7 +270,7 @@ function advancedcontentfilter_content()
'rule_expression' => DI::l10n()->t('Rule Expression'),
'cancel' => DI::l10n()->t('Cancel'),
],
'$current_theme' => DI::app()->getCurrentTheme(),
'$current_theme' => DI::appHelper()->getCurrentTheme(),
'$rules' => DBA::toArray(DBA::select('advancedcontentfilter_rules', [], ['uid' => DI::userSession()->getLocalUserId()])),
'$form_security_token' => BaseModule::getFormSecurityToken()
]);

View file

@ -1,32 +0,0 @@
<?php
/**
* @copyright Copyright (C) 2020, Friendica
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
use Friendica\DI;
/** @var $slim \Slim\App */
/**
* The routing middleware should be added before the ErrorMiddleware
* Otherwise exceptions thrown from it will not be handled
*/
$slim->addRoutingMiddleware();
$errorMiddleware = $slim->addErrorMiddleware(true, true, true, DI::logger());

View file

@ -1,36 +0,0 @@
<?php
/**
* @copyright Copyright (C) 2020, Friendica
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/* @var $slim Slim\App */
$slim->group('/advancedcontentfilter/api', function (\Slim\Routing\RouteCollectorProxy $app) {
$app->group('/rules', function (\Slim\Routing\RouteCollectorProxy $app) {
$app->get('', 'advancedcontentfilter_get_rules');
$app->post('', 'advancedcontentfilter_post_rules');
$app->get('/{id}', 'advancedcontentfilter_get_rules_id');
$app->put('/{id}', 'advancedcontentfilter_put_rules_id');
$app->delete('/{id}', 'advancedcontentfilter_delete_rules_id');
});
$app->group('/variables', function (\Slim\Routing\RouteCollectorProxy $app) {
$app->get('/{guid}', 'advancedcontentfilter_get_variables_guid');
});
});

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -6,7 +6,6 @@
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\DI;
@ -16,7 +15,7 @@ function calc_install() {
function calc_app_menu(array &$b)
{
$b['app_menu'][] = '<div class="app-title"><a href="calc">Calculator</a></div>';
$b['app_menu'][] = '<div class="app-title"><a href="calc">Calculator</a></div>';
}
/**
@ -296,7 +295,7 @@ $o .= <<< EOT
<h3>Calculator</h3>
<br /><br />
<table>
<tbody><tr><td>
<tbody><tr><td>
<table bgcolor="#af9999" border="1">
<tbody><tr><td>
<table border="1" cellpadding="2" cellspacing="2">
@ -323,7 +322,7 @@ $o .= <<< EOT
<td><input name="multiplication" value="&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;" onclick="multiplyNumbers()" type="button"></td>
</tr><tr align="left" valign="middle">
<td><input name="zero" value="&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;" onclick="addDisplay(0)" type="button"></td>
<td><input name="pi" value="&nbsp;Pi&nbsp;&nbsp;" onclick="addDisplay(Math.PI)" type="button"> </td>
<td><input name="pi" value="&nbsp;Pi&nbsp;&nbsp;" onclick="addDisplay(Math.PI)" type="button"> </td>
<td><input name="dot" value="&nbsp;&nbsp;&nbsp;.&nbsp;&nbsp;&nbsp;" onclick='addDisplay(".")' type="button"></td>
<td><input name="division" value="&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;" onclick="divideNumbers()" type="button"></td>
</tr><tr align="left" valign="middle">
@ -345,13 +344,13 @@ $o .= <<< EOT
</form>
<!--
<TD VALIGN=top>
<TD VALIGN=top>
<B>NOTE:</B> All sine and cosine calculations are
<br>done in radians. Remember to convert first
<br>if using degrees.
</TD>
-->
</td></tr></tbody></table>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -7,9 +7,7 @@
*
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
@ -18,7 +16,7 @@ function fromapp_install()
Hook::register('post_local', 'addon/fromapp/fromapp.php', 'fromapp_post_hook');
Hook::register('addon_settings', 'addon/fromapp/fromapp.php', 'fromapp_settings');
Hook::register('addon_settings_post', 'addon/fromapp/fromapp.php', 'fromapp_settings_post');
Logger::notice("installed fromapp");
DI::logger()->notice("installed fromapp");
}
function fromapp_settings_post($post)
@ -76,6 +74,6 @@ function fromapp_post_hook(&$item)
$apps = explode(',', $app);
$item['app'] = trim($apps[mt_rand(0, count($apps)-1)]);
return;
}

View file

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

View file

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

View file

@ -4,13 +4,11 @@
* Description: Thread email comment notifications on Gmail and anonymise them
* Version: 1.0
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*
*
*
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Model\Notification;
@ -21,7 +19,7 @@ function gnot_install()
Hook::register('addon_settings_post', 'addon/gnot/gnot.php', 'gnot_settings_post');
Hook::register('enotify_mail', 'addon/gnot/gnot.php', 'gnot_enotify_mail');
Logger::notice("installed gnot");
DI::logger()->notice("installed gnot");
}
/**
@ -38,7 +36,7 @@ function gnot_settings_post($post) {
}
/**
* Called from the Addon Setting form.
* Called from the Addon Setting form.
* Add our own settings info to the page.
*/
function gnot_settings(array &$data)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -77,10 +77,10 @@ class qqFileUploader {
public function __construct(array $allowedExtensions = [], $sizeLimit = 10485760)
{
$allowedExtensions = array_map('strtolower', $allowedExtensions);
$this->allowedExtensions = $allowedExtensions;
$this->sizeLimit = $sizeLimit;
$this->checkServerSettings();
if (isset($_GET['qqfile'])) {
@ -88,7 +88,7 @@ class qqFileUploader {
} elseif (isset($_FILES['qqfile'])) {
$this->file = new qqUploadedFileForm();
} else {
$this->file = false;
$this->file = false;
}
}
@ -105,7 +105,7 @@ class qqFileUploader {
private function toBytes(string $str): int
{
$val = trim($str);
$val = (int) trim($str);
$last = strtolower($str[strlen($str) - 1]);
switch($last) {

View file

@ -2,12 +2,12 @@
usleep(100000);
$fileName;
$fileSize;
$fileName = '';
$fileSize = 0;;
if (isset($_GET['qqfile'])){
$fileName = $_GET['qqfile'];
// xhr request
$headers = apache_request_headers();
$fileSize = (int)$headers['Content-Length'];
@ -34,13 +34,13 @@ if ($fileSize > 9 * 1024){
die ('{error: "server-error file size is bigger than 9kB"}');
}
if (count($_GET)){
if (count($_GET)){
array_merge($_GET, array('fileName'=>$fileName));
$response = array_merge($_GET, array('success'=>true, 'fileName'=>$fileName));
// to pass data through iframe you will need to encode all html tags
echo htmlspecialchars(json_encode($response), ENT_NOQUOTES);
// to pass data through iframe you will need to encode all html tags
echo htmlspecialchars(json_encode($response), ENT_NOQUOTES);
} else {
die ('{error: "server-error query params not passed"}');
}

View file

@ -2,11 +2,11 @@
sleep(4);
$fileName;
$fileName = '';
if (isset($_GET['qqfile'])){
$fileName = $_GET['qqfile'];
// xhr request
$headers = apache_request_headers();
if ((int)$headers['Content-Length'] == 0){
@ -14,7 +14,7 @@ if (isset($_GET['qqfile'])){
}
} elseif (isset($_FILES['qqfile'])){
$fileName = basename($_FILES['qqfile']['name']);
// form request
if ($_FILES['qqfile']['size'] == 0){
die ('{error: "file size is zero"}');
@ -25,7 +25,7 @@ if (isset($_GET['qqfile'])){
if (count($_GET)){
$_GET['success'] = true;
echo json_encode(array_merge($_GET));
echo json_encode(array_merge($_GET));
} else {
die ('{error: "query params not passed"}');
}

View file

@ -2,11 +2,11 @@
usleep(300);
$fileName;
$fileName = '';
if (isset($_GET['qqfile'])){
$fileName = $_GET['qqfile'];
// xhr request
$headers = apache_request_headers();
if ((int)$headers['Content-Length'] == 0){
@ -14,7 +14,7 @@ if (isset($_GET['qqfile'])){
}
} elseif (isset($_FILES['qqfile'])){
$fileName = basename($_FILES['qqfile']['name']);
// form request
if ($_FILES['qqfile']['size'] == 0){
die ('{error: "file size is zero"}');
@ -25,7 +25,7 @@ if (isset($_GET['qqfile'])){
if (count($_GET)){
//return query params
echo json_encode(array_merge($_GET, array('fileName'=>$fileName)));
echo json_encode(array_merge($_GET, array('fileName'=>$fileName)));
} else {
die ('{error: "query params not passed"}');
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

4
monolog/README.md Normal file
View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -6,9 +6,7 @@
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
@ -17,7 +15,7 @@ function numfriends_install() {
Hook::register('addon_settings', 'addon/numfriends/numfriends.php', 'numfriends_settings');
Hook::register('addon_settings_post', 'addon/numfriends/numfriends.php', 'numfriends_settings_post');
Logger::notice("installed numfriends");
DI::logger()->notice("installed numfriends");
}
/**
@ -39,7 +37,7 @@ function numfriends_settings_post($post) {
/**
*
* Called from the Addon Setting form.
* Called from the Addon Setting form.
* Add our own settings info to the page.
*
*/
@ -50,7 +48,7 @@ function numfriends_settings(array &$data)
}
$numfriends = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'display_friend_count', 24);
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/numfriends/');
$html = Renderer::replaceMacros($t, [
'$numfriends' => ['numfriends', DI::l10n()->t('How many contacts to display on profile sidebar'), $numfriends],

View file

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

View file

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

View file

@ -5,10 +5,9 @@
* Version: 1.1
* Author: Keith Fernie <http://friendika.me4.it/profile/keith>
* Hauke Altmann <https://snarl.de/profile/tugelblend>
*
*
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI;

View file

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

View file

@ -35,9 +35,7 @@
* setting.
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Core\Config\Util\ConfigFileManager;
@ -46,12 +44,12 @@ function piwik_install() {
Hook::register('load_config', 'addon/piwik/piwik.php', 'piwik_load_config');
Hook::register('page_end', 'addon/piwik/piwik.php', 'piwik_analytics');
Logger::notice("installed piwik addon");
DI::logger()->notice("installed piwik addon");
}
function piwik_load_config(ConfigFileManager $loader)
{
DI::app()->getConfigCache()->load($loader->loadAddonConfig('piwik'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('piwik'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
}
function piwik_analytics(string &$b)
@ -76,7 +74,7 @@ function piwik_analytics(string &$b)
* Add the Piwik tracking code for the site.
* If async is set to true use asynchronous tracking
*/
$scriptAsyncValue = $async ? 'true' : 'false';
$scriptPhpEndpoint = $shortendpoint ? 'js/' : 'piwik.php';
$scriptJsEndpoint = $shortendpoint ? 'js/' : 'piwik.js';

View file

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

View file

@ -2,6 +2,8 @@
namespace phpnut;
use CURLFile;
/**
* phpnut.php
* pnut.io PHP library
@ -99,10 +101,14 @@ class phpnut
// if processing stream_markers or any fast stream, decrease $sleepFor
public $streamingSleepFor = 20000;
private $_clientId;
private $_clientSecret;
/**
* Constructs an phpnut PHP object with the specified client ID and
* client secret.
* @param string $client_id The client ID you received from pnut.io when
* @param string $client_id_or_token The client ID you received from pnut.io when
* creating your app.
* @param string $client_secret The client secret you received from
* pnut.io when creating your app.
@ -155,14 +161,14 @@ class phpnut
* or not access to your app. Usually you would place this as a link for
* the user to client, or a redirect to send them to the auth URL.
* Also can be called after authentication for additional scopes
* @param string $callbackUri Where you want the user to be directed
* @param string $callback_uri Where you want the user to be directed
* after authenticating with pnut.io. This must be one of the URIs
* allowed by your pnut.io application settings.
* @param array $scope An array of scopes (permissions) you wish to obtain
* from the user. If you don't specify anything, you'll only receive
* access to the user's basic profile (the default).
*/
public function getAuthUrl(?string $callback_uri=null, array|string|null $scope=null): string
public function getAuthUrl(?string $callback_uri=null, array $scope=null): string
{
if (empty($this->_clientId)) {
throw new phpnutException('You must specify your pnut client ID');
@ -256,8 +262,10 @@ class phpnut
/**
* Check the scope of current token to see if it has required scopes
* has to be done after a check
*
* @return int|array
*/
public function checkScopes(array $app_scopes): int|array
public function checkScopes(array $app_scopes)
{
if (count($this->_scopes) === 0) {
return -1; // _scope is empty
@ -303,7 +311,7 @@ class phpnut
{
return $this->httpReq('delete', "{$this->_baseUrl}token");
}
/**
* Retrieve an app access token from the app.net API. This allows you
* to access the API without going through the user access flow if you
@ -314,7 +322,7 @@ class phpnut
* @return string The app access token
*/
public function getAppAccessToken()
{
{
if (empty($this->_clientId) || empty($this->_clientSecret)) {
throw new phpnutException('You must specify your Pnut client ID and client secret');
}
@ -450,8 +458,10 @@ class phpnut
/**
* Internal function to handle all
* HTTP requests (POST,PUT,GET,DELETE)
*
* @param string|array $params
*/
protected function httpReq(string $act, string $req, string|array $params=[], string $contentType='application/x-www-form-urlencoded')
protected function httpReq(string $act, string $req, $params = [], string $contentType='application/x-www-form-urlencoded')
{
$ch = curl_init($req);
$headers = [];
@ -520,7 +530,7 @@ class phpnut
} else {
throw new phpnutException($response['error']);
}
}
}
// look for response migration errors
elseif (isset($response['meta'], $response['meta']['error_message'])) {
@ -588,7 +598,7 @@ class phpnut
{
return $this->_last_request;
}
public function getLastResponse()
{
return $this->_last_response;
@ -738,7 +748,7 @@ class phpnut
* Delete a Post. The current user must be the same user who created the Post.
* It returns the deleted Post on success.
* @param integer $post_id The ID of the post to delete
* @param array An associative array representing the post that was deleted
* @return array An associative array representing the post that was deleted
*/
public function deletePost(int $post_id)
{
@ -752,7 +762,7 @@ class phpnut
* Retrieve the Posts that are 'in reply to' a specific Post.
* @param integer $post_id The ID of the post you want to retrieve replies for.
* @param array $params An associative array of optional general parameters.
* @return An array of associative arrays, each representing a single post.
* @return array An array of associative arrays, each representing a single post.
*/
public function getPostThread(int $post_id, array $params=[])
{
@ -767,7 +777,7 @@ class phpnut
* Retrieve revisions of a post. Currently only one can be created.
* @param integer $post_id The ID of the post you want to retrieve previous revisions of.
* @param array $params An associative array of optional general parameters.
* @return An array of associative arrays, each representing a single post.
* @return array An array of associative arrays, each representing a single post.
*/
public function getPostRevisions(int $post_id, array $params=[])
{
@ -781,13 +791,13 @@ class phpnut
/**
* Get the most recent Posts created by a specific User in reverse
* chronological order (most recent first).
* @param mixed $user_id Either the ID of the user you wish to retrieve posts by,
* @param string|int $user_id $user_id Either the ID of the user you wish to retrieve posts by,
* or the string "me", which will retrieve posts for the user you're authenticated
* as.
* @param array $params An associative array of optional general parameters.
* @return An array of associative arrays, each representing a single post.
* @return array An array of associative arrays, each representing a single post.
*/
public function getUserPosts(string|int $user_id='me', array $params=[])
public function getUserPosts($user_id = 'me', array $params=[])
{
return $this->httpReq(
'get',
@ -799,13 +809,13 @@ class phpnut
/**
* Get the most recent Posts mentioning by a specific User in reverse
* chronological order (newest first).
* @param mixed $user_id Either the ID of the user who is being mentioned, or
* @param string|int $user_id Either the ID of the user who is being mentioned, or
* the string "me", which will retrieve posts for the user you're authenticated
* as.
* @param array $params An associative array of optional general parameters.
* @return An array of associative arrays, each representing a single post.
* @return array An array of associative arrays, each representing a single post.
*/
public function getUserMentions(string|int $user_id='me', array $params=[])
public function getUserMentions($user_id='me', array $params=[])
{
return $this->httpReq(
'get',
@ -817,7 +827,7 @@ class phpnut
/**
* Get the currently authenticated user's recent messages
* @param array $params An associative array of optional general parameters.
* @return An array of associative arrays, each representing a single post.
* @return array An array of associative arrays, each representing a single post.
*/
public function getUserMessages(array $params=[])
{
@ -832,7 +842,7 @@ class phpnut
* Return the 20 most recent posts from the current User and
* the Users they follow.
* @param array $params An associative array of optional general parameters.
* @return An array of associative arrays, each representing a single post.
* @return array An array of associative arrays, each representing a single post.
*/
public function getUserStream(array $params=[])
{
@ -847,7 +857,7 @@ class phpnut
* Retrieve a list of all public Posts on pnut.io, often referred to as the
* global stream.
* @param array $params An associative array of optional general parameters.
* @return An array of associative arrays, each representing a single post.
* @return array An array of associative arrays, each representing a single post.
*/
public function getPublicPosts(array $params=[])
{
@ -860,7 +870,7 @@ class phpnut
/**
* Retrieve a list of "explore" streams
* @return An array of associative arrays, each representing a single explore stream.
* @return array An array of associative arrays, each representing a single explore stream.
*/
public function getPostExploreStreams()
{
@ -874,7 +884,7 @@ class phpnut
* Retrieve a list of posts from an "explore" stream on pnut.io.
* @param string $slug [<description>]
* @param array $params An associative array of optional general parameters.
* @return An array of associative arrays, each representing a single post.
* @return array An array of associative arrays, each representing a single post.
*/
public function getPostExploreStream(string $slug, array $params=[])
{
@ -916,10 +926,11 @@ class phpnut
* are: count, before_id, since_id, include_muted, include_deleted,
* and include_post_raw.
* See https://github.com/phpnut/api-spec/blob/master/resources/posts.md#general-parameters
* @param string|int $user_id
* @return array An array of associative arrays, each representing a single
* user who has bookmarked a post
*/
public function getBookmarked(string|int $user_id='me', array $params=[])
public function getBookmarked($user_id='me', array $params=[])
{
return $this->httpReq(
'get',
@ -967,7 +978,7 @@ class phpnut
/**
* Repost an existing Post object.
* @param integer $post_id The id of the post
* @return the reposted post
* @return mixed the reposted post
*/
public function repost(int $post_id)
{
@ -980,7 +991,7 @@ class phpnut
/**
* Delete a post that the user has reposted.
* @param integer $post_id The id of the post
* @return the un-reposted post
* @return mixed the un-reposted post
*/
public function deleteRepost(int $post_id)
{
@ -997,7 +1008,7 @@ class phpnut
* This will likely change as the API evolves, as of this writing allowed keys
* are: count, before_id, since_id, include_muted, include_deleted,
* include_directed_posts, and include_raw.
* @return An array of associative arrays, each representing a single post.
* @return array An array of associative arrays, each representing a single post.
*/
public function searchHashtags(string $hashtag, array $params=[])
{
@ -1044,7 +1055,7 @@ class phpnut
* This will likely change as the API evolves, as of this writing allowed keys
* are: count, before_id, since_id, include_muted, include_deleted,
* and include_post_raw.
* @return An array of associative arrays, each representing a single post.
* @return array An array of associative arrays, each representing a single post.
*/
public function getUserPersonalStream(array $params=[])
{
@ -1063,7 +1074,7 @@ class phpnut
);
}
}
/**
* Return the 20 most recent Posts from the current User's personalized stream
* and mentions stream merged into one stream.
@ -1071,7 +1082,7 @@ class phpnut
* This will likely change as the API evolves, as of this writing allowed keys
* are: count, before_id, since_id, include_muted, include_deleted,
* include_directed_posts, and include_raw.
* @return An array of associative arrays, each representing a single post.
* @return array An array of associative arrays, each representing a single post.
*/
public function getUserUnifiedStream(array $params=[])
{
@ -1096,14 +1107,14 @@ class phpnut
/**
* Returns a specific user object.
* @param mixed $user_id The ID of the user you want to retrieve, or the string "@-username", or the string
* @param string|int $user_id The ID of the user you want to retrieve, or the string "@-username", or the string
* "me" to retrieve data for the users you're currently authenticated as.
* @param array $params An associative array of optional general parameters.
* This will likely change as the API evolves, as of this writing allowed keys
* are: include_raw|include_user_raw.
* @return array An associative array representing the user data.
*/
public function getUser(string|int $user_id='me', array $params=[])
public function getUser($user_id='me', array $params=[])
{
return $this->httpReq(
'get',
@ -1131,10 +1142,10 @@ class phpnut
/**
* Add the specified user ID to the list of users followed.
* Returns the User object of the user being followed.
* @param integer $user_id The user ID of the user to follow.
* @param string|int $user_id The user ID of the user to follow.
* @return array An associative array representing the user you just followed.
*/
public function followUser(string|int $user_id)
public function followUser($user_id)
{
return $this->httpReq(
'put',
@ -1145,10 +1156,10 @@ class phpnut
/**
* Removes the specified user ID to the list of users followed.
* Returns the User object of the user being unfollowed.
* @param integer $user_id The user ID of the user to unfollow.
* @param string|int $user_id The user ID of the user to unfollow.
* @return array An associative array representing the user you just unfollowed.
*/
public function unfollowUser(string|int $user_id)
public function unfollowUser($user_id)
{
return $this->httpReq(
'delete',
@ -1158,13 +1169,13 @@ class phpnut
/**
* Returns an array of User objects the specified user is following.
* @param mixed $user_id Either the ID of the user being followed, or
* @param string|int $user_id Either the ID of the user being followed, or
* the string "me", which will retrieve posts for the user you're authenticated
* as.
* @return array An array of associative arrays, each representing a single
* user following $user_id
*/
public function getFollowing(string|int $user_id='me', array $params=[])
public function getFollowing($user_id='me', array $params=[])
{
return $this->httpReq(
'get',
@ -1172,31 +1183,31 @@ class phpnut
. $this->buildQueryString($params)
);
}
/**
* Returns an array of User ids the specified user is following.
* @param mixed $user_id Either the ID of the user being followed, or
* @param string|int $user_id Either the ID of the user being followed, or
* the string "me", which will retrieve posts for the user you're authenticated
* as.
* @return array user ids the specified user is following.
*/
public function getFollowingIDs(string|int $user_id='me')
public function getFollowingIDs($user_id='me')
{
return $this->httpReq(
'get',
"{$this->_baseUrl}users/{$user_id}/following?include_user=0"
);
}
/**
* Returns an array of User objects for users following the specified user.
* @param mixed $user_id Either the ID of the user being followed, or
* @param string|int $user_id Either the ID of the user being followed, or
* the string "me", which will retrieve posts for the user you're authenticated
* as.
* @return array An array of associative arrays, each representing a single
* user following $user_id
*/
public function getFollowers(string|int $user_id='me', array $params=[])
public function getFollowers($user_id='me', array $params=[])
{
return $this->httpReq(
'get',
@ -1204,15 +1215,15 @@ class phpnut
. $this->buildQueryString($params)
);
}
/**
* Returns an array of User ids for users following the specified user.
* @param mixed $user_id Either the ID of the user being followed, or
* @param string|int $user_id Either the ID of the user being followed, or
* the string "me", which will retrieve posts for the user you're authenticated
* as.
* @return array user ids for users following the specified user
*/
public function getFollowersIDs(string|int $user_id='me')
public function getFollowersIDs($user_id='me')
{
return $this->httpReq(
'get',
@ -1236,9 +1247,9 @@ class phpnut
/**
* Mute a user
* @param integer $user_id The user ID to mute
* @param string|int $user_id The user ID to mute
*/
public function muteUser(string|int $user_id)
public function muteUser($user_id)
{
return $this->httpReq(
'put',
@ -1248,9 +1259,9 @@ class phpnut
/**
* Unmute a user
* @param integer $user_id The user ID to unmute
* @param string|int $user_id The user ID to unmute
*/
public function unmuteUser(string|int $user_id)
public function unmuteUser($user_id)
{
return $this->httpReq(
'delete',
@ -1285,10 +1296,10 @@ class phpnut
/**
* List the users who match a specific search term
* @param string $search The search query. Supports @username or #tag searches as
* @param string $query The search query. Supports @username or #tag searches as
* well as normal search terms. Searches username, display name, bio information.
* Does not search posts.
* @return array An array of associative arrays, each representing one user.
* @return array|false An array of associative arrays, each representing one user.
*/
public function searchUsers(array $params=[], string $query='')
{
@ -1328,12 +1339,14 @@ class phpnut
*/
protected function updateUserImage(string $image, string $which='avatar')
{
$mimeType = '';
$test = @getimagesize($image);
if ($test && array_key_exists('mime', $test)) {
$mimeType = $test['mime'];
}
$data = [
$which => new CurlFile($image, $mimeType)
$which => new CURLFile($image, $mimeType)
];
return $this->httpReq(
'post-raw',
@ -1445,10 +1458,10 @@ class phpnut
/**
* get an existing private message channel between multiple users
* @param mixed $users Can be a comma- or space-separated string, or an array.
* @param string|array $users Can be a comma- or space-separated string, or an array.
* Usernames with @-symbol, or user ids.
*/
public function getExistingPM(string|array $users, array $params=[])
public function getExistingPM($users, array $params=[])
{
if (is_string($users)) {
$users = explode(',', str_replace(' ', ',', $users));
@ -1561,7 +1574,7 @@ class phpnut
/**
* Retrieve a list of "explore" streams
* @return An array of associative arrays, each representing a single explore stream.
* @return array An array of associative arrays, each representing a single explore stream.
*/
public function getChannelExploreStreams()
{
@ -1575,7 +1588,7 @@ class phpnut
* Retrieve a list of channels from an "explore" stream on pnut.io.
* @param string $slug [<description>]
* @param array $params An associative array of optional general parameters.
* @return An array of associative arrays, each representing a single channel.
* @return array An array of associative arrays, each representing a single channel.
*/
public function getChannelExploreStream(string $slug, array $params=[])
{
@ -1585,7 +1598,7 @@ class phpnut
. $this->buildQueryString($params)
);
}
/**
* mark channel inactive
*/
@ -1685,11 +1698,11 @@ class phpnut
/**
* create message
* @param $channelid numeric or "pm" for auto-channel (type=io.pnut.core.pm)
* @param string|int $channelid numeric or "pm" for auto-channel (type=io.pnut.core.pm)
* @param array $data array('text'=>'YOUR_MESSAGE') If a type=io.pnut.core.pm, then "destinations" key can be set to address as an array of people to send this PM too
* @param array $params query parameters
*/
public function createMessage(string|int $channelid, array $data, array $params=[])
public function createMessage($channelid, array $data, array $params=[])
{
if (isset($data['destinations'])) {
if (is_string($data['destinations'])) {
@ -1802,16 +1815,16 @@ class phpnut
public function createFile($file, array $data, array $params=[])
{
if (!$file) {
throw new PhpnutException('You must specify a path to a file');
throw new phpnutException('You must specify a path to a file');
}
if (!file_exists($file)) {
throw new PhpnutException('File path specified does not exist');
throw new phpnutException('File path specified does not exist');
}
if (!is_readable($file)) {
throw new PhpnutException('File path specified is not readable');
throw new phpnutException('File path specified is not readable');
}
if (!array_key_exists('type', $data) || !$data['type']) {
throw new PhpnutException('Type is required when creating a file');
throw new phpnutException('Type is required when creating a file');
}
if (!array_key_exists('name', $data)) {
$data['name'] = basename($file);
@ -1823,7 +1836,7 @@ class phpnut
$mimeType = null;
}
if (!array_key_exists('kind', $data)) {
$test = @getimagesize($path);
$test = @getimagesize($file);
if ($test && array_key_exists('mime', $test)) {
$data['kind'] = 'image';
if (!$mimeType) {
@ -1840,7 +1853,7 @@ class phpnut
finfo_close($finfo);
}
if (!$mimeType) {
throw new PhpnutException('Unable to determine mime type of file, try specifying it explicitly');
throw new phpnutException('Unable to determine mime type of file, try specifying it explicitly');
}
$data['content'] = new \CurlFile($file, $mimeType);
return $this->httpReq(
@ -2001,7 +2014,7 @@ class phpnut
$json = json_encode($data);
return $this->httpReq(
'post',
$this->_baseUrl.'polls?'.$this->buildQueryString($params),
$this->_baseUrl.'polls?'.$this->buildQueryString($params),
$json,
'application/json'
);
@ -2010,7 +2023,7 @@ class phpnut
/**
* Responds to a poll.
* @param integer $poll_id The ID of the poll to respond to
* @param array list of positions for the poll response
* @param array $positions list of positions for the poll response
* @param array $params An associative array of optional general parameters.
*/
public function respondToPoll(int $poll_id, array $positions, array $params=[])
@ -2019,7 +2032,7 @@ class phpnut
return $this->httpReq(
'put',
$this->_baseUrl.'polls/'.urlencode($poll_id).'/response?'.$this->buildQueryString($params),
$json,
$json,
'application/json'
);
}
@ -2085,8 +2098,6 @@ class phpnut
* List the polls that match a specific search term
* @param array $params a list of filter, search query, and general Poll parameters
* see: https://docs.pnut.io/resources/channels/search
* @param string $query The search query. Supports
* normal search terms.
* @return array An array of associative arrays, each representing one poll.
* or false on error
*/
@ -2118,7 +2129,7 @@ class phpnut
$params
);
}
/**
* Get User Information
*/
@ -2129,7 +2140,7 @@ class phpnut
"{$this->_baseUrl}token"
);
}
/**
* Get Application Authorized User IDs
*/
@ -2147,7 +2158,7 @@ class phpnut
$params
);
}
/**
* Get Application Authorized User Tokens
*/
@ -2166,14 +2177,12 @@ class phpnut
);
}
/**
* Registers your function (or an array of object and method) to be called
* whenever an event is received via an open pnut.io stream. Your function
* will receive a single parameter, which is the object wrapper containing
* the meta and data.
* @param mixed A PHP callback (either a string containing the function name,
* @param mixed $function A PHP callback (either a string containing the function name,
* or an array where the first element is the class/object and the second
* is the method).
*/
@ -2181,7 +2190,7 @@ class phpnut
{
$this->_streamCallback = $function;
}
/**
* Opens a stream that's been created for this user/app and starts sending
* events/objects to your defined callback functions. You must define at
@ -2231,10 +2240,9 @@ class phpnut
);
return true;
}
/**
* Close the currently open stream.
* @return true;
*/
public function closeStream(): void
{
@ -2251,7 +2259,7 @@ class phpnut
$this->_currentStream = null;
$this->_multiStream = null;
}
/**
* Retrieve all streams for the current access token.
* @return array An array of stream definitions.
@ -2263,7 +2271,7 @@ class phpnut
"{$this->_baseUrl}streams"
);
}
/**
* Returns a single stream specified by a stream ID. The stream must have been
* created with the current access token.
@ -2276,7 +2284,7 @@ class phpnut
$this->_baseUrl.'streams/'.urlencode($streamId)
);
}
/**
* Creates a stream for the current app access token.
*
@ -2307,7 +2315,7 @@ class phpnut
);
return $response;
}
/**
* Update stream for the current app access token
*
@ -2338,7 +2346,7 @@ class phpnut
);
return $response;
}
/**
* Deletes a stream if you no longer need it.
*
@ -2352,7 +2360,7 @@ class phpnut
$this->_baseUrl.'streams/'.urlencode($streamId)
);
}
/**
* Deletes all streams created by the current access token.
*/
@ -2363,7 +2371,7 @@ class phpnut
"{$this->_baseUrl}streams"
);
}
/**
* Internal function used to process incoming chunks from the stream. This is only
* public because it needs to be accessed by CURL. Do not call or use this function
@ -2394,7 +2402,7 @@ class phpnut
}
return strlen($data);
}
/**
* Opens a long lived HTTP connection to the pnut.io servers, and sends data
* received to the httpStreamReceive function. As a general rule you should not
@ -2426,7 +2434,7 @@ class phpnut
$this->_lastStreamActivity = time();
curl_multi_add_handle($this->_multiStream, $this->_currentStream);
}
public function reconnectStream(): void
{
$this->closeStream();
@ -2442,12 +2450,12 @@ class phpnut
}
$this->httpStream('get', $this->_streamUrl);
}
/**
* Process an open stream for x microseconds, then return. This is useful if you want
* to be doing other things while processing the stream. If you just want to
* consume the stream without other actions, you can call processForever() instead.
* @param float @microseconds The number of microseconds to process for before
* @param null|float $microseconds The number of microseconds to process for before
* returning. There are 1,000,000 microseconds in a second.
*
* @return void
@ -2487,7 +2495,7 @@ class phpnut
}
} while ($timeSoFar+$sleepFor < $microseconds);
}
/**
* Process an open stream forever. This function will never return, if you
* want to perform other actions while consuming the stream, you should use

View file

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

View file

@ -6,10 +6,8 @@
* Author: Keith Fernie <http://friendika.me4.it/profile/keith>
*/
use Friendica\App;
use Friendica\BaseModule;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
@ -29,7 +27,7 @@ function public_server_install()
function public_server_load_config(ConfigFileManager $loader)
{
DI::app()->getConfigCache()->load($loader->loadAddonConfig('public_server'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('public_server'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
}
function public_server_register_account($b)
@ -48,7 +46,7 @@ function public_server_register_account($b)
function public_server_cron($b)
{
Logger::notice("public_server: cron start");
DI::logger()->notice("public_server: cron start");
$users = DBA::selectToArray('user', [], ["`account_expires_on` > ? AND `account_expires_on` < ?
AND `expire_notification_sent` <= ?", DBA::NULL_DATETIME, DateTimeFormat::utc('now + 5 days'), DBA::NULL_DATETIME]);
@ -97,7 +95,7 @@ function public_server_cron($b)
}
}
Logger::notice("public_server: cron end");
DI::logger()->notice("public_server: cron end");
}
function public_server_enotify(array &$b)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -3,12 +3,13 @@
namespace Friendica\Addon\ratioed;
use Friendica\Content\Pager;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\User;
use Friendica\Model\Verb;
use Friendica\Module\Moderation\Users\Active;
use Friendica\Protocol\Activity;
/**
* This class implements the "Behaviour" panel in Moderation/Users
@ -24,38 +25,17 @@ class RatioedPanel extends Active
return Renderer::replaceMacros($template, array('$config' => DI::baseUrl() . '/settings/addon'));
}
$action = $this->parameters['action'] ?? '';
$uid = $this->parameters['uid'] ?? 0;
$user = [];
if ($uid) {
$user = User::getById($uid, ['username', 'blocked']);
if (!$user) {
$this->systemMessages->addNotice($this->t('User not found'));
$this->baseUrl->redirect('moderation/users');
$this->baseUrl->redirect('ratioed');
}
}
switch ($action) {
case 'delete':
if ($this->session->getLocalUserId() != $uid) {
self::checkFormSecurityTokenRedirectOnError('moderation/users/active', 'moderation_users_active', 't');
// delete user
User::remove($uid);
$this->systemMessages->addNotice($this->t('User "%s" deleted', $user['username']));
} else {
$this->systemMessages->addNotice($this->t('You can\'t remove yourself'));
}
$this->baseUrl->redirect('moderation/users/active');
break;
case 'block':
self::checkFormSecurityTokenRedirectOnError('moderation/users/active', 'moderation_users_active', 't');
User::block($uid);
$this->systemMessages->addNotice($this->t('User "%s" blocked', $user['username']));
$this->baseUrl->redirect('moderation/users/active');
break;
}
$pager = new Pager($this->l10n, $this->args->getQueryString(), 100);
$valid_orders = [
@ -68,9 +48,9 @@ class RatioedPanel extends Active
];
$order = 'last-item';
$order_direction = '-';
if (!empty($request['o'])) {
$new_order = $request['o'];
$order_direction = '+';
if (!empty($_REQUEST['o'])) {
$new_order = $_REQUEST['o'];
if ($new_order[0] === '-') {
$order_direction = '-';
$new_order = substr($new_order, 1);
@ -96,6 +76,11 @@ class RatioedPanel extends Active
$this->t('Comments last 24h'),
$this->t('Reactions last 24h'),
$this->t('Ratio last 24h'),
$this->t('Replies last month'),
$this->t('Reply likes'),
$this->t('Respondee likes'),
$this->t('OP likes'),
$this->t('Reply guy score'),
];
$field_names = [
'name',
@ -108,6 +93,11 @@ class RatioedPanel extends Active
'comments',
'reactions',
'ratio',
'reply_count',
'reply_likes',
'reply_respondee_likes',
'reply_op_likes',
'reply_guy_score',
];
$th_users = array_map(null, $header_titles, $valid_orders, $field_names);
@ -146,9 +136,130 @@ class RatioedPanel extends Active
]);
}
protected function getReplyGuyRow($contact_uid)
{
$like_vid = Verb::getID(Activity::LIKE);
$post_vid = Verb::getID(Activity::POST);
/*
* This is a complicated query.
*
* The innermost select retrieves a chain of four posts: an
* original post, a target comment (possibly deep down in the
* thread), a reply from our user, and a like for that reply.
* If there's no like, we still want to count the reply, so we
* use an outer join.
*
* The second select adds "points" for different kinds of
* likes. The outermost select then counts up these points,
* and the number of distinct replies.
*/
$reply_guy_result = DBA::p('
SELECT
COUNT(distinct reply_id) AS replies_total,
SUM(like_point) AS like_total,
SUM(target_like_point) AS target_like_total,
SUM(original_like_point) AS original_like_total
FROM (
SELECT
reply_id,
like_date,
like_date IS NOT NULL AS like_point,
like_author = target_author AS target_like_point,
like_author = original_author AS original_like_point
FROM (
SELECT
original_post.`uri-id` AS original_id,
original_post.`author-id` AS original_author,
original_post.created AS original_date,
target_post.`uri-id` AS target_id,
target_post.`author-id` AS target_author,
target_post.created AS target_date,
reply_post.`uri-id` AS reply_id,
reply_post.`author-id` AS reply_author,
reply_post.created AS reply_date,
like_post.`uri-id` AS like_id,
like_post.`author-id` AS like_author,
like_post.created AS like_date
FROM
post AS original_post
JOIN
post AS target_post
ON
original_post.`uri-id` = target_post.`parent-uri-id`
JOIN
post AS reply_post
ON
target_post.`uri-id` = reply_post.`thr-parent-id` AND
reply_post.`author-id` = ? AND
reply_post.`author-id` != target_post.`author-id` AND
reply_post.`author-id` != original_post.`author-id` AND
reply_post.`uri-id` != reply_post.`thr-parent-id` AND
reply_post.vid = ? AND
reply_post.created > CURDATE() - INTERVAL 1 MONTH
LEFT OUTER JOIN
post AS like_post
ON
reply_post.`uri-id` = like_post.`thr-parent-id` AND
like_post.vid = ? AND
like_post.`author-id` != reply_post.`author-id`
) AS post_meta
) AS reply_counts
', $contact_uid, $post_vid, $like_vid);
return $reply_guy_result;
}
// https://stackoverflow.com/a/48283297/235936
protected function sigFig($value, $digits)
{
if ($value == 0) {
$decimalPlaces = $digits - 1;
} elseif ($value < 0) {
$decimalPlaces = $digits - floor(log10($value * -1)) - 1;
} else {
$decimalPlaces = $digits - floor(log10($value)) - 1;
}
$answer = ($decimalPlaces > 0) ?
number_format($value, $decimalPlaces) : round($value, $decimalPlaces);
return $answer;
}
protected function fillReplyGuyData(&$user)
{
$reply_guy_result = $this->getReplyGuyRow($user['user_contact_uid']);
if (DBA::isResult($reply_guy_result)) {
$reply_guy_result_row = DBA::fetch($reply_guy_result);
$user['reply_count'] = (int) $reply_guy_result_row['replies_total'] ?? 0;
$user['reply_likes'] = (int) $reply_guy_result_row['like_total'] ?? 0;
$user['reply_respondee_likes'] = (int) $reply_guy_result_row['target_like_total'] ?? 0;
$user['reply_op_likes'] = (int) $reply_guy_result_row['original_like_total'] ?? 0;
$denominator = $user['reply_likes'] + $user['reply_respondee_likes'] + $user['reply_op_likes'];
if ($user['reply_count'] === 0) {
$user['reply_guy'] = false;
$user['reply_guy_score'] = 0;
} elseif ($denominator == 0) {
$user['reply_guy'] = true;
$user['reply_guy_score'] = '∞';
} else {
$reply_guy_score = $user['reply_count'] / $denominator;
$user['reply_guy'] = $reply_guy_score >= 1.0;
$user['reply_guy_score'] = $this->sigFig($reply_guy_score, 2);
}
} else {
$user['reply_count'] = "error";
$user['reply_likes'] = "error";
$user['reply_respondee_likes'] = "error";
$user['reply_op_likes'] = "error";
$user['reply_guy'] = false;
$user['reply_guy_score'] = 0;
}
}
protected function setupUserCallback(): \Closure
{
Logger::debug("ratioed: setupUserCallback");
DI::logger()->debug("ratioed: setupUserCallback");
$parentCallback = parent::setupUserCallback();
return function ($user) use ($parentCallback) {
$blocked_count = DBA::count('user-contact', ['uid' => $user['uid'], 'is-blocked' => 1]);
@ -158,9 +269,8 @@ class RatioedPanel extends Active
if (DBA::isResult($self_contact_result)) {
$self_contact_result_row = DBA::fetch($self_contact_result);
$user['user_contact_uid'] = $self_contact_result_row['user_contact_uid'];
}
else {
$user['user_contact_uid'] = NULL;
} else {
$user['user_contact_uid'] = null;
}
if ($user['user_contact_uid']) {
@ -172,34 +282,34 @@ class RatioedPanel extends Active
if ($user['reactions'] > 0) {
$user['ratio'] = number_format($user['comments'] / $user['reactions'], 1, '.', '');
$user['ratioed'] = (float)($user['ratio']) >= 2.0;
}
else {
} else {
$user['reactions'] = 0;
if ($user['comments'] == 0) {
$user['ratio'] = '0';
$user['comments'] = 0;
$user['ratio'] = 0;
$user['ratioed'] = false;
}
else {
} else {
$user['ratio'] = '∞';
$user['ratioed'] = false;
}
}
}
else {
} else {
$user['comments'] = 'error';
$user['reactions'] = 'error';
$user['ratio'] = 'error';
$user['ratioed'] = false;
}
}
else {
} else {
$user['comments'] = 'error';
$user['reactions'] = 'error';
$user['ratio'] = 'error';
$user['ratioed'] = false;
}
$this->fillReplyGuyData($user);
$user = $parentCallback($user);
Logger::debug("ratioed: setupUserCallback", [
DI::logger()->debug("ratioed: setupUserCallback", [
'uid' => $user['uid'],
'blocked_by' => $user['blocked_by'],
'comments' => $user['comments'],

View file

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

View file

@ -2,7 +2,7 @@
<div class="panel-body">
<h2>Ratioed Plugin Help</h2>
<p>
This plugin provides administrators with additional statistics about
This plugin provides moderators with additional statistics about
the behaviour of users. These may be useful as early warning signs
that warrant more carefully watching the behaviour of a user. They
are <em>not</em> suitable as a trigger for instantly blocking,
@ -28,7 +28,7 @@
<p>
This plugin allows viewing of an actual ratio, calculated over the
last 24 hours. This is a useful timeframe for sudden dogpiling
events that administrators might not otherwise notice. The plugin
events that moderators might not otherwise notice. The plugin
also calculates other statistics.
</p>
<h3>Explanation of Statistics</h3>
@ -68,10 +68,63 @@
24h". It is intended to approximate the traditional ratio as
understood on Twitter.
</p>
<h4>Replies last month</h4>
<p>
This is the number of times the user posted a reply to someone
else, on a thread the user did not start, any time in the last
month.
</p>
<h4>Reply likes</h4>
<p>
This is the number of likes received by the user on their
replies to other people's posts in the last month. Replies that
receive likes can be assumed to be more of a valuable
contribution than replies that do not.
</p>
<h4>Respondee likes</h4>
<p>
The number of times in the last month the user replied to
someone else's comment and that person then liked the reply.
Likes to replies are not necessarily a positive thing, but if
the person you're replying to approves the reply, that's a very
good sign. Of course it's also common in a debate for neither
side to like the other side's comments without that indicating
an unhealthy interaction, so interpret this statistic cautiously.
</p>
<h4>OP likes</h4>
<p>
The number of times in the last month the user replied on a
thread and the original poster that started the thread liked the
reply. While there is no formal concept of "ownership" of a
thread, conventionally the original poster is assumed to have
started the thread for a reason, and making replies that do not
fulfil that purpose are bad etiquette. Getting approval from
the original poster therefore is a good sign that the user is
posting replies that are wanted.
</p>
<h4>Reply guy score</h4>
<p>
A <a href="https://en.wikipedia.org/wiki/Reply_guy">"reply
guy"</a> is a common Internet phenomenon of people
(disproportionately male) posting unwanted comments on other
(disproportionately female) people's threads, derailing the
conversation. This score loosely quantifies this phenomenon,
as the ratio betwen the number of replies and the sum of likes,
respondee likes, and OP likes. This formula gives extra weight
to particularly relevant likes: a reply to a top-level post that
is liked by the original poster scores the maximum of 3
"points". A score above 1.0 might indicate cause for concern
for moderators.
</p>
<p>
Since this is indicative of long-term behaviour, the score is
calculated over a month instead of 24 hours.
</p>
</p>
<h3>Performance</h3>
<p>
The statistics are computed from scratch each time the page loads.
It's possible that this might put a heavy load on the database. and
It's possible that this might put a heavy load on the database, and
the page may take a long time to load.
</p>
<h3>Extending</h3>

View file

@ -2,26 +2,21 @@
<link rel="stylesheet" href="view/theme/frio/css/mod_admin.css?v={{constant('\Friendica\App::VERSION')}}" type="text/css" media="screen"/>
<div id="admin-users" class="adminpage generic-page-wrapper">
<h1>{{$title}} - {{$page}} ({{$count}})</h1>
<p>
<a href="{{$base_url}}/moderation/users/create" class="btn btn-primary"><i class="fa fa-user-plus"></i> {{$h_newuser}}</a>
</p>
<h1>
{{$title}} - {{$page}} ({{$count}})
<a href="{{$base_url}}/ratioed/help"><i style="float: right; font-size: 60%" class="fa fa-question-circle fa-fw" aria-hidden="true"></i></a>
</h1>
<form action="{{$baseurl}}/{{$query_string}}" method="post">
<input type="hidden" name="form_security_token" value="{{$form_security_token}}">
<table id="users" class="table table-hover">
<thead>
<tr>
<th>
<div class="checkbox">
<input type="checkbox" id="admin-settings-users-select" class="selecttoggle" data-select-class="users_ckbx"/>
<label for="admin-settings-users-select"></label>
</div>
</th>
<th></th>
<th></th>
{{foreach $th_users as $k=>$th}}
{{if $k < 2 || $order_users == $th.1 || ($k==5 && !in_array($order_users,[$th_users.2.1, $th_users.3.1, $th_users.4.1])) }}
{{if $k < 2 || $order_users == $th.1 || ($k==4 && !in_array($order_users,[$th_users.2.1, $th_users.3.1, $th_users.5.1])) }}
<th class="th-{{$k}}">
<a href="{{$baseurl}}/moderation/users/active?o={{if $order_direction_users == "+"}}-{{/if}}{{$th.1}}" class="table-order">
<a href="{{$baseurl}}/ratioed?o={{if $order_direction_users == "+"}}-{{/if}}{{$th.1}}" class="table-order">
{{if $order_users == $th.1}}
{{if $order_direction_users == "+"}}
&#8595;
@ -41,17 +36,8 @@
</thead>
<tbody>
{{foreach $users as $u}}
<tr id="user-{{$u.uid}}" class="{{if $u.ratioed}}blocked{{/if}}">
<td>
{{if $u.is_deletable}}
<div class="checkbox">
<input type="checkbox" class="users_ckbx" id="id_user_{{$u.uid}}" name="user[]" value="{{$u.uid}}"/>
<label for="id_user_{{$u.uid}}"></label>
</div>
{{else}}
&nbsp;
{{/if}}
</td>
<tr id="user-{{$u.uid}}" class="{{if $u.ratioed || $u.reply_guy}}blocked{{/if}}">
<td></td>
<td><img class="avatar-nano" src="{{$u.micro}}" title="{{$u.nickname}}"></td>
<td><a href="{{$u.url}}" title="{{$u.nickname}}"> {{$u.name}}</a></td>
<td>{{$u.email}}</td>
@ -63,11 +49,7 @@
<td>{{$u.login_date}}</td>
{{/if}}
{{if $order_users == $th_users.4.1}}
<td>{{$u.lastitem_date}}</td>
{{/if}}
{{if !in_array($order_users,[$th_users.2.1, $th_users.3.1, $th_users.4.1]) }}
{{if $order_users == $th_users.5.1}}
<td>
<i class="fa
{{if $u.page_flags_raw==0}}fa-user{{/if}} {{* PAGE_NORMAL *}}
@ -91,6 +73,10 @@
</td>
{{/if}}
{{if !in_array($order_users,[$th_users.2.1, $th_users.3.1, $th_users.5.1]) }}
<td>{{$u.lastitem_date}}</td>
{{/if}}
<td class="text-right">
<button type="button" class="btn-link admin-settings-action-link" onclick="return details({{$u.uid}})"><span class="caret"></span></button>
</td>
@ -135,30 +121,11 @@
{{/foreach}}
</td>
<td class="text-right">
{{if $u.is_deletable}}
<a href="{{$baseurl}}/moderation/users/active/block/{{$u.uid}}?t={{$form_security_token}}" class="admin-settings-action-link" title="{{$block}}">
<i class="fa fa-ban" aria-hidden="true"></i>
</a>
<a href="{{$baseurl}}/moderation/users/active/delete/{{$u.uid}}?t={{$form_security_token}}" class="admin-settings-action-link" title="{{$delete}}" onclick="return confirm_delete('{{$confirm_delete}}','{{$u.name}}')">
<i class="fa fa-trash" aria-hidden="true"></i>
</a>
{{else}}
&nbsp;
{{/if}}
</td>
<td class="text-right"></td>
</tr>
{{/foreach}}
</tbody>
</table>
<div class="panel-footer">
<button type="submit" name="page_users_block" value="1" class="btn btn-warning">
<i class="fa fa-ban" aria-hidden="true"></i> {{$block}}
</button>
<button type="submit" name="page_users_delete" value="1" class="btn btn-danger" onclick="return confirm_delete('{{$confirm_delete_multi}}')">
<i class="fa fa-trash" aria-hidden="true"></i> {{$delete}}
</button>
</div>
{{$pager nofilter}}
</form>
</div>

View file

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

View file

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

View file

@ -4,10 +4,10 @@ namespace Friendica\Addon\s3_storage\src;
defined('AKEEBAENGINE') or define('AKEEBAENGINE', 1);
use Akeeba\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 Akeeba\S3\Configuration;
use Akeeba\S3\Connector;
use Akeeba\S3\Exception\CannotDeleteFile;
use Akeeba\S3\Input;
use Friendica\Core\Storage\Capability\ICanWriteToStorage;
use Friendica\Core\Storage\Exception\StorageException;
use Friendica\Util\Strings;

View file

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

View file

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

View file

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

View file

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

View file

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

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