commit
da40c96e9a
228 changed files with 26874 additions and 32654 deletions
15
.github/issue_template.md
vendored
Normal file
15
.github/issue_template.md
vendored
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
### Expected behavior
|
||||||
|
|
||||||
|
### Actual behavior
|
||||||
|
|
||||||
|
### Steps to reproduce the problem
|
||||||
|
|
||||||
|
### Friendica version you encountered the problem
|
||||||
|
|
||||||
|
see `example.com/friendica` on your Friendica node for the version information.
|
||||||
|
|
||||||
|
### Friendica source (git, zip)
|
||||||
|
|
||||||
|
### PHP version
|
||||||
|
|
||||||
|
### SQL version
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -53,7 +53,8 @@ nbproject
|
||||||
venv/
|
venv/
|
||||||
|
|
||||||
#ignore Composer dependencies
|
#ignore Composer dependencies
|
||||||
vendor
|
/vendor
|
||||||
|
/view/asset
|
||||||
|
|
||||||
#ignore config files from JetBrains
|
#ignore config files from JetBrains
|
||||||
/.idea
|
/.idea
|
22
CHANGELOG
22
CHANGELOG
|
@ -2,11 +2,11 @@ Version 3.6 (2018-03-23)
|
||||||
Friendica Core:
|
Friendica Core:
|
||||||
Updates to the translations (DE, EN_GB, EN_US, ES, FR, IT, ZH_CN) [translation teams]
|
Updates to the translations (DE, EN_GB, EN_US, ES, FR, IT, ZH_CN) [translation teams]
|
||||||
Updates for the Danish and French regions [Alkarex]
|
Updates for the Danish and French regions [Alkarex]
|
||||||
Update for the documentation [andyhee, annando, rabuzarus, ratten, rudlof, silke, tobiasd]
|
Update for the documentation [andyhee, annando, rabuzarus, ratten, rudloff, silke, tobiasd]
|
||||||
Updates to the themes [Andi-K, annando, fabrixxm, hoergen, rebeka-catalina, rabuzarus]
|
Updates to the themes [Andi-K, annando, fabrixxm, hoergen, rebeka-catalina, rabuzarus]
|
||||||
Enhancements to the ARIA support in frio [rabuzarus]
|
Enhancements to the ARIA support in frio [rabuzarus]
|
||||||
Enhancements to the DB handling and structure [annando]
|
Enhancements to the DB handling and structure [annando]
|
||||||
Enhancements to the API [annando, fabrixxm, MrPetovan, rudlof]
|
Enhancements to the API [annando, fabrixxm, MrPetovan, rudloff]
|
||||||
Enhancements to the support of Open Graph with images [hoergen]
|
Enhancements to the support of Open Graph with images [hoergen]
|
||||||
Enhancements to the Diaspora federation (participation signal, relay of dislikes, basic forum support for D*, Birthdays) [annando]
|
Enhancements to the Diaspora federation (participation signal, relay of dislikes, basic forum support for D*, Birthdays) [annando]
|
||||||
Enhancements to the OStatus federation [annando]
|
Enhancements to the OStatus federation [annando]
|
||||||
|
@ -198,7 +198,7 @@ Version 3.5.3 (2017-10-05)
|
||||||
Fixes to buffer, diaspora, libertree, pumpio, gnu social, tumblr, twitter and wppost bridges to redistribute remote_self content [annando]
|
Fixes to buffer, diaspora, libertree, pumpio, gnu social, tumblr, twitter and wppost bridges to redistribute remote_self content [annando]
|
||||||
Fixed a bug in securemail settings form [FuzzJunket]
|
Fixed a bug in securemail settings form [FuzzJunket]
|
||||||
external poller addons are deprecated, as this is now a core functionality [annando]
|
external poller addons are deprecated, as this is now a core functionality [annando]
|
||||||
|
|
||||||
Friendica Directory:
|
Friendica Directory:
|
||||||
Fix a problem with the Vagrant config [tobiasd]
|
Fix a problem with the Vagrant config [tobiasd]
|
||||||
Fix not working node health page [Hypolite]
|
Fix not working node health page [Hypolite]
|
||||||
|
@ -208,7 +208,7 @@ Version 3.5.3 (2017-10-05)
|
||||||
1257, 2786, 2864, 2872, 2998, 3013, 3018, 3131, 3180, 3234, 3248,
|
1257, 2786, 2864, 2872, 2998, 3013, 3018, 3131, 3180, 3234, 3248,
|
||||||
3309, 3313, 3360, 3362, 3391, 3482, 3511, 3512, 3515, 3516, 3529,
|
3309, 3313, 3360, 3362, 3391, 3482, 3511, 3512, 3515, 3516, 3529,
|
||||||
3531, 3536, 3545, 3552, 3553, 3560, 3571, 3589, 3592, 3599, 3615,
|
3531, 3536, 3545, 3552, 3553, 3560, 3571, 3589, 3592, 3599, 3615,
|
||||||
3616, 3621, 3624, 3636, 3645, 3661, 3684, 3685, 3691, 3696, 3699,
|
3616, 3621, 3624, 3636, 3645, 3661, 3684, 3685, 3691, 3696, 3699,
|
||||||
3700, 3732
|
3700, 3732
|
||||||
|
|
||||||
Version 3.5.2 (2017-06-06)
|
Version 3.5.2 (2017-06-06)
|
||||||
|
@ -325,8 +325,8 @@ Version 3.5.1 (2017-03-12)
|
||||||
Twitter-bridge now supports quotes and long posts when importing tweets [annando]
|
Twitter-bridge now supports quotes and long posts when importing tweets [annando]
|
||||||
|
|
||||||
Closed Issues
|
Closed Issues
|
||||||
1019, 1163, 1612, 1613, 2103, 2177, 2252, 2260, 2403, 2991, 2614,
|
1019, 1163, 1612, 1613, 2103, 2177, 2252, 2260, 2403, 2991, 2614,
|
||||||
2751, 2752, 2772, 2791, 2800, 2804, 2813, 2814, 2816, 2817, 2823,
|
2751, 2752, 2772, 2791, 2800, 2804, 2813, 2814, 2816, 2817, 2823,
|
||||||
2850, 2858, 2865, 2892, 2894, 2895, 2907, 2908, 2914, 2015, 2926,
|
2850, 2858, 2865, 2892, 2894, 2895, 2907, 2908, 2914, 2015, 2926,
|
||||||
2948, 2955, 2958, 2963, 2964, 2968, 2987, 2993, 3020, 3052, 3062,
|
2948, 2955, 2958, 2963, 2964, 2968, 2987, 2993, 3020, 3052, 3062,
|
||||||
3066, 3091, 3108, 3113, 3116, 3117, 3118, 3126, 3130, 3135, 3155,
|
3066, 3091, 3108, 3113, 3116, 3117, 3118, 3126, 3130, 3135, 3155,
|
||||||
|
@ -430,7 +430,7 @@ Version 3.4.3 (2015-12-22)
|
||||||
Diaspora and OStatus can be enabled only if requirements are satisfied (annando)
|
Diaspora and OStatus can be enabled only if requirements are satisfied (annando)
|
||||||
Support for additional passwords for ejabberd (annando)
|
Support for additional passwords for ejabberd (annando)
|
||||||
Use proxy for profile photos (annando)
|
Use proxy for profile photos (annando)
|
||||||
'Reload active themes' in theme admin page (fabrixxm)
|
'Reload active themes' in theme admin page (fabrixxm)
|
||||||
Install routine checks for ImageMagick and GIF support (fabrixxm)
|
Install routine checks for ImageMagick and GIF support (fabrixxm)
|
||||||
Install routine checks for availability of "mcrypt_create_iv()" function, needed for RINO2 (fabrixxm)
|
Install routine checks for availability of "mcrypt_create_iv()" function, needed for RINO2 (fabrixxm)
|
||||||
Only suported themes are shown in admin page (annando)
|
Only suported themes are shown in admin page (annando)
|
||||||
|
@ -441,7 +441,7 @@ Version 3.4.3 (2015-12-22)
|
||||||
Show an info message if an empty contact group is shown (issue #1871) (annando)
|
Show an info message if an empty contact group is shown (issue #1871) (annando)
|
||||||
User setting to disable network page autoupdate (issue #1921) (annando)
|
User setting to disable network page autoupdate (issue #1921) (annando)
|
||||||
Settings to limit or permit access to crawler to search page (annando)
|
Settings to limit or permit access to crawler to search page (annando)
|
||||||
What's new for developers:
|
What's new for developers:
|
||||||
Themes can show Events entry in navbar (annando)
|
Themes can show Events entry in navbar (annando)
|
||||||
Themes can now override colorbox (fabrixxm)
|
Themes can now override colorbox (fabrixxm)
|
||||||
Updated Vagrant development VM (silke, hauke)
|
Updated Vagrant development VM (silke, hauke)
|
||||||
|
@ -469,7 +469,7 @@ Version 3.4.3 (2015-12-22)
|
||||||
Fix mention completition popup with TinyMCE (issue #1920) (fabrixxm)
|
Fix mention completition popup with TinyMCE (issue #1920) (fabrixxm)
|
||||||
Fix photo cache and proxy when installed in subfolder (ddorian1)
|
Fix photo cache and proxy when installed in subfolder (ddorian1)
|
||||||
Fix bbcode conversion of the about text for the profile (issue #1607) (annando)
|
Fix bbcode conversion of the about text for the profile (issue #1607) (annando)
|
||||||
|
|
||||||
|
|
||||||
Version 3.4.2 (2015-09-29)
|
Version 3.4.2 (2015-09-29)
|
||||||
|
|
||||||
|
@ -514,8 +514,8 @@ Version 3.4.2 (2015-09-29)
|
||||||
Checks for mcrypt availability before enable or use RINO2 (fabrixm)
|
Checks for mcrypt availability before enable or use RINO2 (fabrixm)
|
||||||
Fix following email contacts (issue #1896) (annando)
|
Fix following email contacts (issue #1896) (annando)
|
||||||
Parse BBCode in contact request notification email (annando)
|
Parse BBCode in contact request notification email (annando)
|
||||||
|
|
||||||
|
|
||||||
Version 3.4.1 (2015-07-06)
|
Version 3.4.1 (2015-07-06)
|
||||||
|
|
||||||
Implement server-to-server encryption (RINO) using php-encryption library as "RINO 2", deprecate "RINO 1" (issue #1655) (fabrixxm)
|
Implement server-to-server encryption (RINO) using php-encryption library as "RINO 2", deprecate "RINO 1" (issue #1655) (fabrixxm)
|
||||||
|
|
10
INSTALL.txt
10
INSTALL.txt
|
@ -68,7 +68,7 @@ OR
|
||||||
|
|
||||||
git clone https://github.com/friendica/friendica [web server folder]
|
git clone https://github.com/friendica/friendica [web server folder]
|
||||||
cd [web server folder]
|
cd [web server folder]
|
||||||
php util/composer.phar install
|
php bin/composer.phar install
|
||||||
|
|
||||||
3. Create an empty database and note the access details (hostname, username,
|
3. Create an empty database and note the access details (hostname, username,
|
||||||
password, database name).
|
password, database name).
|
||||||
|
@ -115,14 +115,14 @@ tables, so that you can start fresh.
|
||||||
8. Set up a cron job or scheduled task to run the worker once every 5-10
|
8. Set up a cron job or scheduled task to run the worker once every 5-10
|
||||||
minutes to pick up the recent "public" postings of your friends. Example:
|
minutes to pick up the recent "public" postings of your friends. Example:
|
||||||
|
|
||||||
cd /base/directory; /path/to/php scripts/worker.php
|
cd /base/directory; /path/to/php bin/worker.php
|
||||||
|
|
||||||
Change "/base/directory", and "/path/to/php" as appropriate for your situation.
|
Change "/base/directory", and "/path/to/php" as appropriate for your situation.
|
||||||
|
|
||||||
If you are using a Linux server, run "crontab -e" and add a line like the
|
If you are using a Linux server, run "crontab -e" and add a line like the
|
||||||
one shown, substituting for your unique paths and settings:
|
one shown, substituting for your unique paths and settings:
|
||||||
|
|
||||||
*/10 * * * * cd /home/myname/mywebsite; /usr/bin/php scripts/worker.php
|
*/10 * * * * cd /home/myname/mywebsite; /usr/bin/php bin/worker.php
|
||||||
|
|
||||||
You can generally find the location of PHP by executing "which php". If you
|
You can generally find the location of PHP by executing "which php". If you
|
||||||
have troubles with this section please contact your hosting provider for
|
have troubles with this section please contact your hosting provider for
|
||||||
|
@ -287,14 +287,14 @@ cron by using something like
|
||||||
|
|
||||||
*/10 * * * * cd /var/www/friendica/friendica/ && sudo -u www-data /usr/bin/php
|
*/10 * * * * cd /var/www/friendica/friendica/ && sudo -u www-data /usr/bin/php
|
||||||
-d suhosin.executor.func.blacklist=none -d suhosin.executor.eval.blacklist=none
|
-d suhosin.executor.func.blacklist=none -d suhosin.executor.eval.blacklist=none
|
||||||
-f scripts/worker.php
|
-f bin/worker.php
|
||||||
|
|
||||||
This worked well for simple test cases, but the friendica-cron still failed with
|
This worked well for simple test cases, but the friendica-cron still failed with
|
||||||
a fatal error:
|
a fatal error:
|
||||||
suhosin[22962]: ALERT - function within blacklist called: proc_open() (attacker
|
suhosin[22962]: ALERT - function within blacklist called: proc_open() (attacker
|
||||||
'REMOTE_ADDR not set', file '/var/www/friendica/friendica/boot.php', line 1341)
|
'REMOTE_ADDR not set', file '/var/www/friendica/friendica/boot.php', line 1341)
|
||||||
|
|
||||||
After a while I noticed, that scripts/worker.php calls further php script via
|
After a while I noticed, that bin/worker.php calls further php script via
|
||||||
proc_open. These scripts themselves also use proc_open and fail, because they
|
proc_open. These scripts themselves also use proc_open and fail, because they
|
||||||
are NOT called with -d suhosin.executor.func.blacklist=none.
|
are NOT called with -d suhosin.executor.func.blacklist=none.
|
||||||
|
|
||||||
|
|
|
@ -27,17 +27,18 @@ The location of the translated files in the source tree is
|
||||||
/view/lang/LNG-CODE/
|
/view/lang/LNG-CODE/
|
||||||
where LNG-CODE is the language code used, e.g. de for German or fr for French.
|
where LNG-CODE is the language code used, e.g. de for German or fr for French.
|
||||||
The translated strings come as a "message.po" file from transifex which needs to be translated into the PHP file friendica uses.
|
The translated strings come as a "message.po" file from transifex which needs to be translated into the PHP file friendica uses.
|
||||||
To do so, place the file in the directory mentioned above and use the "po2php" utility from the util directory of your friendica installation.
|
To do so, place the file in the directory mentioned above and use the "po2php" command from the console.
|
||||||
|
*Please note that the console tool has to be called from the base directory of your Friendica installation.*
|
||||||
|
|
||||||
Assuming you want to convert the German localization which is placed in view/lang/de/message.po you would do the following.
|
Assuming you want to convert the German localization which is placed in view/lang/de/message.po you would do the following.
|
||||||
|
|
||||||
1. Navigate at the command prompt to the base directory of your
|
1. Navigate at the command prompt to the base directory of your
|
||||||
friendica installation
|
friendica installation
|
||||||
|
|
||||||
2. Execute the po2php script, which will place the translation
|
2. Execute the po2php command, which will place the translation
|
||||||
in the strings.php file that is used by friendica.
|
in the strings.php file that is used by friendica.
|
||||||
|
|
||||||
$> php util/po2php.php view/lang/de/messages.po
|
$> php bin/console.php po2php view/lang/de/messages.po
|
||||||
|
|
||||||
The output of the script will be placed at view/lang/de/strings.php where
|
The output of the script will be placed at view/lang/de/strings.php where
|
||||||
friendica is expecting it, so you can test your translation immediately.
|
friendica is expecting it, so you can test your translation immediately.
|
||||||
|
@ -62,7 +63,7 @@ Otherwise your work might get lost, when the translation from Transifex is inclu
|
||||||
Utilities
|
Utilities
|
||||||
---------
|
---------
|
||||||
|
|
||||||
Additional to the po2php script there are some more utilities for translation in the "util" directory of the friendica source tree.
|
Additional to the po2php command there are some more utilities for translation in the console.
|
||||||
If you only want to translate friendica into another language you wont need any of these tools most likely but it gives you an idea how the translation process of friendica works.
|
If you only want to translate friendica into another language you wont need any of these tools most likely but it gives you an idea how the translation process of friendica works.
|
||||||
|
|
||||||
For further information see the utils/README file.
|
For further information see the utils/README file.
|
||||||
|
@ -90,9 +91,9 @@ To update the translation files after you have translated strings of e.g. Espera
|
||||||
|
|
||||||
$> tx pull -l eo
|
$> tx pull -l eo
|
||||||
|
|
||||||
And then use the `po2php` utility described above to convert the `messages.po` file to the `strings.php` file Friendica is loading.
|
And then use the `po2php` command described above to convert the `messages.po` file to the `strings.php` file Friendica is loading.
|
||||||
|
|
||||||
$> php util/po2php.php view/lang/eo/messages.po
|
$> php bin/console.php po2php view/lang/eo/messages.po
|
||||||
|
|
||||||
Afterwards, just commit the two changed files to a feature branch of your Friendica repository, push the changes to github and open a pull request for your changes.
|
Afterwards, just commit the two changed files to a feature branch of your Friendica repository, push the changes to github and open a pull request for your changes.
|
||||||
|
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
3.6
|
2018-05-dev
|
||||||
|
|
4
Vagrantfile
vendored
4
Vagrantfile
vendored
|
@ -17,7 +17,7 @@ Vagrant.configure(2) do |config|
|
||||||
# Create a hostname, don't forget to put it to the `hosts` file
|
# Create a hostname, don't forget to put it to the `hosts` file
|
||||||
# This will point to the server's default virtual host
|
# This will point to the server's default virtual host
|
||||||
# TO DO: Make this work with virtualhost along-side xip.io URL
|
# TO DO: Make this work with virtualhost along-side xip.io URL
|
||||||
config.vm.hostname = "friendica.dev"
|
config.vm.hostname = "friendica.local"
|
||||||
|
|
||||||
# Create a static IP
|
# Create a static IP
|
||||||
config.vm.network :private_network, ip: server_ip
|
config.vm.network :private_network, ip: server_ip
|
||||||
|
@ -36,7 +36,7 @@ Vagrant.configure(2) do |config|
|
||||||
vb.memory = server_memory
|
vb.memory = server_memory
|
||||||
end
|
end
|
||||||
|
|
||||||
# Enable provisioning with a shell script.
|
# Enable provisioning with a shell script.
|
||||||
config.vm.provision "shell", path: "./util/vagrant_provision.sh"
|
config.vm.provision "shell", path: "./util/vagrant_provision.sh"
|
||||||
# run: "always"
|
# run: "always"
|
||||||
# run: "once"
|
# run: "once"
|
||||||
|
|
|
@ -13,14 +13,14 @@
|
||||||
* Installation:
|
* Installation:
|
||||||
*
|
*
|
||||||
* - Change it's owner to whichever user is running the server, ie. ejabberd
|
* - Change it's owner to whichever user is running the server, ie. ejabberd
|
||||||
* $ chown ejabberd:ejabberd /path/to/friendica/scripts/auth_ejabberd.php
|
* $ chown ejabberd:ejabberd /path/to/friendica/bin/auth_ejabberd.php
|
||||||
*
|
*
|
||||||
* - Change the access mode so it is readable only to the user ejabberd and has exec
|
* - Change the access mode so it is readable only to the user ejabberd and has exec
|
||||||
* $ chmod 700 /path/to/friendica/scripts/auth_ejabberd.php
|
* $ chmod 700 /path/to/friendica/bin/auth_ejabberd.php
|
||||||
*
|
*
|
||||||
* - Edit your ejabberd.cfg file, comment out your auth_method and add:
|
* - Edit your ejabberd.cfg file, comment out your auth_method and add:
|
||||||
* {auth_method, external}.
|
* {auth_method, external}.
|
||||||
* {extauth_program, "/path/to/friendica/script/auth_ejabberd.php"}.
|
* {extauth_program, "/path/to/friendica/bin/auth_ejabberd.php"}.
|
||||||
*
|
*
|
||||||
* - Restart your ejabberd service, you should be able to login with your friendica auth info
|
* - Restart your ejabberd service, you should be able to login with your friendica auth info
|
||||||
*
|
*
|
||||||
|
@ -33,6 +33,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
|
use Friendica\BaseObject;
|
||||||
|
use Friendica\Core\Config;
|
||||||
use Friendica\Util\ExAuth;
|
use Friendica\Util\ExAuth;
|
||||||
|
|
||||||
if (sizeof($_SERVER["argv"]) == 0) {
|
if (sizeof($_SERVER["argv"]) == 0) {
|
||||||
|
@ -53,6 +55,7 @@ require_once "boot.php";
|
||||||
require_once "include/dba.php";
|
require_once "include/dba.php";
|
||||||
|
|
||||||
$a = new App(dirname(__DIR__));
|
$a = new App(dirname(__DIR__));
|
||||||
|
BaseObject::setApp($a);
|
||||||
|
|
||||||
@include ".htconfig.php";
|
@include ".htconfig.php";
|
||||||
dba::connect($db_host, $db_user, $db_pass, $db_data);
|
dba::connect($db_host, $db_user, $db_pass, $db_data);
|
10
bin/console
Executable file
10
bin/console
Executable file
|
@ -0,0 +1,10 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
dir=$(cd "${0%[/\\]*}" > /dev/null; pwd)
|
||||||
|
|
||||||
|
if [[ -d /proc/cygdrive && $(which php) == $(readlink -n /proc/cygdrive)/* ]]; then
|
||||||
|
# We are in Cgywin using Windows php, so the path must be translated
|
||||||
|
dir=$(cygpath -m "$dir");
|
||||||
|
fi
|
||||||
|
|
||||||
|
php "${dir}/console.php" "$@"
|
4
bin/console.bat
Executable file
4
bin/console.bat
Executable file
|
@ -0,0 +1,4 @@
|
||||||
|
@echo OFF
|
||||||
|
:: in case DelayedExpansion is on and a path contains !
|
||||||
|
setlocal DISABLEDELAYEDEXPANSION
|
||||||
|
php "%~dp0console.php" %*
|
9
bin/console.php
Executable file
9
bin/console.php
Executable file
|
@ -0,0 +1,9 @@
|
||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
include_once dirname(__DIR__) . '/boot.php';
|
||||||
|
|
||||||
|
$a = new Friendica\App(dirname(__DIR__));
|
||||||
|
\Friendica\BaseObject::setApp($a);
|
||||||
|
|
||||||
|
(new Friendica\Core\Console($argv))->execute();
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env php
|
#!/usr/bin/env php
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @file scripts/daemon.php
|
* @file bin/daemon.php
|
||||||
* @brief Run the worker from a daemon.
|
* @brief Run the worker from a daemon.
|
||||||
*
|
*
|
||||||
* This script was taken from http://php.net/manual/en/function.pcntl-fork.php
|
* This script was taken from http://php.net/manual/en/function.pcntl-fork.php
|
||||||
|
@ -104,7 +104,7 @@ while (true) {
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
// Call the worker
|
// Call the worker
|
||||||
$cmdline = $php.' scripts/worker.php';
|
$cmdline = $php.' bin/worker.php';
|
||||||
|
|
||||||
$executed = false;
|
$executed = false;
|
||||||
|
|
|
@ -45,7 +45,7 @@ case "$MODE" in
|
||||||
;;
|
;;
|
||||||
'default')
|
'default')
|
||||||
cd "$FULLPATH/.."
|
cd "$FULLPATH/.."
|
||||||
OUTFILE="$FULLPATH/messages.po"
|
OUTFILE="$FULLPATH/../util/messages.po"
|
||||||
FINDSTARTDIR="."
|
FINDSTARTDIR="."
|
||||||
# skip addon folder
|
# skip addon folder
|
||||||
FINDOPTS="( -wholename */addon -or -wholename */addons-extra -or -wholename */smarty3 ) -prune -o"
|
FINDOPTS="( -wholename */addon -or -wholename */addons-extra -or -wholename */smarty3 ) -prune -o"
|
|
@ -1,11 +1,12 @@
|
||||||
#!/usr/bin/env php
|
#!/usr/bin/env php
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @file scripts/worker.php
|
* @file bin/worker.php
|
||||||
* @brief Starts the background processing
|
* @brief Starts the background processing
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
|
use Friendica\BaseObject;
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
|
@ -26,6 +27,7 @@ require_once "boot.php";
|
||||||
require_once "include/dba.php";
|
require_once "include/dba.php";
|
||||||
|
|
||||||
$a = new App(dirname(__DIR__));
|
$a = new App(dirname(__DIR__));
|
||||||
|
BaseObject::setApp($a);
|
||||||
|
|
||||||
require_once ".htconfig.php";
|
require_once ".htconfig.php";
|
||||||
dba::connect($db_host, $db_user, $db_pass, $db_data);
|
dba::connect($db_host, $db_user, $db_pass, $db_data);
|
27
boot.php
27
boot.php
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @file_tag_unsave_file boot.php
|
* @file boot.php
|
||||||
* This file defines some global constants and includes the central App class.
|
* This file defines some global constants and includes the central App class.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -20,7 +20,9 @@
|
||||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
|
require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
|
use Friendica\BaseObject;
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
|
use Friendica\Core\Cache;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
|
@ -37,9 +39,9 @@ require_once 'include/text.php';
|
||||||
|
|
||||||
define('FRIENDICA_PLATFORM', 'Friendica');
|
define('FRIENDICA_PLATFORM', 'Friendica');
|
||||||
define('FRIENDICA_CODENAME', 'The Tazmans Flax-lily');
|
define('FRIENDICA_CODENAME', 'The Tazmans Flax-lily');
|
||||||
define('FRIENDICA_VERSION', '3.6');
|
define('FRIENDICA_VERSION', '2018-05-dev');
|
||||||
define('DFRN_PROTOCOL_VERSION', '2.23');
|
define('DFRN_PROTOCOL_VERSION', '2.23');
|
||||||
define('DB_UPDATE_VERSION', 1256);
|
define('DB_UPDATE_VERSION', 1259);
|
||||||
define('NEW_UPDATE_ROUTINE_VERSION', 1170);
|
define('NEW_UPDATE_ROUTINE_VERSION', 1170);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -121,18 +123,20 @@ define('LOGGER_ALL', 4);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Cache
|
* @name Cache
|
||||||
|
* @deprecated since version 3.6
|
||||||
|
* @see Cache
|
||||||
*
|
*
|
||||||
* Cache levels
|
* Cache levels
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
define('CACHE_MONTH', 0);
|
define('CACHE_MONTH', Cache::MONTH);
|
||||||
define('CACHE_WEEK', 1);
|
define('CACHE_WEEK', Cache::WEEK);
|
||||||
define('CACHE_DAY', 2);
|
define('CACHE_DAY', Cache::DAY);
|
||||||
define('CACHE_HOUR', 3);
|
define('CACHE_HOUR', Cache::HOUR);
|
||||||
define('CACHE_HALF_HOUR', 4);
|
define('CACHE_HALF_HOUR', Cache::HALF_HOUR);
|
||||||
define('CACHE_QUARTER_HOUR', 5);
|
define('CACHE_QUARTER_HOUR', Cache::QUARTER_HOUR);
|
||||||
define('CACHE_FIVE_MINUTES', 6);
|
define('CACHE_FIVE_MINUTES', Cache::FIVE_MINUTES);
|
||||||
define('CACHE_MINUTE', 7);
|
define('CACHE_MINUTE', Cache::MINUTE);
|
||||||
/* @}*/
|
/* @}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -533,6 +537,7 @@ function get_app()
|
||||||
|
|
||||||
if (empty($a)) {
|
if (empty($a)) {
|
||||||
$a = new App(dirname(__DIR__));
|
$a = new App(dirname(__DIR__));
|
||||||
|
BaseObject::setApp($a);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $a;
|
return $a;
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">5.6",
|
"php": ">5.6",
|
||||||
"ext-xml": "*",
|
"ext-xml": "*",
|
||||||
|
"asika/simple-console": "^1.0",
|
||||||
|
"divineomega/password_exposed": "^2.4",
|
||||||
"ezyang/htmlpurifier": "~4.7.0",
|
"ezyang/htmlpurifier": "~4.7.0",
|
||||||
"league/html-to-markdown": "~4.4.1",
|
"league/html-to-markdown": "~4.4.1",
|
||||||
"lightopenid/lightopenid": "dev-master",
|
"lightopenid/lightopenid": "dev-master",
|
||||||
|
@ -32,14 +34,15 @@
|
||||||
"npm-asset/jquery-colorbox": "^1.6",
|
"npm-asset/jquery-colorbox": "^1.6",
|
||||||
"npm-asset/jquery-datetimepicker": "^2.4.0",
|
"npm-asset/jquery-datetimepicker": "^2.4.0",
|
||||||
"npm-asset/jgrowl": "^1.4",
|
"npm-asset/jgrowl": "^1.4",
|
||||||
"npm-asset/fullcalendar": "^3.0.1"
|
"npm-asset/fullcalendar": "^3.0.1",
|
||||||
|
"npm-asset/cropperjs": "1.2.2"
|
||||||
},
|
},
|
||||||
"repositories": [
|
"repositories": [
|
||||||
{
|
{
|
||||||
"type": "vcs",
|
"type": "vcs",
|
||||||
"url": "https://github.com/pear/Text_Highlighter"
|
"url": "https://github.com/pear/Text_Highlighter"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Friendica\\": "src/"
|
"Friendica\\": "src/"
|
||||||
|
@ -53,11 +56,11 @@
|
||||||
"optimize-autoloader": true,
|
"optimize-autoloader": true,
|
||||||
"preferred-install": "dist",
|
"preferred-install": "dist",
|
||||||
"fxp-asset": {
|
"fxp-asset": {
|
||||||
"installer-paths": {
|
"installer-paths": {
|
||||||
"npm-asset-library": "vendor/asset",
|
"npm-asset-library": "view/asset",
|
||||||
"bower-asset-library": "vendor/asset"
|
"bower-asset-library": "view/asset"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"archive": {
|
"archive": {
|
||||||
"exclude": [
|
"exclude": [
|
||||||
|
|
747
composer.lock
generated
747
composer.lock
generated
|
@ -4,8 +4,41 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "3ff4187b4f7167583a3b8caa5f7c2a8a",
|
"content-hash": "12b8df66213734281765cb6e2c5a786e",
|
||||||
"packages": [
|
"packages": [
|
||||||
|
{
|
||||||
|
"name": "asika/simple-console",
|
||||||
|
"version": "1.0.3",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/asika32764/php-simple-console.git",
|
||||||
|
"reference": "0b624c1a999849dc6481a47182e58d593bf65068"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/asika32764/php-simple-console/zipball/0b624c1a999849dc6481a47182e58d593bf65068",
|
||||||
|
"reference": "0b624c1a999849dc6481a47182e58d593bf65068",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Asika\\SimpleConsole\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Simon Asika",
|
||||||
|
"email": "asika32764@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "One file console framework to help you write build scripts.",
|
||||||
|
"time": "2018-03-08T12:05:40+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "bower-asset/Chart-js",
|
"name": "bower-asset/Chart-js",
|
||||||
"version": "v2.7.1",
|
"version": "v2.7.1",
|
||||||
|
@ -100,6 +133,54 @@
|
||||||
"description": "Minimalistic but perfect custom scrollbar plugin",
|
"description": "Minimalistic but perfect custom scrollbar plugin",
|
||||||
"time": "2017-01-10T01:04:09+00:00"
|
"time": "2017-01-10T01:04:09+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "divineomega/password_exposed",
|
||||||
|
"version": "v2.5.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/DivineOmega/password_exposed.git",
|
||||||
|
"reference": "c928bf722eb02398df11076add60df070cb55581"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/DivineOmega/password_exposed/zipball/c928bf722eb02398df11076add60df070cb55581",
|
||||||
|
"reference": "c928bf722eb02398df11076add60df070cb55581",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"guzzlehttp/guzzle": "^6.3",
|
||||||
|
"paragonie/certainty": "^1",
|
||||||
|
"php": ">=5.6",
|
||||||
|
"rapidwebltd/rw-file-cache-psr-6": "^1.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"fzaninotto/faker": "^1.7",
|
||||||
|
"phpunit/phpunit": "^5.7",
|
||||||
|
"satooshi/php-coveralls": "^2.0",
|
||||||
|
"vimeo/psalm": "^1"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"DivineOmega\\PasswordExposed\\": "src/"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"src/PasswordExposedFunction.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"LGPL-3.0-only"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Jordan Hall",
|
||||||
|
"email": "jordan@hall05.co.uk"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "This PHP package provides a `password_exposed` helper function, that uses the haveibeenpwned.com API to check if a password has been exposed in a data breach.",
|
||||||
|
"time": "2018-04-02T18:16:36+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "ezyang/htmlpurifier",
|
"name": "ezyang/htmlpurifier",
|
||||||
"version": "v4.7.0",
|
"version": "v4.7.0",
|
||||||
|
@ -203,6 +284,187 @@
|
||||||
],
|
],
|
||||||
"time": "2017-10-20T06:53:56+00:00"
|
"time": "2017-10-20T06:53:56+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "guzzlehttp/guzzle",
|
||||||
|
"version": "6.3.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/guzzle/guzzle.git",
|
||||||
|
"reference": "f4db5a78a5ea468d4831de7f0bf9d9415e348699"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/f4db5a78a5ea468d4831de7f0bf9d9415e348699",
|
||||||
|
"reference": "f4db5a78a5ea468d4831de7f0bf9d9415e348699",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"guzzlehttp/promises": "^1.0",
|
||||||
|
"guzzlehttp/psr7": "^1.4",
|
||||||
|
"php": ">=5.5"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"ext-curl": "*",
|
||||||
|
"phpunit/phpunit": "^4.0 || ^5.0",
|
||||||
|
"psr/log": "^1.0"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"psr/log": "Required for using the Log middleware"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "6.2-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"src/functions_include.php"
|
||||||
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"GuzzleHttp\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Michael Dowling",
|
||||||
|
"email": "mtdowling@gmail.com",
|
||||||
|
"homepage": "https://github.com/mtdowling"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Guzzle is a PHP HTTP client library",
|
||||||
|
"homepage": "http://guzzlephp.org/",
|
||||||
|
"keywords": [
|
||||||
|
"client",
|
||||||
|
"curl",
|
||||||
|
"framework",
|
||||||
|
"http",
|
||||||
|
"http client",
|
||||||
|
"rest",
|
||||||
|
"web service"
|
||||||
|
],
|
||||||
|
"time": "2017-06-22T18:50:49+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "guzzlehttp/promises",
|
||||||
|
"version": "v1.3.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/guzzle/promises.git",
|
||||||
|
"reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646",
|
||||||
|
"reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.5.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "^4.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "1.4-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"GuzzleHttp\\Promise\\": "src/"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"src/functions_include.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Michael Dowling",
|
||||||
|
"email": "mtdowling@gmail.com",
|
||||||
|
"homepage": "https://github.com/mtdowling"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Guzzle promises library",
|
||||||
|
"keywords": [
|
||||||
|
"promise"
|
||||||
|
],
|
||||||
|
"time": "2016-12-20T10:07:11+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "guzzlehttp/psr7",
|
||||||
|
"version": "1.4.2",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/guzzle/psr7.git",
|
||||||
|
"reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
|
||||||
|
"reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.4.0",
|
||||||
|
"psr/http-message": "~1.0"
|
||||||
|
},
|
||||||
|
"provide": {
|
||||||
|
"psr/http-message-implementation": "1.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "~4.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "1.4-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"GuzzleHttp\\Psr7\\": "src/"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"src/functions_include.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Michael Dowling",
|
||||||
|
"email": "mtdowling@gmail.com",
|
||||||
|
"homepage": "https://github.com/mtdowling"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Tobias Schultze",
|
||||||
|
"homepage": "https://github.com/Tobion"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "PSR-7 message implementation that also provides common utility methods",
|
||||||
|
"keywords": [
|
||||||
|
"http",
|
||||||
|
"message",
|
||||||
|
"request",
|
||||||
|
"response",
|
||||||
|
"stream",
|
||||||
|
"uri",
|
||||||
|
"url"
|
||||||
|
],
|
||||||
|
"time": "2017-03-20T17:10:46+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "league/html-to-markdown",
|
"name": "league/html-to-markdown",
|
||||||
"version": "4.4.1",
|
"version": "4.4.1",
|
||||||
|
@ -398,6 +660,100 @@
|
||||||
],
|
],
|
||||||
"time": "2017-12-18T10:38:51+00:00"
|
"time": "2017-12-18T10:38:51+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "npm-asset/cropperjs",
|
||||||
|
"version": "1.2.2",
|
||||||
|
"dist": {
|
||||||
|
"type": "tar",
|
||||||
|
"url": "https://registry.npmjs.org/cropperjs/-/cropperjs-1.2.2.tgz",
|
||||||
|
"reference": null,
|
||||||
|
"shasum": "30dc7a7ce872155b23a33bd10ad4c76c0d613f55"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"npm-asset/babel-core": ">=6.26.0,<7.0.0",
|
||||||
|
"npm-asset/babel-plugin-external-helpers": ">=6.22.0,<7.0.0",
|
||||||
|
"npm-asset/babel-preset-env": ">=1.6.1,<2.0.0",
|
||||||
|
"npm-asset/cpy-cli": ">=1.0.1,<2.0.0",
|
||||||
|
"npm-asset/cssnano": ">=3.10.0,<4.0.0",
|
||||||
|
"npm-asset/del-cli": ">=1.1.0,<2.0.0",
|
||||||
|
"npm-asset/eslint": ">=4.14.0,<5.0.0",
|
||||||
|
"npm-asset/eslint-config-airbnb-base": ">=12.1.0,<13.0.0",
|
||||||
|
"npm-asset/eslint-plugin-import": ">=2.8.0,<3.0.0",
|
||||||
|
"npm-asset/node-qunit-phantomjs": ">=2.0.0,<3.0.0",
|
||||||
|
"npm-asset/npm-run-all": ">=4.1.2,<5.0.0",
|
||||||
|
"npm-asset/postcss-cli": ">=4.1.1,<5.0.0",
|
||||||
|
"npm-asset/postcss-cssnext": ">=3.0.2,<4.0.0",
|
||||||
|
"npm-asset/postcss-header": ">=1.0.0,<2.0.0",
|
||||||
|
"npm-asset/postcss-url": ">=7.3.0,<8.0.0",
|
||||||
|
"npm-asset/rollup": ">=0.53.3,<0.54.0",
|
||||||
|
"npm-asset/rollup-plugin-babel": ">=3.0.3,<4.0.0",
|
||||||
|
"npm-asset/rollup-watch": ">=4.3.1,<5.0.0",
|
||||||
|
"npm-asset/stylefmt": ">=6.0.0,<7.0.0",
|
||||||
|
"npm-asset/uglify-js": ">=3.3.4,<4.0.0"
|
||||||
|
},
|
||||||
|
"type": "npm-asset-library",
|
||||||
|
"extra": {
|
||||||
|
"npm-asset-bugs": {
|
||||||
|
"url": "https://github.com/fengyuanchen/cropperjs/issues"
|
||||||
|
},
|
||||||
|
"npm-asset-files": [
|
||||||
|
"src",
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"npm-asset-main": "dist/cropper.common.js",
|
||||||
|
"npm-asset-directories": [],
|
||||||
|
"npm-asset-repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/fengyuanchen/cropperjs.git"
|
||||||
|
},
|
||||||
|
"npm-asset-scripts": {
|
||||||
|
"build": "npm run build:css && npm run build:js",
|
||||||
|
"build:css": "postcss src/css/cropper.css -o dist/cropper.css --no-map",
|
||||||
|
"build:js": "rollup -c",
|
||||||
|
"clear": "del-cli dist",
|
||||||
|
"compress": "npm run compress:css && npm run compress:js",
|
||||||
|
"compress:css": "postcss dist/cropper.css -u cssnano -o dist/cropper.min.css --no-map",
|
||||||
|
"compress:js": "uglifyjs dist/cropper.js -o dist/cropper.min.js -c -m --comments /^!/",
|
||||||
|
"copy": "cpy dist/cropper.css docs/css",
|
||||||
|
"lint": "eslint src/js --fix",
|
||||||
|
"release": "npm run clear && npm run lint && npm run build && npm run compress && npm run copy && npm test",
|
||||||
|
"start": "npm-run-all --parallel watch:*",
|
||||||
|
"test": "node-qunit-phantomjs test/index.html --timeout 10",
|
||||||
|
"watch:css": "postcss src/css/cropper.css -o docs/css/cropper.css -m -w",
|
||||||
|
"watch:js": "rollup -c -m -w"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Chen Fengyuan",
|
||||||
|
"url": "http://chenfengyuan.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "JavaScript image cropper.",
|
||||||
|
"homepage": "https://fengyuanchen.github.io/cropperjs",
|
||||||
|
"keywords": [
|
||||||
|
"crop",
|
||||||
|
"cropper",
|
||||||
|
"cropper.js",
|
||||||
|
"cropperjs",
|
||||||
|
"cropping",
|
||||||
|
"css",
|
||||||
|
"development",
|
||||||
|
"front-end",
|
||||||
|
"html",
|
||||||
|
"image",
|
||||||
|
"javascript",
|
||||||
|
"move",
|
||||||
|
"rotate",
|
||||||
|
"scale",
|
||||||
|
"web",
|
||||||
|
"zoom"
|
||||||
|
],
|
||||||
|
"time": "2018-01-03T13:39:39+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "npm-asset/fullcalendar",
|
"name": "npm-asset/fullcalendar",
|
||||||
"version": "3.8.2",
|
"version": "3.8.2",
|
||||||
|
@ -937,6 +1293,129 @@
|
||||||
"homepage": "https://github.com/kartik-v/php-date-formatter",
|
"homepage": "https://github.com/kartik-v/php-date-formatter",
|
||||||
"time": "2016-02-18T15:15:55+00:00"
|
"time": "2016-02-18T15:15:55+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "paragonie/certainty",
|
||||||
|
"version": "v1.0.2",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/paragonie/certainty.git",
|
||||||
|
"reference": "a2d14f5b0b85c58329dee248d77d34e7e1202a32"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/paragonie/certainty/zipball/a2d14f5b0b85c58329dee248d77d34e7e1202a32",
|
||||||
|
"reference": "a2d14f5b0b85c58329dee248d77d34e7e1202a32",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"guzzlehttp/guzzle": "^6",
|
||||||
|
"paragonie/constant_time_encoding": "^1|^2",
|
||||||
|
"paragonie/sodium_compat": "^1.6",
|
||||||
|
"php": "^5.6|^7"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "^5|^6",
|
||||||
|
"vimeo/psalm": "^1"
|
||||||
|
},
|
||||||
|
"bin": [
|
||||||
|
"bin/certainty-cert-symlink"
|
||||||
|
],
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"ParagonIE\\Certainty\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"ISC"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Paragon Initiative Enterprises",
|
||||||
|
"email": "security@paragonie.com",
|
||||||
|
"homepage": "https://paragonie.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Up-to-date, verifiable repository for Certificate Authorities",
|
||||||
|
"keywords": [
|
||||||
|
"CA-Cert",
|
||||||
|
"Ed25519",
|
||||||
|
"Public-Key Infractructure",
|
||||||
|
"ca",
|
||||||
|
"ca-cert.pem",
|
||||||
|
"cacert",
|
||||||
|
"cacert.pem",
|
||||||
|
"certificate authority",
|
||||||
|
"pki",
|
||||||
|
"ssl",
|
||||||
|
"tls"
|
||||||
|
],
|
||||||
|
"time": "2018-03-12T18:34:23+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "paragonie/constant_time_encoding",
|
||||||
|
"version": "v1.0.2",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/paragonie/constant_time_encoding.git",
|
||||||
|
"reference": "6111a38faf6fdebc14e36652d22036f379ba58d3"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/6111a38faf6fdebc14e36652d22036f379ba58d3",
|
||||||
|
"reference": "6111a38faf6fdebc14e36652d22036f379ba58d3",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^5.3|^7"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"paragonie/random_compat": "^1|^2",
|
||||||
|
"phpunit/phpunit": "4.*|5.*",
|
||||||
|
"vimeo/psalm": "^1"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"ParagonIE\\ConstantTime\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Paragon Initiative Enterprises",
|
||||||
|
"email": "security@paragonie.com",
|
||||||
|
"homepage": "https://paragonie.com",
|
||||||
|
"role": "Maintainer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Steve 'Sc00bz' Thomas",
|
||||||
|
"email": "steve@tobtu.com",
|
||||||
|
"homepage": "https://www.tobtu.com",
|
||||||
|
"role": "Original Developer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-32, Base-16)",
|
||||||
|
"keywords": [
|
||||||
|
"base16",
|
||||||
|
"base32",
|
||||||
|
"base32_decode",
|
||||||
|
"base32_encode",
|
||||||
|
"base64",
|
||||||
|
"base64_decode",
|
||||||
|
"base64_encode",
|
||||||
|
"bin2hex",
|
||||||
|
"encoding",
|
||||||
|
"hex",
|
||||||
|
"hex2bin",
|
||||||
|
"rfc4648"
|
||||||
|
],
|
||||||
|
"time": "2018-03-10T19:46:06+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "paragonie/random_compat",
|
"name": "paragonie/random_compat",
|
||||||
"version": "v2.0.11",
|
"version": "v2.0.11",
|
||||||
|
@ -985,6 +1464,88 @@
|
||||||
],
|
],
|
||||||
"time": "2017-09-27T21:40:39+00:00"
|
"time": "2017-09-27T21:40:39+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "paragonie/sodium_compat",
|
||||||
|
"version": "v1.6.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/paragonie/sodium_compat.git",
|
||||||
|
"reference": "1f6e5682eff4a5a6a394b14331a1904f1740e432"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/paragonie/sodium_compat/zipball/1f6e5682eff4a5a6a394b14331a1904f1740e432",
|
||||||
|
"reference": "1f6e5682eff4a5a6a394b14331a1904f1740e432",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"paragonie/random_compat": "^1|^2",
|
||||||
|
"php": "^5.2.4|^5.3|^5.4|^5.5|^5.6|^7"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "^3|^4|^5"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-libsodium": "PHP < 7.0: Better performance, password hashing (Argon2i), secure memory management (memzero), and better security.",
|
||||||
|
"ext-sodium": "PHP >= 7.0: Better performance, password hashing (Argon2i), secure memory management (memzero), and better security."
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"autoload.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"ISC"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Paragon Initiative Enterprises",
|
||||||
|
"email": "security@paragonie.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Frank Denis",
|
||||||
|
"email": "jedisct1@pureftpd.org"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Pure PHP implementation of libsodium; uses the PHP extension if it exists",
|
||||||
|
"keywords": [
|
||||||
|
"Authentication",
|
||||||
|
"BLAKE2b",
|
||||||
|
"ChaCha20",
|
||||||
|
"ChaCha20-Poly1305",
|
||||||
|
"Chapoly",
|
||||||
|
"Curve25519",
|
||||||
|
"Ed25519",
|
||||||
|
"EdDSA",
|
||||||
|
"Edwards-curve Digital Signature Algorithm",
|
||||||
|
"Elliptic Curve Diffie-Hellman",
|
||||||
|
"Poly1305",
|
||||||
|
"Pure-PHP cryptography",
|
||||||
|
"RFC 7748",
|
||||||
|
"RFC 8032",
|
||||||
|
"Salpoly",
|
||||||
|
"Salsa20",
|
||||||
|
"X25519",
|
||||||
|
"XChaCha20-Poly1305",
|
||||||
|
"XSalsa20-Poly1305",
|
||||||
|
"Xchacha20",
|
||||||
|
"Xsalsa20",
|
||||||
|
"aead",
|
||||||
|
"cryptography",
|
||||||
|
"ecdh",
|
||||||
|
"elliptic curve",
|
||||||
|
"elliptic curve cryptography",
|
||||||
|
"encryption",
|
||||||
|
"libsodium",
|
||||||
|
"php",
|
||||||
|
"public-key cryptography",
|
||||||
|
"secret-key cryptography",
|
||||||
|
"side-channel resistant"
|
||||||
|
],
|
||||||
|
"time": "2018-02-15T05:50:20+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "pear/console_getopt",
|
"name": "pear/console_getopt",
|
||||||
"version": "v1.4.1",
|
"version": "v1.4.1",
|
||||||
|
@ -1227,6 +1788,190 @@
|
||||||
"homepage": "http://pear.php.net/package/Text_LanguageDetect",
|
"homepage": "http://pear.php.net/package/Text_LanguageDetect",
|
||||||
"time": "2017-03-02T16:14:08+00:00"
|
"time": "2017-03-02T16:14:08+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "psr/cache",
|
||||||
|
"version": "1.0.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/php-fig/cache.git",
|
||||||
|
"reference": "d11b50ad223250cf17b86e38383413f5a6764bf8"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8",
|
||||||
|
"reference": "d11b50ad223250cf17b86e38383413f5a6764bf8",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "1.0.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Psr\\Cache\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "PHP-FIG",
|
||||||
|
"homepage": "http://www.php-fig.org/"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Common interface for caching libraries",
|
||||||
|
"keywords": [
|
||||||
|
"cache",
|
||||||
|
"psr",
|
||||||
|
"psr-6"
|
||||||
|
],
|
||||||
|
"time": "2016-08-06T20:24:11+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "psr/http-message",
|
||||||
|
"version": "1.0.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/php-fig/http-message.git",
|
||||||
|
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
|
||||||
|
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "1.0.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Psr\\Http\\Message\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "PHP-FIG",
|
||||||
|
"homepage": "http://www.php-fig.org/"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Common interface for HTTP messages",
|
||||||
|
"homepage": "https://github.com/php-fig/http-message",
|
||||||
|
"keywords": [
|
||||||
|
"http",
|
||||||
|
"http-message",
|
||||||
|
"psr",
|
||||||
|
"psr-7",
|
||||||
|
"request",
|
||||||
|
"response"
|
||||||
|
],
|
||||||
|
"time": "2016-08-06T14:39:51+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "rapidwebltd/rw-file-cache",
|
||||||
|
"version": "v1.2.5",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/rapidwebltd/RW-File-Cache.git",
|
||||||
|
"reference": "4a1d5aaefa6ffafec8e2d60787f12bcd9890977e"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/rapidwebltd/RW-File-Cache/zipball/4a1d5aaefa6ffafec8e2d60787f12bcd9890977e",
|
||||||
|
"reference": "4a1d5aaefa6ffafec8e2d60787f12bcd9890977e",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.2.1"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "^5.7"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "1.0-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"rapidweb\\RWFileCache\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"LGPL-3.0-only"
|
||||||
|
],
|
||||||
|
"description": "RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.",
|
||||||
|
"homepage": "https://github.com/rapidwebltd/RW-File-Cache",
|
||||||
|
"keywords": [
|
||||||
|
"cache",
|
||||||
|
"caching",
|
||||||
|
"caching library",
|
||||||
|
"file cache",
|
||||||
|
"library",
|
||||||
|
"php"
|
||||||
|
],
|
||||||
|
"time": "2018-01-23T17:20:58+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "rapidwebltd/rw-file-cache-psr-6",
|
||||||
|
"version": "v1.0.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/rapidwebltd/RW-File-Cache-PSR-6.git",
|
||||||
|
"reference": "b74ea201d4c964f0e6db0fb036d1ab28a570df66"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/rapidwebltd/RW-File-Cache-PSR-6/zipball/b74ea201d4c964f0e6db0fb036d1ab28a570df66",
|
||||||
|
"reference": "b74ea201d4c964f0e6db0fb036d1ab28a570df66",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"psr/cache": "^1.0",
|
||||||
|
"rapidwebltd/rw-file-cache": "^1.2.3"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"cache/integration-tests": "^0.16.0",
|
||||||
|
"phpunit/phpunit": "^5.7"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"rapidweb\\RWFileCachePSR6\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"LGPL-3.0-only"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Jordan Hall",
|
||||||
|
"email": "jordan.hall@rapidweb.biz"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "PSR-6 adapter for RW File Cache",
|
||||||
|
"time": "2018-01-30T19:13:45+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "smarty/smarty",
|
"name": "smarty/smarty",
|
||||||
"version": "v3.1.31",
|
"version": "v3.1.31",
|
||||||
|
|
33
database.sql
33
database.sql
|
@ -1,6 +1,6 @@
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
-- Friendica 3.6-rc (Asparagus)
|
-- Friendica 2018-05-dev (The Tazmans Flax-lily)
|
||||||
-- DB_UPDATE_VERSION 1256
|
-- DB_UPDATE_VERSION 1259
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,12 +55,12 @@ CREATE TABLE IF NOT EXISTS `auth_codes` (
|
||||||
-- TABLE cache
|
-- TABLE cache
|
||||||
--
|
--
|
||||||
CREATE TABLE IF NOT EXISTS `cache` (
|
CREATE TABLE IF NOT EXISTS `cache` (
|
||||||
`k` varbinary(255) NOT NULL COMMENT '',
|
`k` varbinary(255) NOT NULL COMMENT 'cache key',
|
||||||
`v` mediumtext COMMENT '',
|
`v` mediumtext COMMENT 'cached serialized value',
|
||||||
`expire_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
|
`expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
|
||||||
`updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
|
`updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
|
||||||
PRIMARY KEY(`k`),
|
PRIMARY KEY(`k`),
|
||||||
INDEX `expire_mode_updated` (`expire_mode`,`updated`)
|
INDEX `k_expires` (`k`,`expires`)
|
||||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||||
|
|
||||||
--
|
--
|
||||||
|
@ -122,9 +122,9 @@ CREATE TABLE IF NOT EXISTS `contact` (
|
||||||
`xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
`xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||||
`attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
`attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||||
`avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
`avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||||
`photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
`photo` varchar(255) DEFAULT '' COMMENT '',
|
||||||
`thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
`thumb` varchar(255) DEFAULT '' COMMENT '',
|
||||||
`micro` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
`micro` varchar(255) DEFAULT '' COMMENT '',
|
||||||
`site-pubkey` text COMMENT '',
|
`site-pubkey` text COMMENT '',
|
||||||
`issued-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
`issued-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||||
`dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
`dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||||
|
@ -397,6 +397,8 @@ CREATE TABLE IF NOT EXISTS `gserver` (
|
||||||
`noscrape` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
`noscrape` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||||
`network` char(4) NOT NULL DEFAULT '' COMMENT '',
|
`network` char(4) NOT NULL DEFAULT '' COMMENT '',
|
||||||
`platform` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
`platform` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||||
|
`relay-subscribe` boolean NOT NULL DEFAULT '0' COMMENT 'Has the server subscribed to the relay system',
|
||||||
|
`relay-scope` varchar(10) NOT NULL DEFAULT '' COMMENT 'The scope of messages that the server wants to get',
|
||||||
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
|
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
|
||||||
`last_poco_query` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
|
`last_poco_query` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
|
||||||
`last_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
|
`last_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
|
||||||
|
@ -405,6 +407,16 @@ CREATE TABLE IF NOT EXISTS `gserver` (
|
||||||
UNIQUE INDEX `nurl` (`nurl`(190))
|
UNIQUE INDEX `nurl` (`nurl`(190))
|
||||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- TABLE gserver-tag
|
||||||
|
--
|
||||||
|
CREATE TABLE IF NOT EXISTS `gserver-tag` (
|
||||||
|
`gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
|
||||||
|
`tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
|
||||||
|
PRIMARY KEY(`gserver-id`,`tag`),
|
||||||
|
INDEX `tag` (`tag`)
|
||||||
|
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- TABLE hook
|
-- TABLE hook
|
||||||
--
|
--
|
||||||
|
@ -1079,3 +1091,4 @@ CREATE TABLE IF NOT EXISTS `workerqueue` (
|
||||||
INDEX `executed` (`executed`)
|
INDEX `executed` (`executed`)
|
||||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -372,7 +372,7 @@ include/cronhooks.php: Addon::callHooks('cron', $d);
|
||||||
|
|
||||||
include/security.php: Addon::callHooks('logged_in', $a->user);
|
include/security.php: Addon::callHooks('logged_in', $a->user);
|
||||||
|
|
||||||
include/html2bbcode.php: Addon::callHooks('html2bbcode', $text);
|
src/Content/Text/HTML.php: Addon::callHooks('html2bbcode', $text);
|
||||||
|
|
||||||
include/Contact.php: Addon::callHooks('remove_user',$r[0]);
|
include/Contact.php: Addon::callHooks('remove_user',$r[0]);
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ It's a command-line tool that downloads required libraries into the `vendor` fol
|
||||||
|
|
||||||
## How to use Composer
|
## How to use Composer
|
||||||
|
|
||||||
If you don't have Composer installed on your system, Friendica ships with a copy of it at `util/composer.phar`.
|
If you don't have Composer installed on your system, Friendica ships with a copy of it at `bin/composer.phar`.
|
||||||
For the purpose of this help, all examples will use this path to run Composer commands, however feel free to replace them with your own way of calling Composer.
|
For the purpose of this help, all examples will use this path to run Composer commands, however feel free to replace them with your own way of calling Composer.
|
||||||
Composer requires PHP CLI and the following examples assume it's available system-wide.
|
Composer requires PHP CLI and the following examples assume it's available system-wide.
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ Here are the typical commands you will have to run to do so:
|
||||||
````
|
````
|
||||||
~> git clone https://github.com/friendica/friendica.git friendica
|
~> git clone https://github.com/friendica/friendica.git friendica
|
||||||
~/friendica> cd friendica
|
~/friendica> cd friendica
|
||||||
~/friendica> util/composer.phar install
|
~/friendica> bin/composer.phar install
|
||||||
````
|
````
|
||||||
|
|
||||||
That's it! Composer will take care of fetching all the required libraries in the `vendor` folder and build the autoloader to make those libraries available to Friendica.
|
That's it! Composer will take care of fetching all the required libraries in the `vendor` folder and build the autoloader to make those libraries available to Friendica.
|
||||||
|
@ -42,7 +42,7 @@ Updating Friendica to the current stable or the latest develop version is easy w
|
||||||
````
|
````
|
||||||
~> cd friendica
|
~> cd friendica
|
||||||
~/friendica> git pull
|
~/friendica> git pull
|
||||||
~/friendica> util/composer.phar install
|
~/friendica> bin/composer.phar install
|
||||||
````
|
````
|
||||||
|
|
||||||
And that's it. If any library used by Friendica has been upgraded, Composer will fetch the version currently used by Friendica and refresh the autoloader to ensure the best performances.
|
And that's it. If any library used by Friendica has been upgraded, Composer will fetch the version currently used by Friendica and refresh the autoloader to ensure the best performances.
|
||||||
|
@ -87,13 +87,13 @@ Or you can specify the exact version of the library if you code requires it, and
|
||||||
|
|
||||||
To add a library, just add its Packagist identifier to the `require` list and set a target version string.
|
To add a library, just add its Packagist identifier to the `require` list and set a target version string.
|
||||||
|
|
||||||
Then you should run `util/composer.phar update` to add it to your local `vendor` folder and update the `composer.lock` file that specifies the current versions of the dependencies.
|
Then you should run `bin/composer.phar update` to add it to your local `vendor` folder and update the `composer.lock` file that specifies the current versions of the dependencies.
|
||||||
|
|
||||||
#### Updating an existing dependency
|
#### Updating an existing dependency
|
||||||
|
|
||||||
If a package needs to be updated, whether to the next minor version or to the next major version provided you changed the adequate code in Friendica, simply edit `composer.json` to update the target version string of the relevant library.
|
If a package needs to be updated, whether to the next minor version or to the next major version provided you changed the adequate code in Friendica, simply edit `composer.json` to update the target version string of the relevant library.
|
||||||
|
|
||||||
Then you should run `util/composer.phar update` to update it in your local `vendor` folder and update the `composer.lock` file that specifies the current versions of the dependencies.
|
Then you should run `bin/composer.phar update` to update it in your local `vendor` folder and update the `composer.lock` file that specifies the current versions of the dependencies.
|
||||||
|
|
||||||
Please note that you should commit both `composer.json` and `composer.lock` with your work every time you make a change to the former.
|
Please note that you should commit both `composer.json` and `composer.lock` with your work every time you make a change to the former.
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ This is because `sudo` doesn't always change the `HOME` environment variable, wh
|
||||||
However, you can temporarily change environment variable for the execution of a single command.
|
However, you can temporarily change environment variable for the execution of a single command.
|
||||||
For Composer, this would be:
|
For Composer, this would be:
|
||||||
````
|
````
|
||||||
$> COMPOSER_HOME=/var/tmp/composer sudo -u [web user] util/composer.phar [mode]
|
$> COMPOSER_HOME=/var/tmp/composer sudo -u [web user] bin/composer.phar [mode]
|
||||||
````
|
````
|
||||||
|
|
||||||
## Related
|
## Related
|
||||||
|
|
|
@ -94,7 +94,7 @@ Please remove all the `require_once` mentions of the former file, as they will p
|
||||||
|
|
||||||
## Miscellaneous tips
|
## Miscellaneous tips
|
||||||
|
|
||||||
When you are done with moving the class, please run `php util/typo.php` from the Friendica base directory to check for obvious mistakes.
|
When you are done with moving the class, please run `php bin/console.php typo` from the Friendica base directory to check for obvious mistakes.
|
||||||
Howevever, this tool isn't bullet-proof, and a staging install of Friendica is recommended to test your class move without impairing your production server if you host one.
|
Howevever, this tool isn't bullet-proof, and a staging install of Friendica is recommended to test your class move without impairing your production server if you host one.
|
||||||
|
|
||||||
Most of Friendica processes are run in the background, so make sure to turn on your debug log to check for errors that wouldn't show up while simply browsing Friendica.
|
Most of Friendica processes are run in the background, so make sure to turn on your debug log to check for errors that wouldn't show up while simply browsing Friendica.
|
||||||
|
|
|
@ -60,7 +60,7 @@ If you want to have git automatically update the dependencies with composer, you
|
||||||
}
|
}
|
||||||
# `composer install` if the `composer.lock` file gets changed
|
# `composer install` if the `composer.lock` file gets changed
|
||||||
# to update all the php dependencies
|
# to update all the php dependencies
|
||||||
check_run composer.lock "util/composer.phar install --no-dev"
|
check_run composer.lock "bin/composer.phar install --no-dev"
|
||||||
|
|
||||||
just place it into `.git/hooks/post-merge` and make it executable.
|
just place it into `.git/hooks/post-merge` and make it executable.
|
||||||
|
|
||||||
|
|
26
doc/FAQ.md
26
doc/FAQ.md
|
@ -30,7 +30,7 @@ User
|
||||||
|
|
||||||
SSL (Secure Socket Layer) is a technology to encrypt data transfer between computers.
|
SSL (Secure Socket Layer) is a technology to encrypt data transfer between computers.
|
||||||
Sometimes your browser warns you about a missing or invalid certificate.
|
Sometimes your browser warns you about a missing or invalid certificate.
|
||||||
These warnings can have three reasons:
|
These warnings can have three reasons:
|
||||||
|
|
||||||
1. The server you are connected to doesn't offer SSL encryption.
|
1. The server you are connected to doesn't offer SSL encryption.
|
||||||
2. The server has a self-signed certificate (not recommended).
|
2. The server has a self-signed certificate (not recommended).
|
||||||
|
@ -49,8 +49,8 @@ Generally, you can attach any kind of file to a post.
|
||||||
This is possible by using the "paper-clip"-symbol in the editor.
|
This is possible by using the "paper-clip"-symbol in the editor.
|
||||||
These files will be linked to your post and can be downloaded by your contacts.
|
These files will be linked to your post and can be downloaded by your contacts.
|
||||||
But it's not possible to get a preview for these items.
|
But it's not possible to get a preview for these items.
|
||||||
Because of this, this upload method is only recommended for office or zipped files.
|
Because of this, this upload method is only recommended for office or zipped files.
|
||||||
If you want to share content from Dropbox, Owncloud or any other [filehoster](http://en.wikipedia.org/wiki/Comparison_of_file_hosting_services), use the "link"-button (chain-symbol).
|
If you want to share content from Dropbox, Owncloud or any other [filehoster](http://en.wikipedia.org/wiki/Comparison_of_file_hosting_services), use the "link"-button (chain-symbol).
|
||||||
|
|
||||||
When you're adding URLs of other webpages with the "link"-button, Friendica tries to create a small preview.
|
When you're adding URLs of other webpages with the "link"-button, Friendica tries to create a small preview.
|
||||||
If this doesn't work, try to add the link by typing: [url=http://example.com]*self-chosen name*[/url].
|
If this doesn't work, try to add the link by typing: [url=http://example.com]*self-chosen name*[/url].
|
||||||
|
@ -58,9 +58,9 @@ If this doesn't work, try to add the link by typing: [url=http://example.com]*se
|
||||||
You can also add video and audio files to posts.
|
You can also add video and audio files to posts.
|
||||||
However, instead of a direct upload you have to use one of the following methods:
|
However, instead of a direct upload you have to use one of the following methods:
|
||||||
|
|
||||||
1. Add the video or audio link of a hoster (Youtube, Vimeo, Soundcloud and anyone else with oembed/opengraph-support). Videos will be shown with a preview image you can click on to start. SoundCloud directly inserts a player to your post.
|
1. Add the video or audio link of a hoster (Youtube, Vimeo, Soundcloud and anyone else with oembed/opengraph-support). Videos will be shown with a preview image you can click on to start. SoundCloud directly inserts a player to your post.
|
||||||
|
|
||||||
2. If you have your own server, you can upload multimedia files via FTP and insert the URL.
|
2. If you have your own server, you can upload multimedia files via FTP and insert the URL.
|
||||||
|
|
||||||
Friendica uses HTML5 for embedding content.
|
Friendica uses HTML5 for embedding content.
|
||||||
Therefore, the supported files are dependent on your browser and operating system.
|
Therefore, the supported files are dependent on your browser and operating system.
|
||||||
|
@ -125,16 +125,16 @@ If you want to share your public page via rss you can use one of the following l
|
||||||
|
|
||||||
basic-url.com//feed/[nickname]/posts
|
basic-url.com//feed/[nickname]/posts
|
||||||
|
|
||||||
Example: Friendica Support
|
Example: Friendica Support
|
||||||
|
|
||||||
https://forum.friendi.ca/feed/helpers/posts
|
https://forum.friendi.ca/feed/helpers/posts
|
||||||
|
|
||||||
#### RSS feed of the conversations at your site
|
#### RSS feed of the conversations at your site
|
||||||
|
|
||||||
basic-url.com/feed/profilename/comments
|
basic-url.com/feed/profilename/comments
|
||||||
|
|
||||||
Example: Friendica Support
|
Example: Friendica Support
|
||||||
|
|
||||||
https://forum.friendi.ca/feed/helpers/comments
|
https://forum.friendi.ca/feed/helpers/comments
|
||||||
|
|
||||||
<a name="clients"></a>
|
<a name="clients"></a>
|
||||||
|
@ -192,7 +192,7 @@ There you will always find the current stable version of friendica.
|
||||||
|
|
||||||
Addons are listed at [this page](https://github.com/friendica/friendica-addons).
|
Addons are listed at [this page](https://github.com/friendica/friendica-addons).
|
||||||
|
|
||||||
If you are searching for new themes, you can find them at [Friendica-Themes.com](http://friendica-themes.com/)
|
If you are searching for new themes, you can find them at [Friendica-Themes.com](http://friendica-themes.com/)
|
||||||
|
|
||||||
<a name="adminaccount1"></a>
|
<a name="adminaccount1"></a>
|
||||||
### I've changed my email address now the admin panel is gone?
|
### I've changed my email address now the admin panel is gone?
|
||||||
|
@ -213,8 +213,8 @@ The listed emails need to be separated by a comma.
|
||||||
Please have a look at the Admin panel under [DB updates](/admin/dbsync/) and follow the link to *check database structure*.
|
Please have a look at the Admin panel under [DB updates](/admin/dbsync/) and follow the link to *check database structure*.
|
||||||
This will start a background process to check if the structure is up to the current definition.
|
This will start a background process to check if the structure is up to the current definition.
|
||||||
|
|
||||||
You can manually execute the structure update from the CLI in the base directory of your Friendica installation by running the following script:
|
You can manually execute the structure update from the CLI in the base directory of your Friendica installation by running the following command:
|
||||||
|
|
||||||
scripts/dbstructure.php update
|
bin/console dbstructure update
|
||||||
|
|
||||||
if there occur any errors, please contact the [support forum](https://forum.friendi.ca/profile/helpers).
|
if there occur any errors, please contact the [support forum](https://forum.friendi.ca/profile/helpers).
|
||||||
|
|
|
@ -13,7 +13,7 @@ Introduction to the workflow with our GitHub repository
|
||||||
3. Fork the Friendica repository from [https://github.com/friendica/friendica.git](https://github.com/friendica/friendica.git).
|
3. Fork the Friendica repository from [https://github.com/friendica/friendica.git](https://github.com/friendica/friendica.git).
|
||||||
4. Clone your fork from your GitHub account to your machine.
|
4. Clone your fork from your GitHub account to your machine.
|
||||||
Follow the instructions provided here: [http://help.github.com/fork-a-repo/](http://help.github.com/fork-a-repo/) to create and use your own tracking fork on GitHub
|
Follow the instructions provided here: [http://help.github.com/fork-a-repo/](http://help.github.com/fork-a-repo/) to create and use your own tracking fork on GitHub
|
||||||
5. Run `util/composer.phar install` in Friendica's folder.
|
5. Run `bin/composer.phar install` in Friendica's folder.
|
||||||
6. Commit your changes to your fork.
|
6. Commit your changes to your fork.
|
||||||
Then go to your GitHub page and create a "Pull request" to notify us to merge your work.
|
Then go to your GitHub page and create a "Pull request" to notify us to merge your work.
|
||||||
|
|
||||||
|
@ -68,7 +68,9 @@ If possible get an experienced Friendica developer to review the code.
|
||||||
Don't hesitate to ask us in case of doubt.
|
Don't hesitate to ask us in case of doubt.
|
||||||
|
|
||||||
3. Check your code for typos.
|
3. Check your code for typos.
|
||||||
There is a PHP script in the *util* directory called *typos.php* for this.
|
There is a console command called *typo* for this.
|
||||||
|
|
||||||
|
$> php bin/console.php typo
|
||||||
|
|
||||||
Check out how to work with [our Vagrant](help/Vagrant) to save a lot of setup time!
|
Check out how to work with [our Vagrant](help/Vagrant) to save a lot of setup time!
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ The Linux commands to clone the repository into a directory "mywebsite" would be
|
||||||
|
|
||||||
git clone https://github.com/friendica/friendica.git mywebsite
|
git clone https://github.com/friendica/friendica.git mywebsite
|
||||||
cd mywebsite
|
cd mywebsite
|
||||||
util/composer.phar install
|
bin/composer.phar install
|
||||||
|
|
||||||
Make sure the folder *view/smarty3* exists and is writable by the webserver user
|
Make sure the folder *view/smarty3* exists and is writable by the webserver user
|
||||||
|
|
||||||
|
@ -102,14 +102,14 @@ You might wish to move/rename .htconfig.php to another name and empty (called 'd
|
||||||
Set up a cron job or scheduled task to run the worker once every 5-10 minutes in order to perform background processing.
|
Set up a cron job or scheduled task to run the worker once every 5-10 minutes in order to perform background processing.
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
cd /base/directory; /path/to/php scripts/worker.php
|
cd /base/directory; /path/to/php bin/worker.php
|
||||||
|
|
||||||
Change "/base/directory", and "/path/to/php" as appropriate for your situation.
|
Change "/base/directory", and "/path/to/php" as appropriate for your situation.
|
||||||
|
|
||||||
If you are using a Linux server, run "crontab -e" and add a line like the
|
If you are using a Linux server, run "crontab -e" and add a line like the
|
||||||
one shown, substituting for your unique paths and settings:
|
one shown, substituting for your unique paths and settings:
|
||||||
|
|
||||||
*/10 * * * * cd /home/myname/mywebsite; /usr/bin/php scripts/worker.php
|
*/10 * * * * cd /home/myname/mywebsite; /usr/bin/php bin/worker.php
|
||||||
|
|
||||||
You can generally find the location of PHP by executing "which php".
|
You can generally find the location of PHP by executing "which php".
|
||||||
If you run into trouble with this section please contact your hosting provider for assistance.
|
If you run into trouble with this section please contact your hosting provider for assistance.
|
||||||
|
|
|
@ -21,7 +21,7 @@ You can get the latest changes at any time with
|
||||||
|
|
||||||
cd path/to/friendica
|
cd path/to/friendica
|
||||||
git pull
|
git pull
|
||||||
util/composer.phar install
|
bin/composer.phar install
|
||||||
|
|
||||||
The addon tree has to be updated separately like so:
|
The addon tree has to be updated separately like so:
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
Table cache
|
Table cache
|
||||||
===========
|
===========
|
||||||
|
|
||||||
|
Stores temporary data
|
||||||
|
|
||||||
| Field | Description | Type | Null | Key | Default | Extra |
|
| Field | Description | Type | Null | Key | Default | Extra |
|
||||||
| ------------ | ---------------------------------- | ------------ | ---- | --- | ------------------- | ----- |
|
| ------------ | ---------------------------------- | ------------ | ---- | --- | ------------------- | ----- |
|
||||||
| k | horizontal width + url or resource | varchar(255) | NO | PRI | NULL | |
|
| k | cache key | varchar(255) | NO | PRI | NULL | |
|
||||||
| v | OEmbed response from site | text | NO | | NULL | |
|
| v | cached serialized value | text | NO | | NULL | |
|
||||||
|
| expires | datetime of cache expiration | datetime | NO | MUL | 0001-01-01 00:00:00 | |
|
||||||
| updated | datetime of cache insertion | datetime | NO | MUL | 0001-01-01 00:00:00 | |
|
| updated | datetime of cache insertion | datetime | NO | MUL | 0001-01-01 00:00:00 | |
|
||||||
| expire_mode | | int(11) | NO | | 0 | |
|
|
||||||
|
|
||||||
Return to [database documentation](help/database)
|
Return to [database documentation](help/database)
|
||||||
|
|
|
@ -265,7 +265,7 @@ include/cronhooks.php: Addon::callHooks('cron', $d);
|
||||||
|
|
||||||
include/security.php: Addon::callHooks('logged_in', $a->user);
|
include/security.php: Addon::callHooks('logged_in', $a->user);
|
||||||
|
|
||||||
include/html2bbcode.php: Addon::callHooks('html2bbcode', $text);
|
src/Content/Text/HTML.php: Addon::callHooks('html2bbcode', $text);
|
||||||
|
|
||||||
include/Contact.php: Addon::callHooks('remove_user',$r[0]);
|
include/Contact.php: Addon::callHooks('remove_user',$r[0]);
|
||||||
|
|
||||||
|
|
|
@ -29,10 +29,10 @@ Nutzer
|
||||||
<a name="ssl"></a>
|
<a name="ssl"></a>
|
||||||
### Warum erhalte ich Warnungen über fehlende Zertifikate?
|
### Warum erhalte ich Warnungen über fehlende Zertifikate?
|
||||||
|
|
||||||
Manchmal erhältst Du eine Browser-Warnung über fehlende Zertifikate.
|
Manchmal erhältst Du eine Browser-Warnung über fehlende Zertifikate.
|
||||||
Diese Warnungen können drei Gründe haben:
|
Diese Warnungen können drei Gründe haben:
|
||||||
|
|
||||||
1. der Server, mit dem Du verbunden bist, nutzt kein SSL;
|
1. der Server, mit dem Du verbunden bist, nutzt kein SSL;
|
||||||
|
|
||||||
2. der Server hat ein selbst-signiertes Zertifikat (nicht empfohlen)
|
2. der Server hat ein selbst-signiertes Zertifikat (nicht empfohlen)
|
||||||
|
|
||||||
|
@ -40,39 +40,39 @@ Diese Warnungen können drei Gründe haben:
|
||||||
|
|
||||||
*(SSL (Secure Socket Layer) ist eine Technologie, die Daten auf ihrem Weg zwischen zwei Computern verschlüsselt.)*
|
*(SSL (Secure Socket Layer) ist eine Technologie, die Daten auf ihrem Weg zwischen zwei Computern verschlüsselt.)*
|
||||||
|
|
||||||
Wenn Du noch kein SSL-Zertifikat hast, dann gibt es drei Wege, eines zu erhalten: kauf Dir eines, hole Dir ein kostenloses (z.B. bei StartSSL, WoSign, hoffentlich bald auch letsencrypt) oder kreiere Dein eigenes (nicht empfohlen).
|
Wenn Du noch kein SSL-Zertifikat hast, dann gibt es drei Wege, eines zu erhalten: kauf Dir eines, hole Dir ein kostenloses (z.B. bei StartSSL, WoSign, hoffentlich bald auch letsencrypt) oder kreiere Dein eigenes (nicht empfohlen).
|
||||||
[Weitere Informationen über die Einrichtung von SSL und warum es schlecht ist, selbst-signierte Zertifikate zu nutzen, findest Du hier.](help/SSL)
|
[Weitere Informationen über die Einrichtung von SSL und warum es schlecht ist, selbst-signierte Zertifikate zu nutzen, findest Du hier.](help/SSL)
|
||||||
|
|
||||||
Sei Dir bewusst, dass Browser-Warnungen über Sicherheitslücken etwas sind, wodurch neue Nutzer schnell das Vertrauen in das gesamte Friendica-Projekt verlieren können.
|
Sei Dir bewusst, dass Browser-Warnungen über Sicherheitslücken etwas sind, wodurch neue Nutzer schnell das Vertrauen in das gesamte Friendica-Projekt verlieren können.
|
||||||
Aus diesem Grund wird Friendica Red nur SSL-Zertifikate eines anerkannten Anbieters (CA, certificate authority) akzeptieren und nicht zu Seiten verbinden, die kein SSL nutzen.
|
Aus diesem Grund wird Friendica Red nur SSL-Zertifikate eines anerkannten Anbieters (CA, certificate authority) akzeptieren und nicht zu Seiten verbinden, die kein SSL nutzen.
|
||||||
Unabhängig von den negativen Aspekten von SSL handelt es sich hierbei um eine notwendige Lösung, solange keine etablierte Alternative existiert.
|
Unabhängig von den negativen Aspekten von SSL handelt es sich hierbei um eine notwendige Lösung, solange keine etablierte Alternative existiert.
|
||||||
|
|
||||||
Abgesehen davon kann es ohne SSL auch Probleme mit der Verbindung zu Diaspora geben, da einige Diaspora-Pods eine zertifizierte Verbindung benötigen.
|
Abgesehen davon kann es ohne SSL auch Probleme mit der Verbindung zu Diaspora geben, da einige Diaspora-Pods eine zertifizierte Verbindung benötigen.
|
||||||
|
|
||||||
Wenn Du Friendica nur für eine bestimmte Gruppe von Leuten auf einem einzelnen Server nutzt, bei dem keine Verbindung zum restlichen Netzwerk besteht, dann benötigst Du kein SSL.
|
Wenn Du Friendica nur für eine bestimmte Gruppe von Leuten auf einem einzelnen Server nutzt, bei dem keine Verbindung zum restlichen Netzwerk besteht, dann benötigst Du kein SSL.
|
||||||
Ebenso benötigst Du SSL nicht, wenn Du ausschließlich öffentliche Beiträge auf Deiner Seite veröffentlichst bzw. empfängst.
|
Ebenso benötigst Du SSL nicht, wenn Du ausschließlich öffentliche Beiträge auf Deiner Seite veröffentlichst bzw. empfängst.
|
||||||
|
|
||||||
Wenn Du zum jetzigen Zeitpunkt noch keinen Server aufgesetzt hast, ist es sinnvoll, die verschiedenen Anbieter in Bezug auf SSL zu vergleichen.
|
Wenn Du zum jetzigen Zeitpunkt noch keinen Server aufgesetzt hast, ist es sinnvoll, die verschiedenen Anbieter in Bezug auf SSL zu vergleichen.
|
||||||
Einige erlauben die Nutzung von freien Zertifikaten oder lassen Dich ihre eigenen Zertifikate mitnutzen.
|
Einige erlauben die Nutzung von freien Zertifikaten oder lassen Dich ihre eigenen Zertifikate mitnutzen.
|
||||||
Andere erlauben nur kostenpflichtige Zertifikate als eigenes Angebot bzw. von anderen Anbietern.
|
Andere erlauben nur kostenpflichtige Zertifikate als eigenes Angebot bzw. von anderen Anbietern.
|
||||||
|
|
||||||
<a name="upload"></a>
|
<a name="upload"></a>
|
||||||
### Wie kann ich Bilder, Dateien, Links, Video und Audio in Beiträge einfügen?
|
### Wie kann ich Bilder, Dateien, Links, Video und Audio in Beiträge einfügen?
|
||||||
|
|
||||||
Bilder können direkt im [Beitragseditor](help/Text_editor) vom Computer hochgeladen werden.
|
Bilder können direkt im [Beitragseditor](help/Text_editor) vom Computer hochgeladen werden.
|
||||||
Eine Übersicht aller Bilder, die auf Deinem Server liegen, findest Du unter <i>deineSeite.de/photos/profilname</i>.
|
Eine Übersicht aller Bilder, die auf Deinem Server liegen, findest Du unter <i>deineSeite.de/photos/profilname</i>.
|
||||||
Dort kannst Du auch direkt Bilder hochladen und festlegen, ob Deine Kontakte eine Nachricht über das neue Bild bekommen.
|
Dort kannst Du auch direkt Bilder hochladen und festlegen, ob Deine Kontakte eine Nachricht über das neue Bild bekommen.
|
||||||
|
|
||||||
Alle Arten von Dateien können grundsätzlich als Anhang in Friendica hochgeladen werden.
|
Alle Arten von Dateien können grundsätzlich als Anhang in Friendica hochgeladen werden.
|
||||||
Dafür verwendest Du das Büroklammersymbol im Editor.
|
Dafür verwendest Du das Büroklammersymbol im Editor.
|
||||||
Sie sind dann direkt an den Beitrag geknüpft, können von den Betrachtern heruntergeladen werden, aber werden nicht als Vorschau angezeigt.
|
Sie sind dann direkt an den Beitrag geknüpft, können von den Betrachtern heruntergeladen werden, aber werden nicht als Vorschau angezeigt.
|
||||||
Deshalb eignet sich diese Methode vor allem für Office-Dateien oder gepackte Dateien wie ZIPs, aber weniger für Multimediadateien.
|
Deshalb eignet sich diese Methode vor allem für Office-Dateien oder gepackte Dateien wie ZIPs, aber weniger für Multimediadateien.
|
||||||
Wer hingegen Dateien über Dropbox, über eine auf dem eigenen Server installierte Owncloud oder über einen anderen [Filehoster](http://en.wikipedia.org/wiki/Comparison_of_file_hosting_services) einfügen will, verwendet den Link-Button.
|
Wer hingegen Dateien über Dropbox, über eine auf dem eigenen Server installierte Owncloud oder über einen anderen [Filehoster](http://en.wikipedia.org/wiki/Comparison_of_file_hosting_services) einfügen will, verwendet den Link-Button.
|
||||||
|
|
||||||
Wenn Du mit dem Link-Button (Ketten-Symbol) URLs zu anderen Seiten einfügst, versucht Friendica eine kurze Zusammenfassung als Vorschau abzurufen.
|
Wenn Du mit dem Link-Button (Ketten-Symbol) URLs zu anderen Seiten einfügst, versucht Friendica eine kurze Zusammenfassung als Vorschau abzurufen.
|
||||||
Manchmal klappts das nicht ... dann verlinke den Beitrag einfach per [url=http://example.com]<i>freigewählter Name</i>[/url] im Editor.
|
Manchmal klappts das nicht ... dann verlinke den Beitrag einfach per [url=http://example.com]<i>freigewählter Name</i>[/url] im Editor.
|
||||||
|
|
||||||
Video- und Audiodateien können zwar in Beiträge eingebunden werden, allerdings geht das nicht über einen direkten Upload im Editor wie bei Fotos.
|
Video- und Audiodateien können zwar in Beiträge eingebunden werden, allerdings geht das nicht über einen direkten Upload im Editor wie bei Fotos.
|
||||||
Du hast zwei Möglichkeiten:
|
Du hast zwei Möglichkeiten:
|
||||||
|
|
||||||
1. Du kannst bei dem Video- oder Audiobutton die URL von einem Hoster eingeben (Youtube, Vimeo, Soundcloud und alle anderen mit oembed/opengraph-Unterstützung). Bei Videos zeigt Friendica dann ein Vorschaubild in Deinem Beitrag an, nach einem Klick öffnet sich ein eingebetter Player. Bei Soundcloud wird der Player direkt eingebunden.
|
1. Du kannst bei dem Video- oder Audiobutton die URL von einem Hoster eingeben (Youtube, Vimeo, Soundcloud und alle anderen mit oembed/opengraph-Unterstützung). Bei Videos zeigt Friendica dann ein Vorschaubild in Deinem Beitrag an, nach einem Klick öffnet sich ein eingebetter Player. Bei Soundcloud wird der Player direkt eingebunden.
|
||||||
|
@ -93,32 +93,32 @@ Um Deine privaten Daten zu schützen, wird in Beiträgen nur das Bild aus Deinem
|
||||||
<a name="contacts"></a>
|
<a name="contacts"></a>
|
||||||
### Was ist der Unterschied zwischen blockierten|ignorierten|archivierten|versteckten Kontakten?
|
### Was ist der Unterschied zwischen blockierten|ignorierten|archivierten|versteckten Kontakten?
|
||||||
|
|
||||||
Wir verhindern direkte Kommunikation mit blockierten Kontakten.
|
Wir verhindern direkte Kommunikation mit blockierten Kontakten.
|
||||||
Sie gehören nicht zu den Empfängern beim Versand von Beiträgen und deren Beiträge werden auch nicht importiert.
|
Sie gehören nicht zu den Empfängern beim Versand von Beiträgen und deren Beiträge werden auch nicht importiert.
|
||||||
Trotzdem werden deren Unterhaltungen mit Deinen Freunden in Deinem Stream sichtbar sein.
|
Trotzdem werden deren Unterhaltungen mit Deinen Freunden in Deinem Stream sichtbar sein.
|
||||||
Wenn Du einen Kontakt komplett löschst, können sie Dir eine neue Freundschaftsanfrage schicken.
|
Wenn Du einen Kontakt komplett löschst, können sie Dir eine neue Freundschaftsanfrage schicken.
|
||||||
Blockierte Kontakte können das nicht machen.
|
Blockierte Kontakte können das nicht machen.
|
||||||
Sie können nicht mit Dir direkt kommunizieren, nur über Freunde.
|
Sie können nicht mit Dir direkt kommunizieren, nur über Freunde.
|
||||||
|
|
||||||
Ignorierte Kontakte können weiterhin Beiträge und private Nachrichten von Dir erhalten.
|
Ignorierte Kontakte können weiterhin Beiträge und private Nachrichten von Dir erhalten.
|
||||||
Deren Beiträge und private Nachrichten werden allerdings nicht importiert.
|
Deren Beiträge und private Nachrichten werden allerdings nicht importiert.
|
||||||
Wie bei blockierten Beiträgen siehst Du auch hier weiterhin die Kommentare dieser Person zu anderen Beiträgen Deiner Freunde.
|
Wie bei blockierten Beiträgen siehst Du auch hier weiterhin die Kommentare dieser Person zu anderen Beiträgen Deiner Freunde.
|
||||||
|
|
||||||
[Ein Erweiterung namens "blockem" kann installiert werden, um alle Beiträge einer bestimmten Person in Deinem Stream zu verstecken bzw. zu verkürzen.
|
[Ein Erweiterung namens "blockem" kann installiert werden, um alle Beiträge einer bestimmten Person in Deinem Stream zu verstecken bzw. zu verkürzen.
|
||||||
Dabei werden auch Kommentare dieser Person in Beiträgen Deiner Freunde blockiert.]
|
Dabei werden auch Kommentare dieser Person in Beiträgen Deiner Freunde blockiert.]
|
||||||
|
|
||||||
Ein archivierter Kontakt bedeutet, dass Kommunikation nicht möglich ist und auch nicht versucht wird (das ist z.B. sinnvoll, wenn eine Person zu einem neuen Server gewechselt ist und das alte Profil gelöscht hat).
|
Ein archivierter Kontakt bedeutet, dass Kommunikation nicht möglich ist und auch nicht versucht wird (das ist z.B. sinnvoll, wenn eine Person zu einem neuen Server gewechselt ist und das alte Profil gelöscht hat).
|
||||||
Anders als beim Blockieren werden existierende Beiträge, die vor der Archivierung erstellt wurden, weiterhin angezeigt.
|
Anders als beim Blockieren werden existierende Beiträge, die vor der Archivierung erstellt wurden, weiterhin angezeigt.
|
||||||
|
|
||||||
Ein versteckter Kontakt wird in keiner "Freundeliste" erscheinen (außer für dich).
|
Ein versteckter Kontakt wird in keiner "Freundeliste" erscheinen (außer für dich).
|
||||||
Trotzdem wird ein versteckter Kontakt normal in Unterhaltungen angezeigt - was für andere Kontakte ein Hinweis sein kann, dass diese Person als versteckter Kontakt in Deiner Liste ist.
|
Trotzdem wird ein versteckter Kontakt normal in Unterhaltungen angezeigt - was für andere Kontakte ein Hinweis sein kann, dass diese Person als versteckter Kontakt in Deiner Liste ist.
|
||||||
|
|
||||||
<a name="removed"></a>
|
<a name="removed"></a>
|
||||||
### Was passiert, wenn ein Account gelöscht ist? Ist dieser richtig gelöscht?
|
### Was passiert, wenn ein Account gelöscht ist? Ist dieser richtig gelöscht?
|
||||||
|
|
||||||
Wenn Du Deinen Account löschst, wird sofort der gesamte Inhalt auf Deinem Server gelöscht und ein Löschbefehl an alle Deine Kontakte verschickt.
|
Wenn Du Deinen Account löschst, wird sofort der gesamte Inhalt auf Deinem Server gelöscht und ein Löschbefehl an alle Deine Kontakte verschickt.
|
||||||
Dadurch wirst Du ebenfalls aus dem globalen Verzeichnis gelöscht.
|
Dadurch wirst Du ebenfalls aus dem globalen Verzeichnis gelöscht.
|
||||||
Dieses Vorgehen setzt voraus, dass Dein Profil für 24 Stunden weiterhin "teilweise" verfügbar sein wird, um eine Verbindung zu allen Deinen Kontakten ermöglicht.
|
Dieses Vorgehen setzt voraus, dass Dein Profil für 24 Stunden weiterhin "teilweise" verfügbar sein wird, um eine Verbindung zu allen Deinen Kontakten ermöglicht.
|
||||||
Wir können also Dein Profil blockieren und es so erscheinen lassen, als wären alle Daten sofort gelöscht, allerdings warten wir 24 Stunden (bzw. bis alle Deine Kontakte informiert wurden), bevor wir die Daten auch physikalisch löschen.
|
Wir können also Dein Profil blockieren und es so erscheinen lassen, als wären alle Daten sofort gelöscht, allerdings warten wir 24 Stunden (bzw. bis alle Deine Kontakte informiert wurden), bevor wir die Daten auch physikalisch löschen.
|
||||||
|
|
||||||
<a name="hashtag"></a>
|
<a name="hashtag"></a>
|
||||||
|
@ -137,16 +137,16 @@ Wenn Du die Beiträge Deines Accounts mit RSS teilen willst, dann kannst Du eine
|
||||||
|
|
||||||
deineSeite.de/feed/[profilname]/posts
|
deineSeite.de/feed/[profilname]/posts
|
||||||
|
|
||||||
Beispiel: Friendica Support
|
Beispiel: Friendica Support
|
||||||
|
|
||||||
https://forum.friendi.ca/feed/helpers/posts
|
https://forum.friendi.ca/feed/helpers/posts
|
||||||
|
|
||||||
#### RSS-Feed all deiner Beiträge und Antworten
|
#### RSS-Feed all deiner Beiträge und Antworten
|
||||||
|
|
||||||
deineSeite.de/dfrn_poll/feed/[profilname]/comments
|
deineSeite.de/dfrn_poll/feed/[profilname]/comments
|
||||||
|
|
||||||
Beispiel: Friendica Support
|
Beispiel: Friendica Support
|
||||||
|
|
||||||
https://forum.friendi.ca/feeds/helpers/comments
|
https://forum.friendi.ca/feeds/helpers/comments
|
||||||
|
|
||||||
#### RSS-Feed all deiner Aktivitäten
|
#### RSS-Feed all deiner Aktivitäten
|
||||||
|
@ -197,16 +197,16 @@ Admin
|
||||||
<a name="multiple"></a>
|
<a name="multiple"></a>
|
||||||
### Kann ich mehrere Domains mit den selben Dateien aufsetzen?
|
### Kann ich mehrere Domains mit den selben Dateien aufsetzen?
|
||||||
|
|
||||||
Ja, das ist möglich.
|
Ja, das ist möglich.
|
||||||
Es ist allerdings nicht möglich, eine Datenbank durch zwei Domains zu nutzen.
|
Es ist allerdings nicht möglich, eine Datenbank durch zwei Domains zu nutzen.
|
||||||
Solange Du Deine .htconfig.php allerdings so einrichtest, dass das System nicht versucht, eine Installation durchzuführen, kannst Du die richtige Config-Datei in include/$hostname/.htconfig.php hinterlegen.
|
Solange Du Deine .htconfig.php allerdings so einrichtest, dass das System nicht versucht, eine Installation durchzuführen, kannst Du die richtige Config-Datei in include/$hostname/.htconfig.php hinterlegen.
|
||||||
Alle Cache-Aspekte und der Zugriffsschutz können pro Instanz konfiguriert werden.
|
Alle Cache-Aspekte und der Zugriffsschutz können pro Instanz konfiguriert werden.
|
||||||
|
|
||||||
<a name="sources"></a>
|
<a name="sources"></a>
|
||||||
### Wo kann ich den Quellcode von Friendica, Addons und Themes finden?
|
### Wo kann ich den Quellcode von Friendica, Addons und Themes finden?
|
||||||
|
|
||||||
Du kannst den Friendica-Quellcode [hier](https://github.com/friendica/friendica) finden.
|
Du kannst den Friendica-Quellcode [hier](https://github.com/friendica/friendica) finden.
|
||||||
Dort findest Du immer die aktuellste stabile Version von Friendica.
|
Dort findest Du immer die aktuellste stabile Version von Friendica.
|
||||||
Der Quellcode von Friendica Red ist [hier](https://github.com/friendica/red) zu finden.
|
Der Quellcode von Friendica Red ist [hier](https://github.com/friendica/red) zu finden.
|
||||||
|
|
||||||
Addons findest Du auf [dieser Seite](https://github.com/friendica/friendica-addons).
|
Addons findest Du auf [dieser Seite](https://github.com/friendica/friendica-addons).
|
||||||
|
@ -232,8 +232,8 @@ Rufe bitte im Admin Panel den Punkt [DB Updates](/admin/dbsync/) auf und folge d
|
||||||
Damit wird ein Hintergrundprozess gestartet der die Struktur deiner Datenbank überprüft und gegebenenfalls aktualisiert.
|
Damit wird ein Hintergrundprozess gestartet der die Struktur deiner Datenbank überprüft und gegebenenfalls aktualisiert.
|
||||||
|
|
||||||
Du kannst das Struktur Updatee auch manuell auf der Kommandoeingabe ausführen.
|
Du kannst das Struktur Updatee auch manuell auf der Kommandoeingabe ausführen.
|
||||||
Starte dazu bitte vom Grundverzeichnis deiner Friendica Instanz folgendes Skript:
|
Starte dazu bitte vom Grundverzeichnis deiner Friendica Instanz folgendes Kommand:
|
||||||
|
|
||||||
scripts/dbstructure.php update
|
bin/console dbstructure update
|
||||||
|
|
||||||
sollten bei der Ausführung Fehler auftreten, kontaktiere bitte das [Support Forum](https://forum.friendi.ca/profile/helpers).
|
sollten bei der Ausführung Fehler auftreten, kontaktiere bitte das [Support Forum](https://forum.friendi.ca/profile/helpers).
|
||||||
|
|
|
@ -50,7 +50,7 @@ Wir planen, diese Einschränkung in einer zukünftigen Version zu beheben.
|
||||||
|
|
||||||
`cd meinewebseite`
|
`cd meinewebseite`
|
||||||
`git pull`
|
`git pull`
|
||||||
`util/composer.phar install`
|
`bin/composer.phar install`
|
||||||
|
|
||||||
- Addons installieren
|
- Addons installieren
|
||||||
- zunächst solltest du **in** deinem Webseitenordner sein
|
- zunächst solltest du **in** deinem Webseitenordner sein
|
||||||
|
@ -87,13 +87,13 @@ Wenn du irgendwelche **kritischen** Fehler zu diesen Zeitpunkt erhalten solltest
|
||||||
|
|
||||||
7. Erstelle einen Cron job oder einen regelmäßigen Task, um den Poller alle 5-10 Minuten im Hintergrund ablaufen zu lassen. Beispiel:
|
7. Erstelle einen Cron job oder einen regelmäßigen Task, um den Poller alle 5-10 Minuten im Hintergrund ablaufen zu lassen. Beispiel:
|
||||||
|
|
||||||
`cd /base/directory; /path/to/php scripts/worker.php`
|
`cd /base/directory; /path/to/php bin/worker.php`
|
||||||
|
|
||||||
Ändere "/base/directory" und "/path/to/php" auf deine Systemvorgaben.
|
Ändere "/base/directory" und "/path/to/php" auf deine Systemvorgaben.
|
||||||
|
|
||||||
Wenn du einen Linux-Server nutzt, benutze den Befehl "crontab -e" und ergänze eine Zeile wie die Folgende; angepasst an dein System
|
Wenn du einen Linux-Server nutzt, benutze den Befehl "crontab -e" und ergänze eine Zeile wie die Folgende; angepasst an dein System
|
||||||
|
|
||||||
`*/10 * * * * cd /home/myname/mywebsite; /usr/bin/php scripts/worker.php`
|
`*/10 * * * * cd /home/myname/mywebsite; /usr/bin/php bin/worker.php`
|
||||||
|
|
||||||
Du kannst den PHP-Pfad finden, indem du den Befehl „which php“ ausführst.
|
Du kannst den PHP-Pfad finden, indem du den Befehl „which php“ ausführst.
|
||||||
Wenn du Schwierigkeiten mit diesem Schritt hast, kannst du deinen Hosting-Anbieter kontaktieren.
|
Wenn du Schwierigkeiten mit diesem Schritt hast, kannst du deinen Hosting-Anbieter kontaktieren.
|
||||||
|
|
|
@ -27,6 +27,7 @@ Example: To set the automatic database cleanup process add this line to your .ht
|
||||||
* **always_show_preview** (Boolean) - Only show small preview picures. Default value is false.
|
* **always_show_preview** (Boolean) - Only show small preview picures. Default value is false.
|
||||||
* **block_local_dir** (Boolean) - Blocks the access to the directory of the local users.
|
* **block_local_dir** (Boolean) - Blocks the access to the directory of the local users.
|
||||||
* **auth_cookie_lifetime** (Integer) - Number of days that should pass without any activity before a user who chose "Remember me" when logging in is considered logged out. Defaults to 7.
|
* **auth_cookie_lifetime** (Integer) - Number of days that should pass without any activity before a user who chose "Remember me" when logging in is considered logged out. Defaults to 7.
|
||||||
|
* **config_adapter** (jit|preload) - Allow to switch the configuration adapter to improve performances at the cost of memory consumption. Default value is "jit"
|
||||||
* **curl_range_bytes** - Maximum number of bytes that should be fetched. Default is 0, which mean "no limit".
|
* **curl_range_bytes** - Maximum number of bytes that should be fetched. Default is 0, which mean "no limit".
|
||||||
* **db_log** - Name of a logfile to log slow database queries
|
* **db_log** - Name of a logfile to log slow database queries
|
||||||
* **db_loglimit** - If a database call lasts longer than this value it is logged
|
* **db_loglimit** - If a database call lasts longer than this value it is logged
|
||||||
|
@ -40,6 +41,7 @@ Example: To set the automatic database cleanup process add this line to your .ht
|
||||||
* **diaspora_test** (Boolean) - For development only. Disables the message transfer.
|
* **diaspora_test** (Boolean) - For development only. Disables the message transfer.
|
||||||
* **disable_email_validation** (Boolean) - Disables the check if a mail address is in a valid format and can be resolved via DNS.
|
* **disable_email_validation** (Boolean) - Disables the check if a mail address is in a valid format and can be resolved via DNS.
|
||||||
* **disable_url_validation** (Boolean) - Disables the DNS lookup of an URL.
|
* **disable_url_validation** (Boolean) - Disables the DNS lookup of an URL.
|
||||||
|
* **disable_password_exposed** (Boolean) - Disable the exposition check against the remote haveibeenpwned API on password change. Default value is false.
|
||||||
* **dlogfile - location of the developer log file
|
* **dlogfile - location of the developer log file
|
||||||
* **dlogip - restricts develop log writes to requests originating from this IP address
|
* **dlogip - restricts develop log writes to requests originating from this IP address
|
||||||
* **frontend_worker_timeout** - Value in minutes after we think that a frontend task was killed by the webserver. Default value is 10.
|
* **frontend_worker_timeout** - Value in minutes after we think that a frontend task was killed by the webserver. Default value is 10.
|
||||||
|
@ -59,9 +61,11 @@ Example: To set the automatic database cleanup process add this line to your .ht
|
||||||
* **max_processes_backend** - Maximum number of concurrent database processes for background tasks. Default value is 5.
|
* **max_processes_backend** - Maximum number of concurrent database processes for background tasks. Default value is 5.
|
||||||
* **max_processes_frontend** - Maximum number of concurrent database processes for foreground tasks. Default value is 20.
|
* **max_processes_frontend** - Maximum number of concurrent database processes for foreground tasks. Default value is 20.
|
||||||
* **min_poll_interval** - minimal distance in minutes between two polls for a contact. Default is 1. Reasonable values are between 1 and 59.
|
* **min_poll_interval** - minimal distance in minutes between two polls for a contact. Default is 1. Reasonable values are between 1 and 59.
|
||||||
* **memcache** (Boolean) - Use memcache. To use memcache the PECL extension "memcache" has to be installed and activated.
|
* **session_handler** (database|cache|native) - Whether to use Cache to store session data or to use PHP native session storage. Default value is `database`.
|
||||||
* **memcache_host** - Hostname of the memcache daemon. Default is '127.0.0.1'.
|
* **cache_driver** (database|memcache|memcached) - Whether to use Memcache or Memcached to store temporary cache. Default value is `database`.
|
||||||
* **memcache_port** - Portnumber of the memcache daemon. Default is 11211.
|
* **memcache_host** - Host name of the memcache daemon. Default is '127.0.0.1'.
|
||||||
|
* **memcache_port** - Port number of the memcache daemon. Default is 11211.
|
||||||
|
* **memcached_hosts** - Array of Memcached servers info `[host, port(, weight)]`. Default value is `[['127.0.0.1', 11211]]`.
|
||||||
* **no_count** (Boolean) - Don't do count calculations (currently only when showing albums)
|
* **no_count** (Boolean) - Don't do count calculations (currently only when showing albums)
|
||||||
* **no_oembed** (Boolean) - Don't use OEmbed to fetch more information about a link.
|
* **no_oembed** (Boolean) - Don't use OEmbed to fetch more information about a link.
|
||||||
* **no_smilies** (Boolean) - Don't show smilies.
|
* **no_smilies** (Boolean) - Don't show smilies.
|
||||||
|
@ -81,11 +85,6 @@ Example: To set the automatic database cleanup process add this line to your .ht
|
||||||
* **proxy_cache_time** - Time after which the cache is cleared. Default value is one day.
|
* **proxy_cache_time** - Time after which the cache is cleared. Default value is one day.
|
||||||
* **pushpoll_frequency** -
|
* **pushpoll_frequency** -
|
||||||
* **qsearch_limit** - Default value is 100.
|
* **qsearch_limit** - Default value is 100.
|
||||||
* **relay_server** - Experimental Diaspora feature. Address of the relay server where public posts should be send to. For example https://podrelay.net
|
|
||||||
* **relay_subscribe** (Boolean) - Enables the receiving of public posts from the relay. They will be included in the search and on the community page when it is set up to show all public items.
|
|
||||||
* **relay_scope** - Can be "all" or "tags". "all" means that every public post should be received. "tags" means that only posts with selected tags should be received.
|
|
||||||
* **relay_server_tags** - Comma separated list of tags for the "tags" subscription (see "relay_scrope")
|
|
||||||
* **relay_user_tags** (Boolean) - If enabled, the tags from the saved searches will used for the "tags" subscription in addition to the "relay_server_tags".
|
|
||||||
* **remove_multiplicated_lines** (Boolean) - If enabled, multiple linefeeds in items are stripped to a single one.
|
* **remove_multiplicated_lines** (Boolean) - If enabled, multiple linefeeds in items are stripped to a single one.
|
||||||
* **show_unsupported_addons** (Boolean) - Show all addons including the unsupported ones.
|
* **show_unsupported_addons** (Boolean) - Show all addons including the unsupported ones.
|
||||||
* **show_unsupported_themes** (Boolean) - Show all themes including the unsupported ones.
|
* **show_unsupported_themes** (Boolean) - Show all themes including the unsupported ones.
|
||||||
|
|
|
@ -11,16 +11,16 @@ Installation
|
||||||
|
|
||||||
- Change it's owner to whichever user is running the server, ie. ejabberd
|
- Change it's owner to whichever user is running the server, ie. ejabberd
|
||||||
|
|
||||||
$ chown ejabberd:ejabberd /path/to/friendica/include/auth_ejabberd.php
|
$ chown ejabberd:ejabberd /path/to/friendica/bin/auth_ejabberd.php
|
||||||
|
|
||||||
- Change the access mode so it is readable only to the user ejabberd and has exec
|
- Change the access mode so it is readable only to the user ejabberd and has exec
|
||||||
|
|
||||||
$ chmod 700 /path/to/friendica/include/auth_ejabberd.php
|
$ chmod 700 /path/to/friendica/bin/auth_ejabberd.php
|
||||||
|
|
||||||
- Edit your ejabberd.cfg file, comment out your auth_method and add:
|
- Edit your ejabberd.cfg file, comment out your auth_method and add:
|
||||||
|
|
||||||
{auth_method, external}.
|
{auth_method, external}.
|
||||||
{extauth_program, "/path/to/friendica/include/auth_ejabberd.php"}.
|
{extauth_program, "/path/to/friendica/bin/auth_ejabberd.php"}.
|
||||||
|
|
||||||
- Disable the module "mod_register" and disable the registration:
|
- Disable the module "mod_register" and disable the registration:
|
||||||
|
|
||||||
|
|
|
@ -29,20 +29,21 @@ The location of the translated files in the source tree is
|
||||||
/view/lang/LNG-CODE/
|
/view/lang/LNG-CODE/
|
||||||
where LNG-CODE is the language code used, e.g. de for German or fr for French.
|
where LNG-CODE is the language code used, e.g. de for German or fr for French.
|
||||||
The translated strings come as a "message.po" file from transifex which needs to be translated into the PHP file friendica uses.
|
The translated strings come as a "message.po" file from transifex which needs to be translated into the PHP file friendica uses.
|
||||||
To do so, place the file in the directory mentioned above and use the "po2php" utility from the util directory of your friendica installation.
|
To do so, place the file in the directory mentioned above and use the "po2php" command from the Friendica Console.
|
||||||
|
|
||||||
Assuming you want to convert the German localization which is placed in view/lang/de/message.po you would do the following.
|
Assuming you want to convert the German localization which is placed in view/lang/de/message.po you would do the following.
|
||||||
|
|
||||||
1. Navigate at the command prompt to the base directory of your
|
1. Navigate at the command prompt to the base directory of your
|
||||||
friendica installation
|
friendica installation
|
||||||
|
|
||||||
2. Execute the po2php script, which will place the translation
|
2. Execute the po2php command, which will place the translation
|
||||||
in the strings.php file that is used by friendica.
|
in the strings.php file that is used by friendica.
|
||||||
|
|
||||||
$> php util/po2php.php view/lang/de/messages.po
|
$> php bin/console.php po2php view/lang/de/messages.po
|
||||||
|
|
||||||
The output of the script will be placed at view/lang/de/strings.php where
|
The output of the script will be placed at view/lang/de/strings.php where
|
||||||
friendica is expecting it, so you can test your translation immediately.
|
friendica is expecting it, so you can test your translation immediately.
|
||||||
|
*Please note that the console tool has to be called from the base directory of your Friendica installation.*
|
||||||
|
|
||||||
3. Visit your friendica page to check if it still works in the language you
|
3. Visit your friendica page to check if it still works in the language you
|
||||||
just translated. If not try to find the error, most likely PHP will give
|
just translated. If not try to find the error, most likely PHP will give
|
||||||
|
@ -64,7 +65,7 @@ Otherwise your work might get lost, when the translation from Transifex is inclu
|
||||||
Utilities
|
Utilities
|
||||||
---------
|
---------
|
||||||
|
|
||||||
Additional to the po2php script there are some more utilities for translation in the "util" directory of the friendica source tree.
|
Additional to the po2php command there are some more utilities for translation in the console.
|
||||||
If you only want to translate friendica into another language you wont need any of these tools most likely but it gives you an idea how the translation process of friendica works.
|
If you only want to translate friendica into another language you wont need any of these tools most likely but it gives you an idea how the translation process of friendica works.
|
||||||
|
|
||||||
For further information see the utils/README file.
|
For further information see the utils/README file.
|
||||||
|
@ -92,9 +93,9 @@ To update the translation files after you have translated strings of e.g. Espera
|
||||||
|
|
||||||
$> tx pull -l eo
|
$> tx pull -l eo
|
||||||
|
|
||||||
And then use the `po2php` utility described above to convert the `messages.po` file to the `strings.php` file Friendica is loading.
|
And then use the `po2php` command described above to convert the `messages.po` file to the `strings.php` file Friendica is loading.
|
||||||
|
|
||||||
$> php util/po2php.php view/lang/eo/messages.po
|
$> php bin/console.php po2php view/lang/eo/messages.po
|
||||||
|
|
||||||
Afterwards, just commit the two changed files to a feature branch of your Friendica repository, push the changes to github and open a pull request for your changes.
|
Afterwards, just commit the two changed files to a feature branch of your Friendica repository, push the changes to github and open a pull request for your changes.
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -2,6 +2,11 @@
|
||||||
|
|
||||||
// If automatic system installation fails:
|
// If automatic system installation fails:
|
||||||
|
|
||||||
|
|
||||||
|
die('The configuration you did manually contains some mistakes. Please have a look at your .htconfig.php file.');
|
||||||
|
// If you are doing the configuration manually, please remove the line above
|
||||||
|
|
||||||
|
|
||||||
// Copy or rename this file to .htconfig.php
|
// Copy or rename this file to .htconfig.php
|
||||||
|
|
||||||
// Why .htconfig.php? Because it contains sensitive information which could
|
// Why .htconfig.php? Because it contains sensitive information which could
|
||||||
|
|
|
@ -1,755 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* @file include/acl_selectors.php
|
|
||||||
*/
|
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Content\Feature;
|
|
||||||
use Friendica\Content\Widget;
|
|
||||||
use Friendica\Core\Addon;
|
|
||||||
use Friendica\Core\Config;
|
|
||||||
use Friendica\Core\L10n;
|
|
||||||
use Friendica\Core\Protocol;
|
|
||||||
use Friendica\Database\DBM;
|
|
||||||
use Friendica\Model\Contact;
|
|
||||||
use Friendica\Model\GContact;
|
|
||||||
use Friendica\Util\Network;
|
|
||||||
|
|
||||||
require_once "mod/proxy.php";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package acl_selectors
|
|
||||||
*/
|
|
||||||
function group_select($selname,$selclass,$preselected = false,$size = 4) {
|
|
||||||
|
|
||||||
$a = get_app();
|
|
||||||
|
|
||||||
$o = '';
|
|
||||||
|
|
||||||
$o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" >\r\n";
|
|
||||||
|
|
||||||
$r = q("SELECT `id`, `name` FROM `group` WHERE NOT `deleted` AND `uid` = %d ORDER BY `name` ASC",
|
|
||||||
intval(local_user())
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
$arr = ['group' => $r, 'entry' => $o];
|
|
||||||
|
|
||||||
// e.g. 'network_pre_group_deny', 'profile_pre_group_allow'
|
|
||||||
|
|
||||||
Addon::callHooks($a->module . '_pre_' . $selname, $arr);
|
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
|
||||||
foreach ($r as $rr) {
|
|
||||||
if ((is_array($preselected)) && in_array($rr['id'], $preselected)) {
|
|
||||||
$selected = " selected=\"selected\" ";
|
|
||||||
} else {
|
|
||||||
$selected = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$trimmed = mb_substr($rr['name'],0,12);
|
|
||||||
|
|
||||||
$o .= "<option value=\"{$rr['id']}\" $selected title=\"{$rr['name']}\" >$trimmed</option>\r\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
$o .= "</select>\r\n";
|
|
||||||
|
|
||||||
Addon::callHooks($a->module . '_post_' . $selname, $o);
|
|
||||||
|
|
||||||
|
|
||||||
return $o;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @TODO find proper type-hints
|
|
||||||
function contact_selector($selname, $selclass, $options, $preselected = false)
|
|
||||||
{
|
|
||||||
$a = get_app();
|
|
||||||
|
|
||||||
$mutual = false;
|
|
||||||
$networks = null;
|
|
||||||
$single = false;
|
|
||||||
$exclude = false;
|
|
||||||
$size = 4;
|
|
||||||
|
|
||||||
if (is_array($options)) {
|
|
||||||
if (x($options, 'size'))
|
|
||||||
$size = $options['size'];
|
|
||||||
|
|
||||||
if (x($options, 'mutual_friends')) {
|
|
||||||
$mutual = true;
|
|
||||||
}
|
|
||||||
if (x($options, 'single')) {
|
|
||||||
$single = true;
|
|
||||||
}
|
|
||||||
if (x($options, 'multiple')) {
|
|
||||||
$single = false;
|
|
||||||
}
|
|
||||||
if (x($options, 'exclude')) {
|
|
||||||
$exclude = $options['exclude'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (x($options, 'networks')) {
|
|
||||||
switch ($options['networks']) {
|
|
||||||
case 'DFRN_ONLY':
|
|
||||||
$networks = [NETWORK_DFRN];
|
|
||||||
break;
|
|
||||||
case 'PRIVATE':
|
|
||||||
if (is_array($a->user) && $a->user['prvnets']) {
|
|
||||||
$networks = [NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA];
|
|
||||||
} else {
|
|
||||||
$networks = [NETWORK_DFRN, NETWORK_FACEBOOK, NETWORK_MAIL, NETWORK_DIASPORA];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'TWO_WAY':
|
|
||||||
if (is_array($a->user) && $a->user['prvnets']) {
|
|
||||||
$networks = [NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA];
|
|
||||||
} else {
|
|
||||||
$networks = [NETWORK_DFRN, NETWORK_FACEBOOK, NETWORK_MAIL, NETWORK_DIASPORA, NETWORK_OSTATUS];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default: /// @TODO Maybe log this call?
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$x = ['options' => $options, 'size' => $size, 'single' => $single, 'mutual' => $mutual, 'exclude' => $exclude, 'networks' => $networks];
|
|
||||||
|
|
||||||
Addon::callHooks('contact_select_options', $x);
|
|
||||||
|
|
||||||
$o = '';
|
|
||||||
|
|
||||||
$sql_extra = '';
|
|
||||||
|
|
||||||
if (x($x, 'mutual')) {
|
|
||||||
$sql_extra .= sprintf(" AND `rel` = %d ", intval(CONTACT_IS_FRIEND));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (x($x, 'exclude')) {
|
|
||||||
$sql_extra .= sprintf(" AND `id` != %d ", intval($x['exclude']));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_array($x['networks']) && count($x['networks'])) {
|
|
||||||
/// @TODO rewrite to foreach()
|
|
||||||
for ($y = 0; $y < count($x['networks']) ; $y ++) {
|
|
||||||
$x['networks'][$y] = "'" . dbesc($x['networks'][$y]) . "'";
|
|
||||||
}
|
|
||||||
$str_nets = implode(',', $x['networks']);
|
|
||||||
$sql_extra .= " AND `network` IN ( $str_nets ) ";
|
|
||||||
}
|
|
||||||
|
|
||||||
$tabindex = (x($options, 'tabindex') ? "tabindex=\"" . $options["tabindex"] . "\"" : "");
|
|
||||||
|
|
||||||
if ($x['single']) {
|
|
||||||
$o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"" . $x['size'] . "\" $tabindex >\r\n";
|
|
||||||
} else {
|
|
||||||
$o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"" . $x['size'] . "$\" $tabindex >\r\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
$r = q("SELECT `id`, `name`, `url`, `network` FROM `contact`
|
|
||||||
WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
|
|
||||||
$sql_extra
|
|
||||||
ORDER BY `name` ASC ",
|
|
||||||
intval(local_user())
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
$arr = ['contact' => $r, 'entry' => $o];
|
|
||||||
|
|
||||||
// e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow'
|
|
||||||
|
|
||||||
Addon::callHooks($a->module . '_pre_' . $selname, $arr);
|
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
|
||||||
foreach ($r as $rr) {
|
|
||||||
if ((is_array($preselected)) && in_array($rr['id'], $preselected)) {
|
|
||||||
$selected = " selected=\"selected\" ";
|
|
||||||
} else {
|
|
||||||
$selected = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$trimmed = mb_substr($rr['name'],0,20);
|
|
||||||
|
|
||||||
$o .= "<option value=\"{$rr['id']}\" $selected title=\"{$rr['name']}|{$rr['url']}\" >$trimmed</option>\r\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$o .= "</select>\r\n";
|
|
||||||
|
|
||||||
Addon::callHooks($a->module . '_post_' . $selname, $o);
|
|
||||||
|
|
||||||
return $o;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function contact_select($selname, $selclass, $preselected = false, $size = 4, $privmail = false, $celeb = false, $privatenet = false, $tabindex = null) {
|
|
||||||
$a = get_app();
|
|
||||||
|
|
||||||
$o = '';
|
|
||||||
|
|
||||||
// When used for private messages, we limit correspondence to mutual DFRN/Friendica friends and the selector
|
|
||||||
// to one recipient. By default our selector allows multiple selects amongst all contacts.
|
|
||||||
|
|
||||||
$sql_extra = '';
|
|
||||||
|
|
||||||
if ($privmail || $celeb) {
|
|
||||||
$sql_extra .= sprintf(" AND `rel` = %d ", intval(CONTACT_IS_FRIEND));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($privmail) {
|
|
||||||
$sql_extra .= sprintf(" AND `network` IN ('%s' , '%s') ",
|
|
||||||
NETWORK_DFRN, NETWORK_DIASPORA);
|
|
||||||
} elseif ($privatenet) {
|
|
||||||
$sql_extra .= sprintf(" AND `network` IN ('%s' , '%s', '%s', '%s') ",
|
|
||||||
NETWORK_DFRN, NETWORK_MAIL, NETWORK_FACEBOOK, NETWORK_DIASPORA);
|
|
||||||
}
|
|
||||||
|
|
||||||
$tabindex = ($tabindex > 0 ? "tabindex=\"$tabindex\"" : "");
|
|
||||||
|
|
||||||
if ($privmail && $preselected) {
|
|
||||||
$sql_extra .= " AND `id` IN (".implode(",", $preselected).")";
|
|
||||||
$hidepreselected = ' style="display: none;"';
|
|
||||||
} else {
|
|
||||||
$hidepreselected = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($privmail) {
|
|
||||||
$o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"$size\" $tabindex $hidepreselected>\r\n";
|
|
||||||
} else {
|
|
||||||
$o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" $tabindex >\r\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
$r = q("SELECT `id`, `name`, `url`, `network` FROM `contact`
|
|
||||||
WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
|
|
||||||
$sql_extra
|
|
||||||
ORDER BY `name` ASC ",
|
|
||||||
intval(local_user())
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
$arr = ['contact' => $r, 'entry' => $o];
|
|
||||||
|
|
||||||
// e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow'
|
|
||||||
|
|
||||||
Addon::callHooks($a->module . '_pre_' . $selname, $arr);
|
|
||||||
|
|
||||||
$receiverlist = [];
|
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
|
||||||
foreach ($r as $rr) {
|
|
||||||
if ((is_array($preselected)) && in_array($rr['id'], $preselected)) {
|
|
||||||
$selected = " selected=\"selected\" ";
|
|
||||||
} else {
|
|
||||||
$selected = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($privmail) {
|
|
||||||
$trimmed = Protocol::formatMention($rr['url'], $rr['name']);
|
|
||||||
} else {
|
|
||||||
$trimmed = mb_substr($rr['name'],0,20);
|
|
||||||
}
|
|
||||||
|
|
||||||
$receiverlist[] = $trimmed;
|
|
||||||
|
|
||||||
$o .= "<option value=\"{$rr['id']}\" $selected title=\"{$rr['name']}|{$rr['url']}\" >$trimmed</option>\r\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$o .= "</select>\r\n";
|
|
||||||
|
|
||||||
if ($privmail && $preselected) {
|
|
||||||
$o .= implode(", ", $receiverlist);
|
|
||||||
}
|
|
||||||
|
|
||||||
Addon::callHooks($a->module . '_post_' . $selname, $o);
|
|
||||||
|
|
||||||
return $o;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function fixacl(&$item) {
|
|
||||||
$item = intval(str_replace(['<', '>'], ['', ''], $item));
|
|
||||||
}
|
|
||||||
|
|
||||||
function prune_deadguys($arr) {
|
|
||||||
|
|
||||||
if (! $arr) {
|
|
||||||
return $arr;
|
|
||||||
}
|
|
||||||
|
|
||||||
$str = dbesc(implode(',', $arr));
|
|
||||||
|
|
||||||
$r = q("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 ");
|
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
|
||||||
$ret = [];
|
|
||||||
foreach ($r as $rr) {
|
|
||||||
$ret[] = intval($rr['id']);
|
|
||||||
}
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function get_acl_permissions($user = null) {
|
|
||||||
$allow_cid = $allow_gid = $deny_cid = $deny_gid = false;
|
|
||||||
|
|
||||||
if (is_array($user)) {
|
|
||||||
$allow_cid = ((strlen($user['allow_cid']))
|
|
||||||
? explode('><', $user['allow_cid']) : [] );
|
|
||||||
$allow_gid = ((strlen($user['allow_gid']))
|
|
||||||
? explode('><', $user['allow_gid']) : [] );
|
|
||||||
$deny_cid = ((strlen($user['deny_cid']))
|
|
||||||
? explode('><', $user['deny_cid']) : [] );
|
|
||||||
$deny_gid = ((strlen($user['deny_gid']))
|
|
||||||
? explode('><', $user['deny_gid']) : [] );
|
|
||||||
array_walk($allow_cid,'fixacl');
|
|
||||||
array_walk($allow_gid,'fixacl');
|
|
||||||
array_walk($deny_cid,'fixacl');
|
|
||||||
array_walk($deny_gid,'fixacl');
|
|
||||||
}
|
|
||||||
|
|
||||||
$allow_cid = prune_deadguys($allow_cid);
|
|
||||||
|
|
||||||
return [
|
|
||||||
'allow_cid' => $allow_cid,
|
|
||||||
'allow_gid' => $allow_gid,
|
|
||||||
'deny_cid' => $deny_cid,
|
|
||||||
'deny_gid' => $deny_gid,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function populate_acl($user = null, $show_jotnets = false) {
|
|
||||||
|
|
||||||
$perms = get_acl_permissions($user);
|
|
||||||
|
|
||||||
$jotnets = '';
|
|
||||||
if ($show_jotnets) {
|
|
||||||
$mail_disabled = ((function_exists('imap_open') && (! Config::get('system','imap_disabled'))) ? 0 : 1);
|
|
||||||
|
|
||||||
$mail_enabled = false;
|
|
||||||
$pubmail_enabled = false;
|
|
||||||
|
|
||||||
if (! $mail_disabled) {
|
|
||||||
$r = q("SELECT `pubmail` FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
|
|
||||||
intval(local_user())
|
|
||||||
);
|
|
||||||
if (DBM::is_result($r)) {
|
|
||||||
$mail_enabled = true;
|
|
||||||
if (intval($r[0]['pubmail'])) {
|
|
||||||
$pubmail_enabled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$user['hidewall']) {
|
|
||||||
if ($mail_enabled) {
|
|
||||||
$selected = (($pubmail_enabled) ? ' checked="checked" ' : '');
|
|
||||||
$jotnets .= '<div class="profile-jot-net"><input type="checkbox" name="pubmail_enable"' . $selected . ' value="1" /> ' . L10n::t("Post to Email") . '</div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
Addon::callHooks('jot_networks', $jotnets);
|
|
||||||
} else {
|
|
||||||
$jotnets .= L10n::t('Connectors disabled, since "%s" is enabled.', L10n::t('Hide your profile details from unknown viewers?'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$tpl = get_markup_template("acl_selector.tpl");
|
|
||||||
$o = replace_macros($tpl, [
|
|
||||||
'$showall'=> L10n::t("Visible to everybody"),
|
|
||||||
'$show' => L10n::t("show"),
|
|
||||||
'$hide' => L10n::t("don't show"),
|
|
||||||
'$allowcid' => json_encode($perms['allow_cid']),
|
|
||||||
'$allowgid' => json_encode($perms['allow_gid']),
|
|
||||||
'$denycid' => json_encode($perms['deny_cid']),
|
|
||||||
'$denygid' => json_encode($perms['deny_gid']),
|
|
||||||
'$networks' => $show_jotnets,
|
|
||||||
'$emailcc' => L10n::t('CC: email addresses'),
|
|
||||||
'$emtitle' => L10n::t('Example: bob@example.com, mary@example.com'),
|
|
||||||
'$jotnets' => $jotnets,
|
|
||||||
'$aclModalTitle' => L10n::t('Permissions'),
|
|
||||||
'$aclModalDismiss' => L10n::t('Close'),
|
|
||||||
'$features' => [
|
|
||||||
'aclautomention' => (Feature::isEnabled($user['uid'], "aclautomention") ? "true" : "false")
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
|
|
||||||
|
|
||||||
return $o;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function acl_lookup(App $a, $out_type = 'json')
|
|
||||||
{
|
|
||||||
if (!local_user()) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$start = defaults($_REQUEST, 'start' , 0);
|
|
||||||
$count = defaults($_REQUEST, 'count' , 100);
|
|
||||||
$search = defaults($_REQUEST, 'search' , '');
|
|
||||||
$type = defaults($_REQUEST, 'type' , '');
|
|
||||||
$conv_id = defaults($_REQUEST, 'conversation', null);
|
|
||||||
|
|
||||||
// For use with jquery.textcomplete for private mail completion
|
|
||||||
if (x($_REQUEST, 'query')) {
|
|
||||||
if (! $type) {
|
|
||||||
$type = 'm';
|
|
||||||
}
|
|
||||||
$search = $_REQUEST['query'];
|
|
||||||
}
|
|
||||||
|
|
||||||
logger("Searching for ".$search." - type ".$type." conversation ".$conv_id, LOGGER_DEBUG);
|
|
||||||
|
|
||||||
if ($search != '') {
|
|
||||||
$sql_extra = "AND `name` LIKE '%%".dbesc($search)."%%'";
|
|
||||||
$sql_extra2 = "AND (`attag` LIKE '%%".dbesc($search)."%%' OR `name` LIKE '%%".dbesc($search)."%%' OR `nick` LIKE '%%".dbesc($search)."%%')";
|
|
||||||
} else {
|
|
||||||
/// @TODO Avoid these needless else blocks by putting variable-initialization atop of if()
|
|
||||||
$sql_extra = $sql_extra2 = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
// count groups and contacts
|
|
||||||
if ($type == '' || $type == 'g') {
|
|
||||||
$r = q("SELECT COUNT(*) AS g FROM `group` WHERE `deleted` = 0 AND `uid` = %d $sql_extra",
|
|
||||||
intval(local_user())
|
|
||||||
);
|
|
||||||
$group_count = (int)$r[0]['g'];
|
|
||||||
} else {
|
|
||||||
$group_count = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql_extra2 .= " ".Widget::unavailableNetworks();
|
|
||||||
|
|
||||||
if ($type == '' || $type == 'c') {
|
|
||||||
// autocomplete for editor mentions
|
|
||||||
$r = q("SELECT COUNT(*) AS c FROM `contact`
|
|
||||||
WHERE `uid` = %d AND NOT `self`
|
|
||||||
AND NOT `blocked` AND NOT `pending` AND NOT `archive`
|
|
||||||
AND `success_update` >= `failure_update`
|
|
||||||
AND `notify` != '' $sql_extra2" ,
|
|
||||||
intval(local_user())
|
|
||||||
);
|
|
||||||
$contact_count = (int)$r[0]['c'];
|
|
||||||
} elseif ($type == 'f') {
|
|
||||||
// autocomplete for editor mentions of forums
|
|
||||||
$r = q("SELECT COUNT(*) AS c FROM `contact`
|
|
||||||
WHERE `uid` = %d AND NOT `self`
|
|
||||||
AND NOT `blocked` AND NOT `pending` AND NOT `archive`
|
|
||||||
AND (`forum` OR `prv`)
|
|
||||||
AND `success_update` >= `failure_update`
|
|
||||||
AND `notify` != '' $sql_extra2" ,
|
|
||||||
intval(local_user())
|
|
||||||
);
|
|
||||||
$contact_count = (int)$r[0]['c'];
|
|
||||||
} elseif ($type == 'm') {
|
|
||||||
// autocomplete for Private Messages
|
|
||||||
$r = q("SELECT COUNT(*) AS c FROM `contact`
|
|
||||||
WHERE `uid` = %d AND NOT `self`
|
|
||||||
AND NOT `blocked` AND NOT `pending` AND NOT `archive`
|
|
||||||
AND `success_update` >= `failure_update`
|
|
||||||
AND `network` IN ('%s', '%s') $sql_extra2" ,
|
|
||||||
intval(local_user()),
|
|
||||||
dbesc(NETWORK_DFRN),
|
|
||||||
dbesc(NETWORK_DIASPORA)
|
|
||||||
);
|
|
||||||
$contact_count = (int)$r[0]['c'];
|
|
||||||
|
|
||||||
} elseif ($type == 'a') {
|
|
||||||
// autocomplete for Contacts
|
|
||||||
$r = q("SELECT COUNT(*) AS c FROM `contact`
|
|
||||||
WHERE `uid` = %d AND NOT `self`
|
|
||||||
AND NOT `pending` $sql_extra2" ,
|
|
||||||
intval(local_user())
|
|
||||||
);
|
|
||||||
$contact_count = (int)$r[0]['c'];
|
|
||||||
} else {
|
|
||||||
$contact_count = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$tot = $group_count + $contact_count;
|
|
||||||
|
|
||||||
$groups = [];
|
|
||||||
$contacts = [];
|
|
||||||
|
|
||||||
if ($type == '' || $type == 'g') {
|
|
||||||
/// @todo We should cache this query.
|
|
||||||
// This can be done when we can delete cache entries via wildcard
|
|
||||||
$r = q("SELECT `group`.`id`, `group`.`name`, GROUP_CONCAT(DISTINCT `group_member`.`contact-id` SEPARATOR ',') AS uids
|
|
||||||
FROM `group`
|
|
||||||
INNER JOIN `group_member` ON `group_member`.`gid`=`group`.`id`
|
|
||||||
WHERE NOT `group`.`deleted` AND `group`.`uid` = %d
|
|
||||||
$sql_extra
|
|
||||||
GROUP BY `group`.`name`, `group`.`id`
|
|
||||||
ORDER BY `group`.`name`
|
|
||||||
LIMIT %d,%d",
|
|
||||||
intval(local_user()),
|
|
||||||
intval($start),
|
|
||||||
intval($count)
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($r as $g) {
|
|
||||||
$groups[] = [
|
|
||||||
"type" => "g",
|
|
||||||
"photo" => "images/twopeople.png",
|
|
||||||
"name" => htmlentities($g['name']),
|
|
||||||
"id" => intval($g['id']),
|
|
||||||
"uids" => array_map("intval", explode(",",$g['uids'])),
|
|
||||||
"link" => '',
|
|
||||||
"forum" => '0'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
if ((count($groups) > 0) && ($search == "")) {
|
|
||||||
$groups[] = ["separator" => true];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($type == '') {
|
|
||||||
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv`, (`prv` OR `forum`) AS `frm` FROM `contact`
|
|
||||||
WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
|
|
||||||
AND `success_update` >= `failure_update` AND NOT (`network` IN ('%s', '%s'))
|
|
||||||
$sql_extra2
|
|
||||||
ORDER BY `name` ASC ",
|
|
||||||
intval(local_user()),
|
|
||||||
dbesc(NETWORK_OSTATUS), dbesc(NETWORK_STATUSNET)
|
|
||||||
);
|
|
||||||
} elseif ($type == 'c') {
|
|
||||||
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv` FROM `contact`
|
|
||||||
WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
|
|
||||||
AND `success_update` >= `failure_update` AND NOT (`network` IN ('%s'))
|
|
||||||
$sql_extra2
|
|
||||||
ORDER BY `name` ASC ",
|
|
||||||
intval(local_user()),
|
|
||||||
dbesc(NETWORK_STATUSNET)
|
|
||||||
);
|
|
||||||
} elseif ($type == 'f') {
|
|
||||||
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv` FROM `contact`
|
|
||||||
WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
|
|
||||||
AND `success_update` >= `failure_update` AND NOT (`network` IN ('%s'))
|
|
||||||
AND (`forum` OR `prv`)
|
|
||||||
$sql_extra2
|
|
||||||
ORDER BY `name` ASC ",
|
|
||||||
intval(local_user()),
|
|
||||||
dbesc(NETWORK_STATUSNET)
|
|
||||||
);
|
|
||||||
} elseif ($type == 'm') {
|
|
||||||
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr` FROM `contact`
|
|
||||||
WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive`
|
|
||||||
AND `success_update` >= `failure_update` AND `network` IN ('%s', '%s')
|
|
||||||
$sql_extra2
|
|
||||||
ORDER BY `name` ASC ",
|
|
||||||
intval(local_user()),
|
|
||||||
dbesc(NETWORK_DFRN),
|
|
||||||
dbesc(NETWORK_DIASPORA)
|
|
||||||
);
|
|
||||||
} elseif ($type == 'a') {
|
|
||||||
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv` FROM `contact`
|
|
||||||
WHERE `uid` = %d AND `pending` = 0 AND `success_update` >= `failure_update`
|
|
||||||
$sql_extra2
|
|
||||||
ORDER BY `name` ASC ",
|
|
||||||
intval(local_user())
|
|
||||||
);
|
|
||||||
} elseif ($type == 'x') {
|
|
||||||
// autocomplete for global contact search (e.g. navbar search)
|
|
||||||
$r = navbar_complete($a);
|
|
||||||
$contacts = [];
|
|
||||||
if ($r) {
|
|
||||||
foreach ($r as $g) {
|
|
||||||
$contacts[] = [
|
|
||||||
'photo' => proxy_url($g['photo'], false, PROXY_SIZE_MICRO),
|
|
||||||
'name' => $g['name'],
|
|
||||||
'nick' => (x($g['addr']) ? $g['addr'] : $g['url']),
|
|
||||||
'network' => $g['network'],
|
|
||||||
'link' => $g['url'],
|
|
||||||
'forum' => (x($g['community']) ? 1 : 0),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$o = [
|
|
||||||
'start' => $start,
|
|
||||||
'count' => $count,
|
|
||||||
'items' => $contacts,
|
|
||||||
];
|
|
||||||
echo json_encode($o);
|
|
||||||
killme();
|
|
||||||
} else {
|
|
||||||
$r = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
|
||||||
$forums = [];
|
|
||||||
foreach ($r as $g) {
|
|
||||||
$entry = [
|
|
||||||
'type' => 'c',
|
|
||||||
'photo' => proxy_url($g['micro'], false, PROXY_SIZE_MICRO),
|
|
||||||
'name' => htmlentities($g['name']),
|
|
||||||
'id' => intval($g['id']),
|
|
||||||
'network' => $g['network'],
|
|
||||||
'link' => $g['url'],
|
|
||||||
'nick' => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']),
|
|
||||||
'addr' => htmlentities(($g['addr']) ? $g['addr'] : $g['url']),
|
|
||||||
'forum' => ((x($g, 'forum') || x($g, 'prv')) ? 1 : 0),
|
|
||||||
];
|
|
||||||
if ($entry['forum']) {
|
|
||||||
$forums[] = $entry;
|
|
||||||
} else {
|
|
||||||
$contacts[] = $entry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (count($forums) > 0) {
|
|
||||||
if ($search == "") {
|
|
||||||
$forums[] = ["separator" => true];
|
|
||||||
}
|
|
||||||
$contacts = array_merge($forums, $contacts);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$items = array_merge($groups, $contacts);
|
|
||||||
|
|
||||||
// At multi threaded posts the conv_id is not the parent of the whole thread
|
|
||||||
if ($conv_id > 0) {
|
|
||||||
$parent_item = dba::selectFirst('item', ['parent'], ['id' => $conv_id]);
|
|
||||||
if (DBM::is_result($parent_item)) {
|
|
||||||
$conv_id = $parent_item['parent'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($conv_id) {
|
|
||||||
/*
|
|
||||||
* if $conv_id is set, get unknown contacts in thread
|
|
||||||
* but first get known contacts url to filter them out
|
|
||||||
*/
|
|
||||||
$known_contacts = array_map(
|
|
||||||
function ($i) {
|
|
||||||
return dbesc($i['link']);
|
|
||||||
}
|
|
||||||
, $contacts);
|
|
||||||
|
|
||||||
$unknown_contacts = [];
|
|
||||||
$r = q("SELECT `author-link`
|
|
||||||
FROM `item` WHERE `parent` = %d
|
|
||||||
AND (`author-name` LIKE '%%%s%%' OR `author-link` LIKE '%%%s%%')
|
|
||||||
AND `author-link` NOT IN ('%s')
|
|
||||||
GROUP BY `author-link`, `author-avatar`, `author-name`
|
|
||||||
ORDER BY `author-name` ASC
|
|
||||||
",
|
|
||||||
intval($conv_id),
|
|
||||||
dbesc($search),
|
|
||||||
dbesc($search),
|
|
||||||
implode("', '", $known_contacts)
|
|
||||||
);
|
|
||||||
if (DBM::is_result($r)) {
|
|
||||||
foreach ($r as $row) {
|
|
||||||
$contact = Contact::getDetailsByURL($row['author-link']);
|
|
||||||
|
|
||||||
if (count($contact) > 0) {
|
|
||||||
$unknown_contacts[] = [
|
|
||||||
'type' => 'c',
|
|
||||||
'photo' => proxy_url($contact['micro'], false, PROXY_SIZE_MICRO),
|
|
||||||
'name' => htmlentities($contact['name']),
|
|
||||||
'id' => intval($contact['cid']),
|
|
||||||
'network' => $contact['network'],
|
|
||||||
'link' => $contact['url'],
|
|
||||||
'nick' => htmlentities($contact['nick'] ? : $contact['addr']),
|
|
||||||
'addr' => htmlentities(($contact['addr']) ? $contact['addr'] : $contact['url']),
|
|
||||||
'forum' => $contact['forum']
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$items = array_merge($items, $unknown_contacts);
|
|
||||||
$tot += count($unknown_contacts);
|
|
||||||
}
|
|
||||||
|
|
||||||
$results = [
|
|
||||||
'tot' => $tot,
|
|
||||||
'start' => $start,
|
|
||||||
'count' => $count,
|
|
||||||
'groups' => $groups,
|
|
||||||
'contacts' => $contacts,
|
|
||||||
'items' => $items,
|
|
||||||
'type' => $type,
|
|
||||||
'search' => $search,
|
|
||||||
];
|
|
||||||
|
|
||||||
Addon::callHooks('acl_lookup_end', $results);
|
|
||||||
|
|
||||||
if ($out_type === 'html') {
|
|
||||||
$o = [
|
|
||||||
'tot' => $results['tot'],
|
|
||||||
'start' => $results['start'],
|
|
||||||
'count' => $results['count'],
|
|
||||||
'groups' => $results['groups'],
|
|
||||||
'contacts' => $results['contacts'],
|
|
||||||
];
|
|
||||||
return $o;
|
|
||||||
}
|
|
||||||
|
|
||||||
$o = [
|
|
||||||
'tot' => $results['tot'],
|
|
||||||
'start' => $results['start'],
|
|
||||||
'count' => $results['count'],
|
|
||||||
'items' => $results['items'],
|
|
||||||
];
|
|
||||||
|
|
||||||
echo json_encode($o);
|
|
||||||
|
|
||||||
killme();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Searching for global contacts for autocompletion
|
|
||||||
*
|
|
||||||
* @param App $a
|
|
||||||
* @return array with the search results
|
|
||||||
*/
|
|
||||||
function navbar_complete(App $a) {
|
|
||||||
|
|
||||||
// logger('navbar_complete');
|
|
||||||
|
|
||||||
if ((Config::get('system','block_public')) && (! local_user()) && (! remote_user())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if searching in the local global contact table is enabled
|
|
||||||
$localsearch = Config::get('system','poco_local_search');
|
|
||||||
|
|
||||||
$search = notags(trim($_REQUEST['search']));
|
|
||||||
$mode = $_REQUEST['smode'];
|
|
||||||
|
|
||||||
// don't search if search term has less than 2 characters
|
|
||||||
if (! $search || mb_strlen($search) < 2) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (substr($search,0,1) === '@') {
|
|
||||||
$search = substr($search,1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($localsearch) {
|
|
||||||
$x = GContact::searchByName($search, $mode);
|
|
||||||
return $x;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $localsearch) {
|
|
||||||
$p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : '');
|
|
||||||
|
|
||||||
$x = Network::curl(get_server() . '/lsearch?f=' . $p . '&search=' . urlencode($search));
|
|
||||||
if ($x['success']) {
|
|
||||||
$j = json_decode($x['body'],true);
|
|
||||||
if ($j && isset($j['results'])) {
|
|
||||||
return $j['results'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @TODO Not needed here?
|
|
||||||
return;
|
|
||||||
}
|
|
|
@ -10,6 +10,7 @@ use Friendica\App;
|
||||||
use Friendica\Content\ContactSelector;
|
use Friendica\Content\ContactSelector;
|
||||||
use Friendica\Content\Feature;
|
use Friendica\Content\Feature;
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
|
use Friendica\Content\Text\HTML;
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
|
@ -41,11 +42,9 @@ use Friendica\Util\Network;
|
||||||
use Friendica\Util\XML;
|
use Friendica\Util\XML;
|
||||||
|
|
||||||
require_once 'include/conversation.php';
|
require_once 'include/conversation.php';
|
||||||
require_once 'include/html2plain.php';
|
|
||||||
require_once 'mod/share.php';
|
require_once 'mod/share.php';
|
||||||
require_once 'mod/item.php';
|
require_once 'mod/item.php';
|
||||||
require_once 'include/security.php';
|
require_once 'include/security.php';
|
||||||
require_once 'include/html2bbcode.php';
|
|
||||||
require_once 'mod/wall_upload.php';
|
require_once 'mod/wall_upload.php';
|
||||||
require_once 'mod/proxy.php';
|
require_once 'mod/proxy.php';
|
||||||
|
|
||||||
|
@ -317,12 +316,16 @@ function api_call(App $a)
|
||||||
/// @TODO round() really everywhere?
|
/// @TODO round() really everywhere?
|
||||||
logger(
|
logger(
|
||||||
parse_url($a->query_string, PHP_URL_PATH) . ": " . sprintf(
|
parse_url($a->query_string, PHP_URL_PATH) . ": " . sprintf(
|
||||||
"Database: %s/%s, Network: %s, I/O: %s, Other: %s, Total: %s",
|
"Database: %s/%s, Cache %s/%s, Network: %s, I/O: %s, Other: %s, Total: %s",
|
||||||
round($a->performance["database"] - $a->performance["database_write"], 3),
|
round($a->performance["database"] - $a->performance["database_write"], 3),
|
||||||
round($a->performance["database_write"], 3),
|
round($a->performance["database_write"], 3),
|
||||||
|
round($a->performance["cache"], 3),
|
||||||
|
round($a->performance["cache_write"], 3),
|
||||||
round($a->performance["network"], 2),
|
round($a->performance["network"], 2),
|
||||||
round($a->performance["file"], 2),
|
round($a->performance["file"], 2),
|
||||||
round($duration - ($a->performance["database"] + $a->performance["network"] + $a->performance["file"]), 2),
|
round($duration - ($a->performance["database"]
|
||||||
|
+ $a->performance["cache"] + $a->performance["cache_write"]
|
||||||
|
+ $a->performance["network"] + $a->performance["file"]), 2),
|
||||||
round($duration, 2)
|
round($duration, 2)
|
||||||
),
|
),
|
||||||
LOGGER_DEBUG
|
LOGGER_DEBUG
|
||||||
|
@ -344,6 +347,21 @@ function api_call(App $a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$o = "Cache Read:\n";
|
||||||
|
foreach ($a->callstack["cache"] as $func => $time) {
|
||||||
|
$time = round($time, 3);
|
||||||
|
if ($time > 0) {
|
||||||
|
$o .= $func . ": " . $time . "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$o .= "\nCache Write:\n";
|
||||||
|
foreach ($a->callstack["cache_write"] as $func => $time) {
|
||||||
|
$time = round($time, 3);
|
||||||
|
if ($time > 0) {
|
||||||
|
$o .= $func . ": " . $time . "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$o .= "\nNetwork:\n";
|
$o .= "\nNetwork:\n";
|
||||||
foreach ($a->callstack["network"] as $func => $time) {
|
foreach ($a->callstack["network"] as $func => $time) {
|
||||||
$time = round($time, 3);
|
$time = round($time, 3);
|
||||||
|
@ -1077,7 +1095,7 @@ function api_statuses_mediap($type)
|
||||||
$purifier = new HTMLPurifier($config);
|
$purifier = new HTMLPurifier($config);
|
||||||
$txt = $purifier->purify($txt);
|
$txt = $purifier->purify($txt);
|
||||||
}
|
}
|
||||||
$txt = html2bbcode($txt);
|
$txt = HTML::toBBCode($txt);
|
||||||
|
|
||||||
$a->argv[1]=$user_info['screen_name']; //should be set to username?
|
$a->argv[1]=$user_info['screen_name']; //should be set to username?
|
||||||
|
|
||||||
|
@ -1128,7 +1146,7 @@ function api_statuses_update($type)
|
||||||
$purifier = new HTMLPurifier($config);
|
$purifier = new HTMLPurifier($config);
|
||||||
$txt = $purifier->purify($txt);
|
$txt = $purifier->purify($txt);
|
||||||
|
|
||||||
$_REQUEST['body'] = html2bbcode($txt);
|
$_REQUEST['body'] = HTML::toBBCode($txt);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$_REQUEST['body'] = requestdata('status');
|
$_REQUEST['body'] = requestdata('status');
|
||||||
|
@ -2605,10 +2623,10 @@ function api_format_messages($item, $recipient, $sender)
|
||||||
if ($_GET['getText'] == 'html') {
|
if ($_GET['getText'] == 'html') {
|
||||||
$ret['text'] = BBCode::convert($item['body'], false);
|
$ret['text'] = BBCode::convert($item['body'], false);
|
||||||
} elseif ($_GET['getText'] == 'plain') {
|
} elseif ($_GET['getText'] == 'plain') {
|
||||||
$ret['text'] = trim(html2plain(BBCode::convert(api_clean_plain_items($item['body']), false, 2, true), 0));
|
$ret['text'] = trim(HTML::toPlaintext(BBCode::convert(api_clean_plain_items($item['body']), false, 2, true), 0));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$ret['text'] = $item['title'] . "\n" . html2plain(BBCode::convert(api_clean_plain_items($item['body']), false, 2, true), 0);
|
$ret['text'] = $item['title'] . "\n" . HTML::toPlaintext(BBCode::convert(api_clean_plain_items($item['body']), false, 2, true), 0);
|
||||||
}
|
}
|
||||||
if (x($_GET, 'getUserObjects') && $_GET['getUserObjects'] == 'false') {
|
if (x($_GET, 'getUserObjects') && $_GET['getUserObjects'] == 'false') {
|
||||||
unset($ret['sender']);
|
unset($ret['sender']);
|
||||||
|
@ -2631,7 +2649,7 @@ function api_convert_item($item)
|
||||||
|
|
||||||
// Workaround for ostatus messages where the title is identically to the body
|
// Workaround for ostatus messages where the title is identically to the body
|
||||||
$html = BBCode::convert(api_clean_plain_items($body), false, 2, true);
|
$html = BBCode::convert(api_clean_plain_items($body), false, 2, true);
|
||||||
$statusbody = trim(html2plain($html, 0));
|
$statusbody = trim(HTML::toPlaintext($html, 0));
|
||||||
|
|
||||||
// handle data: images
|
// handle data: images
|
||||||
$statusbody = api_format_items_embeded_images($item, $statusbody);
|
$statusbody = api_format_items_embeded_images($item, $statusbody);
|
||||||
|
|
|
@ -1,264 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Friendica\Content\Text\BBCode;
|
|
||||||
use Friendica\Content\Text\Markdown;
|
|
||||||
use Friendica\Core\Addon;
|
|
||||||
use Friendica\Core\L10n;
|
|
||||||
use Friendica\Core\System;
|
|
||||||
use Friendica\Model\Contact;
|
|
||||||
use Friendica\Network\Probe;
|
|
||||||
use Friendica\Util\DateTimeFormat;
|
|
||||||
use League\HTMLToMarkdown\HtmlConverter;
|
|
||||||
|
|
||||||
require_once 'include/event.php';
|
|
||||||
require_once 'include/html2bbcode.php';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Callback function to replace a Diaspora style mention in a mention for Friendica
|
|
||||||
*
|
|
||||||
* @param array $match Matching values for the callback
|
|
||||||
* @return string Replaced mention
|
|
||||||
*/
|
|
||||||
function diaspora_mention2bb($match) {
|
|
||||||
if ($match[2] == '') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = Contact::getDetailsByAddr($match[2]);
|
|
||||||
|
|
||||||
$name = $match[1];
|
|
||||||
|
|
||||||
if ($name == '') {
|
|
||||||
$name = $data['name'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return '@[url=' . $data['url'] . ']' . $name . '[/url]';
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* we don't want to support a bbcode specific markdown interpreter
|
|
||||||
* and the markdown library we have is pretty good, but provides HTML output.
|
|
||||||
* So we'll use that to convert to HTML, then convert the HTML back to bbcode,
|
|
||||||
* and then clean up a few Diaspora specific constructs.
|
|
||||||
*/
|
|
||||||
function diaspora2bb($s) {
|
|
||||||
|
|
||||||
$s = html_entity_decode($s, ENT_COMPAT, 'UTF-8');
|
|
||||||
|
|
||||||
// Handles single newlines
|
|
||||||
$s = str_replace("\r\n", "\n", $s);
|
|
||||||
$s = str_replace("\n", " \n", $s);
|
|
||||||
$s = str_replace("\r", " \n", $s);
|
|
||||||
|
|
||||||
// Replace lonely stars in lines not starting with it with literal stars
|
|
||||||
$s = preg_replace('/^([^\*]+)\*([^\*]*)$/im', '$1\*$2', $s);
|
|
||||||
|
|
||||||
// The parser cannot handle paragraphs correctly
|
|
||||||
$s = str_replace(['</p>', '<p>', '<p dir="ltr">'], ['<br>', '<br>', '<br>'], $s);
|
|
||||||
|
|
||||||
// Escaping the hash tags
|
|
||||||
$s = preg_replace('/\#([^\s\#])/', '#$1', $s);
|
|
||||||
|
|
||||||
$s = Markdown::convert($s);
|
|
||||||
|
|
||||||
$regexp = "/@\{(?:([^\}]+?); )?([^\} ]+)\}/";
|
|
||||||
$s = preg_replace_callback($regexp, 'diaspora_mention2bb', $s);
|
|
||||||
|
|
||||||
$s = str_replace('#', '#', $s);
|
|
||||||
|
|
||||||
$s = html2bbcode($s);
|
|
||||||
|
|
||||||
// protect the recycle symbol from turning into a tag, but without unescaping angles and naked ampersands
|
|
||||||
$s = str_replace('♲', html_entity_decode('♲', ENT_QUOTES, 'UTF-8'), $s);
|
|
||||||
|
|
||||||
// Convert everything that looks like a link to a link
|
|
||||||
$s = preg_replace('/([^\]=]|^)(https?\:\/\/)([a-zA-Z0-9:\/\-?&;.=_~#%$!+,@]+(?<!,))/ism', '$1[url=$2$3]$2$3[/url]', $s);
|
|
||||||
|
|
||||||
//$s = preg_replace("/([^\]\=]|^)(https?\:\/\/)(vimeo|youtu|www\.youtube|soundcloud)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2$3$4]$2$3$4[/url]',$s);
|
|
||||||
$s = BBCode::pregReplaceInTag('/\[url\=?(.*?)\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/url\]/ism', '[youtube]$2[/youtube]', 'url', $s);
|
|
||||||
$s = BBCode::pregReplaceInTag('/\[url\=https?:\/\/www.youtube.com\/watch\?v\=(.*?)\].*?\[\/url\]/ism' , '[youtube]$1[/youtube]', 'url', $s);
|
|
||||||
$s = BBCode::pregReplaceInTag('/\[url\=?(.*?)\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/url\]/ism' , '[vimeo]$2[/vimeo]' , 'url', $s);
|
|
||||||
$s = BBCode::pregReplaceInTag('/\[url\=https?:\/\/vimeo.com\/([0-9]+)\](.*?)\[\/url\]/ism' , '[vimeo]$1[/vimeo]' , 'url', $s);
|
|
||||||
|
|
||||||
// remove duplicate adjacent code tags
|
|
||||||
$s = preg_replace('/(\[code\])+(.*?)(\[\/code\])+/ism', '[code]$2[/code]', $s);
|
|
||||||
|
|
||||||
// Don't show link to full picture (until it is fixed)
|
|
||||||
$s = BBCode::scaleExternalImages($s, false);
|
|
||||||
|
|
||||||
return $s;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Callback function to replace a Friendica style mention in a mention for Diaspora
|
|
||||||
*
|
|
||||||
* @param array $match Matching values for the callback
|
|
||||||
* @return string Replaced mention
|
|
||||||
*/
|
|
||||||
function diaspora_mentions($match) {
|
|
||||||
|
|
||||||
$contact = Contact::getDetailsByURL($match[3]);
|
|
||||||
|
|
||||||
if (!x($contact, 'addr')) {
|
|
||||||
$contact = Probe::uri($match[3]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!x($contact, 'addr')) {
|
|
||||||
return $match[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
$mention = '@{' . $match[2] . '; ' . $contact['addr'] . '}';
|
|
||||||
return $mention;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Converts a BBCode text into Markdown
|
|
||||||
*
|
|
||||||
* This function converts a BBCode item body to be sent to Markdown-enabled
|
|
||||||
* systems like Diaspora and Libertree
|
|
||||||
*
|
|
||||||
* @param string $Text
|
|
||||||
* @param bool $fordiaspora Diaspora requires more changes than Libertree
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function bb2diaspora($Text, $fordiaspora = true) {
|
|
||||||
$a = get_app();
|
|
||||||
|
|
||||||
$OriginalText = $Text;
|
|
||||||
|
|
||||||
// Since Diaspora is creating a summary for links, this function removes them before posting
|
|
||||||
if ($fordiaspora) {
|
|
||||||
$Text = BBCode::removeShareInformation($Text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Transform #tags, strip off the [url] and replace spaces with underscore
|
|
||||||
*/
|
|
||||||
$URLSearchString = "^\[\]";
|
|
||||||
$Text = preg_replace_callback("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/i",
|
|
||||||
function ($matches) {
|
|
||||||
return '#' . str_replace(' ', '_', $matches[2]);
|
|
||||||
}
|
|
||||||
, $Text);
|
|
||||||
|
|
||||||
// Converting images with size parameters to simple images. Markdown doesn't know it.
|
|
||||||
$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $Text);
|
|
||||||
|
|
||||||
// Extracting multi-line code blocks before the whitespace processing/code highlighter in BBCode::convert()
|
|
||||||
$codeblocks = [];
|
|
||||||
|
|
||||||
$Text = preg_replace_callback("#\[code(?:=([^\]]*))?\](.*?)\[\/code\]#is",
|
|
||||||
function ($matches) use (&$codeblocks) {
|
|
||||||
$return = $matches[0];
|
|
||||||
if (strpos($matches[2], "\n") !== false) {
|
|
||||||
$return = '#codeblock-' . count($codeblocks) . '#';
|
|
||||||
|
|
||||||
$prefix = '````' . $matches[1] . PHP_EOL;
|
|
||||||
$codeblocks[] = $prefix . trim($matches[2]) . PHP_EOL . '````';
|
|
||||||
}
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
, $Text);
|
|
||||||
|
|
||||||
// Convert it to HTML - don't try oembed
|
|
||||||
if ($fordiaspora) {
|
|
||||||
$Text = BBCode::convert($Text, false, 3);
|
|
||||||
|
|
||||||
// Add all tags that maybe were removed
|
|
||||||
if (preg_match_all("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", $OriginalText, $tags)) {
|
|
||||||
$tagline = "";
|
|
||||||
foreach ($tags[2] as $tag) {
|
|
||||||
$tag = html_entity_decode($tag, ENT_QUOTES, 'UTF-8');
|
|
||||||
if (!strpos(html_entity_decode($Text, ENT_QUOTES, 'UTF-8'), '#' . $tag)) {
|
|
||||||
$tagline .= '#' . $tag . ' ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$Text = $Text." ".$tagline;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$Text = BBCode::convert($Text, false, 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
// mask some special HTML chars from conversation to markdown
|
|
||||||
$Text = str_replace(['<', '>', '&'], ['&_lt_;', '&_gt_;', '&_amp_;'], $Text);
|
|
||||||
|
|
||||||
// If a link is followed by a quote then there should be a newline before it
|
|
||||||
// Maybe we should make this newline at every time before a quote.
|
|
||||||
$Text = str_replace(["</a><blockquote>"], ["</a><br><blockquote>"], $Text);
|
|
||||||
|
|
||||||
$stamp1 = microtime(true);
|
|
||||||
|
|
||||||
// Now convert HTML to Markdown
|
|
||||||
$converter = new HtmlConverter();
|
|
||||||
$Text = $converter->convert($Text);
|
|
||||||
|
|
||||||
// unmask the special chars back to HTML
|
|
||||||
$Text = str_replace(['&\_lt\_;', '&\_gt\_;', '&\_amp\_;'], ['<', '>', '&'], $Text);
|
|
||||||
|
|
||||||
$a->save_timestamp($stamp1, "parser");
|
|
||||||
|
|
||||||
// Libertree has a problem with escaped hashtags.
|
|
||||||
$Text = str_replace(['\#'], ['#'], $Text);
|
|
||||||
|
|
||||||
// Remove any leading or trailing whitespace, as this will mess up
|
|
||||||
// the Diaspora signature verification and cause the item to disappear
|
|
||||||
$Text = trim($Text);
|
|
||||||
|
|
||||||
if ($fordiaspora) {
|
|
||||||
$URLSearchString = "^\[\]";
|
|
||||||
$Text = preg_replace_callback("/([@]\[(.*?)\])\(([$URLSearchString]*?)\)/ism", 'diaspora_mentions', $Text);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Restore code blocks
|
|
||||||
$Text = preg_replace_callback('/#codeblock-([0-9]+)#/iU',
|
|
||||||
function ($matches) use ($codeblocks) {
|
|
||||||
$return = '';
|
|
||||||
if (isset($codeblocks[intval($matches[1])])) {
|
|
||||||
$return = $codeblocks[$matches[1]];
|
|
||||||
}
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
, $Text);
|
|
||||||
|
|
||||||
Addon::callHooks('bb2diaspora',$Text);
|
|
||||||
|
|
||||||
return $Text;
|
|
||||||
}
|
|
||||||
|
|
||||||
function unescape_underscores_in_links($m) {
|
|
||||||
$y = str_replace('\\_', '_', $m[2]);
|
|
||||||
return('[' . $m[1] . '](' . $y . ')');
|
|
||||||
}
|
|
||||||
|
|
||||||
function format_event_diaspora($ev) {
|
|
||||||
if (! ((is_array($ev)) && count($ev))) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$bd_format = L10n::t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM
|
|
||||||
|
|
||||||
$o = 'Friendica event notification:' . "\n";
|
|
||||||
|
|
||||||
$o .= '**' . (($ev['summary']) ? bb2diaspora($ev['summary']) : bb2diaspora($ev['desc'])) . '**' . "\n";
|
|
||||||
|
|
||||||
// @todo What. Is. Going. On. With. This. Useless. Ternary. Operator? - mrpetovan
|
|
||||||
$o .= L10n::t('Starts:') . ' ' . '[' . day_translate(
|
|
||||||
$ev['adjust'] ? DateTimeFormat::utc($ev['start'], $bd_format) : DateTimeFormat::utc($ev['start'], $bd_format)
|
|
||||||
)
|
|
||||||
. '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(DateTimeFormat::utc($ev['start'])) . ")\n";
|
|
||||||
|
|
||||||
if (! $ev['nofinish']) {
|
|
||||||
$o .= L10n::t('Finishes:') . ' ' . '[' . day_translate(
|
|
||||||
$ev['adjust'] ? DateTimeFormat::utc($ev['finish'], $bd_format) : DateTimeFormat::utc($ev['finish'], $bd_format)
|
|
||||||
)
|
|
||||||
. '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(DateTimeFormat::utc($ev['finish'])) . ")\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strlen($ev['location'])) {
|
|
||||||
$o .= L10n::t('Location:') . bb2diaspora($ev['location'])
|
|
||||||
. "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
$o .= "\n";
|
|
||||||
return $o;
|
|
||||||
}
|
|
|
@ -21,8 +21,6 @@ use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Temporal;
|
use Friendica\Util\Temporal;
|
||||||
use Friendica\Util\XML;
|
use Friendica\Util\XML;
|
||||||
|
|
||||||
require_once "include/acl_selectors.php";
|
|
||||||
|
|
||||||
function item_extract_images($body) {
|
function item_extract_images($body) {
|
||||||
|
|
||||||
$saved_image = [];
|
$saved_image = [];
|
||||||
|
|
|
@ -13,7 +13,7 @@ use Friendica\Util\DateTimeFormat;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class dba {
|
class dba {
|
||||||
public static $connected = true;
|
public static $connected = false;
|
||||||
|
|
||||||
private static $_server_info = '';
|
private static $_server_info = '';
|
||||||
private static $db;
|
private static $db;
|
||||||
|
@ -48,8 +48,6 @@ class dba {
|
||||||
$db = trim($db);
|
$db = trim($db);
|
||||||
|
|
||||||
if (!(strlen($server) && strlen($user))) {
|
if (!(strlen($server) && strlen($user))) {
|
||||||
self::$connected = false;
|
|
||||||
self::$db = null;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,8 +55,6 @@ class dba {
|
||||||
if (strlen($server) && ($server !== 'localhost') && ($server !== '127.0.0.1')) {
|
if (strlen($server) && ($server !== 'localhost') && ($server !== '127.0.0.1')) {
|
||||||
if (! dns_get_record($server, DNS_A + DNS_CNAME + DNS_PTR)) {
|
if (! dns_get_record($server, DNS_A + DNS_CNAME + DNS_PTR)) {
|
||||||
self::$error = L10n::t('Cannot locate DNS info for database server \'%s\'', $server);
|
self::$error = L10n::t('Cannot locate DNS info for database server \'%s\'', $server);
|
||||||
self::$connected = false;
|
|
||||||
self::$db = null;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +75,6 @@ class dba {
|
||||||
self::$db = @new PDO($connect, $user, $pass);
|
self::$db = @new PDO($connect, $user, $pass);
|
||||||
self::$connected = true;
|
self::$connected = true;
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
self::$connected = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,14 +93,10 @@ class dba {
|
||||||
// No suitable SQL driver was found.
|
// No suitable SQL driver was found.
|
||||||
if (!self::$connected) {
|
if (!self::$connected) {
|
||||||
self::$db = null;
|
self::$db = null;
|
||||||
if (!$install) {
|
|
||||||
System::unavailable();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
$a->save_timestamp($stamp1, "network");
|
$a->save_timestamp($stamp1, "network");
|
||||||
|
|
||||||
return true;
|
return self::$connected;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -146,7 +137,7 @@ class dba {
|
||||||
*
|
*
|
||||||
* @param string $query The database query that will be analyzed
|
* @param string $query The database query that will be analyzed
|
||||||
*/
|
*/
|
||||||
private static function log_index($query) {
|
private static function logIndex($query) {
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
if (empty($a->config["system"]["db_log_index"])) {
|
if (empty($a->config["system"]["db_log_index"])) {
|
||||||
|
@ -273,7 +264,7 @@ class dba {
|
||||||
* @param array $args The parameters that are to replace the ? placeholders
|
* @param array $args The parameters that are to replace the ? placeholders
|
||||||
* @return string The replaced SQL query
|
* @return string The replaced SQL query
|
||||||
*/
|
*/
|
||||||
private static function replace_parameters($sql, $args) {
|
private static function replaceParameters($sql, $args) {
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
foreach ($args AS $param => $value) {
|
foreach ($args AS $param => $value) {
|
||||||
if (is_int($args[$param]) || is_float($args[$param])) {
|
if (is_int($args[$param]) || is_float($args[$param])) {
|
||||||
|
@ -414,7 +405,7 @@ class dba {
|
||||||
|
|
||||||
// The fallback routine is called as well when there are no arguments
|
// The fallback routine is called as well when there are no arguments
|
||||||
if (!$can_be_prepared || (count($args) == 0)) {
|
if (!$can_be_prepared || (count($args) == 0)) {
|
||||||
$retval = self::$db->query(self::replace_parameters($sql, $args));
|
$retval = self::$db->query(self::replaceParameters($sql, $args));
|
||||||
if (self::$db->errno) {
|
if (self::$db->errno) {
|
||||||
self::$error = self::$db->error;
|
self::$error = self::$db->error;
|
||||||
self::$errorno = self::$db->errno;
|
self::$errorno = self::$db->errno;
|
||||||
|
@ -477,7 +468,7 @@ class dba {
|
||||||
$errorno = self::$errorno;
|
$errorno = self::$errorno;
|
||||||
|
|
||||||
logger('DB Error '.self::$errorno.': '.self::$error."\n".
|
logger('DB Error '.self::$errorno.': '.self::$error."\n".
|
||||||
System::callstack(8)."\n".self::replace_parameters($sql, $params));
|
System::callstack(8)."\n".self::replaceParameters($sql, $params));
|
||||||
|
|
||||||
self::$error = $error;
|
self::$error = $error;
|
||||||
self::$errorno = $errorno;
|
self::$errorno = $errorno;
|
||||||
|
@ -497,7 +488,7 @@ class dba {
|
||||||
@file_put_contents($a->config["system"]["db_log"], DateTimeFormat::utcNow()."\t".$duration."\t".
|
@file_put_contents($a->config["system"]["db_log"], DateTimeFormat::utcNow()."\t".$duration."\t".
|
||||||
basename($backtrace[1]["file"])."\t".
|
basename($backtrace[1]["file"])."\t".
|
||||||
$backtrace[1]["line"]."\t".$backtrace[2]["function"]."\t".
|
$backtrace[1]["line"]."\t".$backtrace[2]["function"]."\t".
|
||||||
substr(self::replace_parameters($sql, $args), 0, 2000)."\n", FILE_APPEND);
|
substr(self::replaceParameters($sql, $args), 0, 2000)."\n", FILE_APPEND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $retval;
|
return $retval;
|
||||||
|
@ -542,7 +533,7 @@ class dba {
|
||||||
$errorno = self::$errorno;
|
$errorno = self::$errorno;
|
||||||
|
|
||||||
logger('DB Error '.self::$errorno.': '.self::$error."\n".
|
logger('DB Error '.self::$errorno.': '.self::$error."\n".
|
||||||
System::callstack(8)."\n".self::replace_parameters($sql, $params));
|
System::callstack(8)."\n".self::replaceParameters($sql, $params));
|
||||||
|
|
||||||
self::$error = $error;
|
self::$error = $error;
|
||||||
self::$errorno = $errorno;
|
self::$errorno = $errorno;
|
||||||
|
@ -568,10 +559,10 @@ class dba {
|
||||||
|
|
||||||
$fields = [];
|
$fields = [];
|
||||||
|
|
||||||
$array_element = each($condition);
|
reset($condition);
|
||||||
$array_key = $array_element['key'];
|
$first_key = key($condition);
|
||||||
if (!is_int($array_key)) {
|
if (!is_int($first_key)) {
|
||||||
$fields = [$array_key];
|
$fields = [$first_key];
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = self::select($table, $fields, $condition, ['limit' => 1]);
|
$stmt = self::select($table, $fields, $condition, ['limit' => 1]);
|
||||||
|
@ -847,7 +838,7 @@ class dba {
|
||||||
*
|
*
|
||||||
* This process must only be started once, since the value is cached.
|
* This process must only be started once, since the value is cached.
|
||||||
*/
|
*/
|
||||||
private static function build_relation_data() {
|
private static function buildRelationData() {
|
||||||
$definition = DBStructure::definition();
|
$definition = DBStructure::definition();
|
||||||
|
|
||||||
foreach ($definition AS $table => $structure) {
|
foreach ($definition AS $table => $structure) {
|
||||||
|
@ -896,7 +887,7 @@ class dba {
|
||||||
|
|
||||||
// To speed up the whole process we cache the table relations
|
// To speed up the whole process we cache the table relations
|
||||||
if (count(self::$relation) == 0) {
|
if (count(self::$relation) == 0) {
|
||||||
self::build_relation_data();
|
self::buildRelationData();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is there a relation entry for the table?
|
// Is there a relation entry for the table?
|
||||||
|
@ -951,17 +942,14 @@ class dba {
|
||||||
|
|
||||||
foreach ($commands AS $command) {
|
foreach ($commands AS $command) {
|
||||||
$conditions = $command['conditions'];
|
$conditions = $command['conditions'];
|
||||||
$array_element = each($conditions);
|
reset($conditions);
|
||||||
$array_key = $array_element['key'];
|
$first_key = key($conditions);
|
||||||
if (is_int($array_key)) {
|
|
||||||
$condition_string = " WHERE " . array_shift($conditions);
|
|
||||||
} else {
|
|
||||||
$condition_string = " WHERE `" . implode("` = ? AND `", array_keys($conditions)) . "` = ?";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((count($command['conditions']) > 1) || is_int($array_key)) {
|
$condition_string = self::buildCondition($conditions);
|
||||||
|
|
||||||
|
if ((count($command['conditions']) > 1) || is_int($first_key)) {
|
||||||
$sql = "DELETE FROM `" . $command['table'] . "`" . $condition_string;
|
$sql = "DELETE FROM `" . $command['table'] . "`" . $condition_string;
|
||||||
logger(self::replace_parameters($sql, $conditions), LOGGER_DATA);
|
logger(self::replaceParameters($sql, $conditions), LOGGER_DATA);
|
||||||
|
|
||||||
if (!self::e($sql, $conditions)) {
|
if (!self::e($sql, $conditions)) {
|
||||||
if ($do_transaction) {
|
if ($do_transaction) {
|
||||||
|
@ -991,7 +979,7 @@ class dba {
|
||||||
$sql = "DELETE FROM `" . $table . "` WHERE `" . $field . "` IN (" .
|
$sql = "DELETE FROM `" . $table . "` WHERE `" . $field . "` IN (" .
|
||||||
substr(str_repeat("?, ", count($field_values)), 0, -2) . ");";
|
substr(str_repeat("?, ", count($field_values)), 0, -2) . ");";
|
||||||
|
|
||||||
logger(self::replace_parameters($sql, $field_values), LOGGER_DATA);
|
logger(self::replaceParameters($sql, $field_values), LOGGER_DATA);
|
||||||
|
|
||||||
if (!self::e($sql, $field_values)) {
|
if (!self::e($sql, $field_values)) {
|
||||||
if ($do_transaction) {
|
if ($do_transaction) {
|
||||||
|
@ -1048,13 +1036,7 @@ class dba {
|
||||||
|
|
||||||
$table = self::escape($table);
|
$table = self::escape($table);
|
||||||
|
|
||||||
$array_element = each($condition);
|
$condition_string = self::buildCondition($condition);
|
||||||
$array_key = $array_element['key'];
|
|
||||||
if (is_int($array_key)) {
|
|
||||||
$condition_string = " WHERE ".array_shift($condition);
|
|
||||||
} else {
|
|
||||||
$condition_string = " WHERE `".implode("` = ? AND `", array_keys($condition))."` = ?";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_bool($old_fields)) {
|
if (is_bool($old_fields)) {
|
||||||
$do_insert = $old_fields;
|
$do_insert = $old_fields;
|
||||||
|
@ -1149,6 +1131,8 @@ class dba {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$table = self::escape($table);
|
||||||
|
|
||||||
if (count($fields) > 0) {
|
if (count($fields) > 0) {
|
||||||
$select_fields = "`" . implode("`, `", array_values($fields)) . "`";
|
$select_fields = "`" . implode("`, `", array_values($fields)) . "`";
|
||||||
} else {
|
} else {
|
||||||
|
@ -1240,12 +1224,28 @@ class dba {
|
||||||
{
|
{
|
||||||
$condition_string = '';
|
$condition_string = '';
|
||||||
if (count($condition) > 0) {
|
if (count($condition) > 0) {
|
||||||
$array_element = each($condition);
|
reset($condition);
|
||||||
$array_key = $array_element['key'];
|
$first_key = key($condition);
|
||||||
if (is_int($array_key)) {
|
if (is_int($first_key)) {
|
||||||
$condition_string = " WHERE ".array_shift($condition);
|
$condition_string = " WHERE ".array_shift($condition);
|
||||||
} else {
|
} else {
|
||||||
$condition_string = " WHERE `".implode("` = ? AND `", array_keys($condition))."` = ?";
|
$new_values = [];
|
||||||
|
$condition_string = "";
|
||||||
|
foreach ($condition as $field => $value) {
|
||||||
|
if ($condition_string != "") {
|
||||||
|
$condition_string .= " AND ";
|
||||||
|
}
|
||||||
|
if (is_array($value)) {
|
||||||
|
$new_values = array_merge($new_values, array_values($value));
|
||||||
|
$placeholders = substr(str_repeat("?, ", count($value)), 0, -2);
|
||||||
|
$condition_string .= "`" . $field . "` IN (" . $placeholders . ")";
|
||||||
|
} else {
|
||||||
|
$new_values[$field] = $value;
|
||||||
|
$condition_string .= "`" . $field . "` = ?";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$condition_string = " WHERE " . $condition_string;
|
||||||
|
$condition = $new_values;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,6 @@ use Friendica\Database\DBM;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Emailer;
|
use Friendica\Util\Emailer;
|
||||||
|
|
||||||
require_once 'include/html2bbcode.php';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Creates a notification entry and possibly sends a mail
|
* @brief Creates a notification entry and possibly sends a mail
|
||||||
*
|
*
|
||||||
|
|
1065
include/event.php
1065
include/event.php
File diff suppressed because it is too large
Load diff
|
@ -1,403 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* @file include/html2bbcode.php
|
|
||||||
* @brief Converter for HTML to BBCode
|
|
||||||
*
|
|
||||||
* Made by: ike@piratenpartei.de
|
|
||||||
* Originally made for the syncom project: http://wiki.piratenpartei.de/Syncom
|
|
||||||
* https://github.com/annando/Syncom
|
|
||||||
*/
|
|
||||||
|
|
||||||
use Friendica\Core\Addon;
|
|
||||||
use Friendica\Util\Network;
|
|
||||||
use Friendica\Util\XML;
|
|
||||||
|
|
||||||
function node2bbcode(&$doc, $oldnode, $attributes, $startbb, $endbb)
|
|
||||||
{
|
|
||||||
do {
|
|
||||||
$done = node2bbcodesub($doc, $oldnode, $attributes, $startbb, $endbb);
|
|
||||||
} while ($done);
|
|
||||||
}
|
|
||||||
|
|
||||||
function node2bbcodesub(&$doc, $oldnode, $attributes, $startbb, $endbb)
|
|
||||||
{
|
|
||||||
$savestart = str_replace('$', '\x01', $startbb);
|
|
||||||
$replace = false;
|
|
||||||
|
|
||||||
$xpath = new DomXPath($doc);
|
|
||||||
|
|
||||||
$list = $xpath->query("//".$oldnode);
|
|
||||||
foreach ($list as $oldNode) {
|
|
||||||
$attr = [];
|
|
||||||
if ($oldNode->attributes->length) {
|
|
||||||
foreach ($oldNode->attributes as $attribute) {
|
|
||||||
$attr[$attribute->name] = $attribute->value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$replace = true;
|
|
||||||
|
|
||||||
$startbb = $savestart;
|
|
||||||
|
|
||||||
$i = 0;
|
|
||||||
|
|
||||||
foreach ($attributes as $attribute => $value) {
|
|
||||||
$startbb = str_replace('\x01'.++$i, '$1', $startbb);
|
|
||||||
if (strpos('*'.$startbb, '$1') > 0) {
|
|
||||||
if ($replace && (@$attr[$attribute] != '')) {
|
|
||||||
$startbb = preg_replace($value, $startbb, $attr[$attribute], -1, $count);
|
|
||||||
|
|
||||||
// If nothing could be changed
|
|
||||||
if ($count == 0) {
|
|
||||||
$replace = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$replace = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (@$attr[$attribute] != $value) {
|
|
||||||
$replace = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($replace) {
|
|
||||||
$StartCode = $oldNode->ownerDocument->createTextNode($startbb);
|
|
||||||
$EndCode = $oldNode->ownerDocument->createTextNode($endbb);
|
|
||||||
|
|
||||||
$oldNode->parentNode->insertBefore($StartCode, $oldNode);
|
|
||||||
|
|
||||||
if ($oldNode->hasChildNodes()) {
|
|
||||||
foreach ($oldNode->childNodes as $child) {
|
|
||||||
$newNode = $child->cloneNode(true);
|
|
||||||
$oldNode->parentNode->insertBefore($newNode, $oldNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$oldNode->parentNode->insertBefore($EndCode, $oldNode);
|
|
||||||
$oldNode->parentNode->removeChild($oldNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return($replace);
|
|
||||||
}
|
|
||||||
|
|
||||||
function html2bbcode($message, $basepath = '')
|
|
||||||
{
|
|
||||||
|
|
||||||
$message = str_replace("\r", "", $message);
|
|
||||||
|
|
||||||
// Removing code blocks before the whitespace removal processing below
|
|
||||||
$codeblocks = [];
|
|
||||||
$message = preg_replace_callback(
|
|
||||||
'#<pre><code(?: class="([^"]*)")?>(.*)</code></pre>#iUs',
|
|
||||||
function ($matches) use (&$codeblocks) {
|
|
||||||
$return = '[codeblock-' . count($codeblocks) . ']';
|
|
||||||
|
|
||||||
$prefix = '[code]';
|
|
||||||
if ($matches[1] != '') {
|
|
||||||
$prefix = '[code=' . $matches[1] . ']';
|
|
||||||
}
|
|
||||||
$codeblocks[] = $prefix . trim($matches[2]) . '[/code]';
|
|
||||||
return $return;
|
|
||||||
},
|
|
||||||
$message
|
|
||||||
);
|
|
||||||
|
|
||||||
$message = str_replace(
|
|
||||||
[
|
|
||||||
"<li><p>",
|
|
||||||
"</p></li>",
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"<li>",
|
|
||||||
"</li>",
|
|
||||||
],
|
|
||||||
$message
|
|
||||||
);
|
|
||||||
|
|
||||||
// remove namespaces
|
|
||||||
$message = preg_replace('=<(\w+):(.+?)>=', '<removeme>', $message);
|
|
||||||
$message = preg_replace('=</(\w+):(.+?)>=', '</removeme>', $message);
|
|
||||||
|
|
||||||
$doc = new DOMDocument();
|
|
||||||
$doc->preserveWhiteSpace = false;
|
|
||||||
|
|
||||||
$message = mb_convert_encoding($message, 'HTML-ENTITIES', "UTF-8");
|
|
||||||
|
|
||||||
@$doc->loadHTML($message);
|
|
||||||
|
|
||||||
XML::deleteNode($doc, 'style');
|
|
||||||
XML::deleteNode($doc, 'head');
|
|
||||||
XML::deleteNode($doc, 'title');
|
|
||||||
XML::deleteNode($doc, 'meta');
|
|
||||||
XML::deleteNode($doc, 'xml');
|
|
||||||
XML::deleteNode($doc, 'removeme');
|
|
||||||
|
|
||||||
$xpath = new DomXPath($doc);
|
|
||||||
$list = $xpath->query("//pre");
|
|
||||||
foreach ($list as $node) {
|
|
||||||
$node->nodeValue = str_replace("\n", "\r", $node->nodeValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
$message = $doc->saveHTML();
|
|
||||||
$message = str_replace(["\n<", ">\n", "\r", "\n", "\xC3\x82\xC2\xA0"], ["<", ">", "<br />", " ", ""], $message);
|
|
||||||
$message = preg_replace('= [\s]*=i', " ", $message);
|
|
||||||
@$doc->loadHTML($message);
|
|
||||||
|
|
||||||
node2bbcode($doc, 'html', [], "", "");
|
|
||||||
node2bbcode($doc, 'body', [], "", "");
|
|
||||||
|
|
||||||
// Outlook-Quote - Variant 1
|
|
||||||
node2bbcode($doc, 'p', ['class'=>'MsoNormal', 'style'=>'margin-left:35.4pt'], '[quote]', '[/quote]');
|
|
||||||
|
|
||||||
// Outlook-Quote - Variant 2
|
|
||||||
node2bbcode($doc, 'div', ['style'=>'border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt'], '[quote]', '[/quote]');
|
|
||||||
|
|
||||||
// MyBB-Stuff
|
|
||||||
node2bbcode($doc, 'span', ['style'=>'text-decoration: underline;'], '[u]', '[/u]');
|
|
||||||
node2bbcode($doc, 'span', ['style'=>'font-style: italic;'], '[i]', '[/i]');
|
|
||||||
node2bbcode($doc, 'span', ['style'=>'font-weight: bold;'], '[b]', '[/b]');
|
|
||||||
|
|
||||||
/*node2bbcode($doc, 'font', array('face'=>'/([\w ]+)/', 'size'=>'/(\d+)/', 'color'=>'/(.+)/'), '[font=$1][size=$2][color=$3]', '[/color][/size][/font]');
|
|
||||||
node2bbcode($doc, 'font', array('size'=>'/(\d+)/', 'color'=>'/(.+)/'), '[size=$1][color=$2]', '[/color][/size]');
|
|
||||||
node2bbcode($doc, 'font', array('face'=>'/([\w ]+)/', 'size'=>'/(.+)/'), '[font=$1][size=$2]', '[/size][/font]');
|
|
||||||
node2bbcode($doc, 'font', array('face'=>'/([\w ]+)/', 'color'=>'/(.+)/'), '[font=$1][color=$3]', '[/color][/font]');
|
|
||||||
node2bbcode($doc, 'font', array('face'=>'/([\w ]+)/'), '[font=$1]', '[/font]');
|
|
||||||
node2bbcode($doc, 'font', array('size'=>'/(\d+)/'), '[size=$1]', '[/size]');
|
|
||||||
node2bbcode($doc, 'font', array('color'=>'/(.+)/'), '[color=$1]', '[/color]');
|
|
||||||
*/
|
|
||||||
// Untested
|
|
||||||
//node2bbcode($doc, 'span', array('style'=>'/.*font-size:\s*(.+?)[,;].*font-family:\s*(.+?)[,;].*color:\s*(.+?)[,;].*/'), '[size=$1][font=$2][color=$3]', '[/color][/font][/size]');
|
|
||||||
//node2bbcode($doc, 'span', array('style'=>'/.*font-size:\s*(\d+)[,;].*/'), '[size=$1]', '[/size]');
|
|
||||||
//node2bbcode($doc, 'span', array('style'=>'/.*font-size:\s*(.+?)[,;].*/'), '[size=$1]', '[/size]');
|
|
||||||
|
|
||||||
node2bbcode($doc, 'span', ['style'=>'/.*color:\s*(.+?)[,;].*/'], '[color="$1"]', '[/color]');
|
|
||||||
|
|
||||||
//node2bbcode($doc, 'span', array('style'=>'/.*font-family:\s*(.+?)[,;].*/'), '[font=$1]', '[/font]');
|
|
||||||
|
|
||||||
//node2bbcode($doc, 'div', array('style'=>'/.*font-family:\s*(.+?)[,;].*font-size:\s*(\d+?)pt.*/'), '[font=$1][size=$2]', '[/size][/font]');
|
|
||||||
//node2bbcode($doc, 'div', array('style'=>'/.*font-family:\s*(.+?)[,;].*font-size:\s*(\d+?)px.*/'), '[font=$1][size=$2]', '[/size][/font]');
|
|
||||||
//node2bbcode($doc, 'div', array('style'=>'/.*font-family:\s*(.+?)[,;].*/'), '[font=$1]', '[/font]');
|
|
||||||
|
|
||||||
// Importing the classes - interesting for importing of posts from third party networks that were exported from friendica
|
|
||||||
// Test
|
|
||||||
//node2bbcode($doc, 'span', array('class'=>'/([\w ]+)/'), '[class=$1]', '[/class]');
|
|
||||||
node2bbcode($doc, 'span', ['class'=>'type-link'], '[class=type-link]', '[/class]');
|
|
||||||
node2bbcode($doc, 'span', ['class'=>'type-video'], '[class=type-video]', '[/class]');
|
|
||||||
|
|
||||||
node2bbcode($doc, 'strong', [], '[b]', '[/b]');
|
|
||||||
node2bbcode($doc, 'em', [], '[i]', '[/i]');
|
|
||||||
node2bbcode($doc, 'b', [], '[b]', '[/b]');
|
|
||||||
node2bbcode($doc, 'i', [], '[i]', '[/i]');
|
|
||||||
node2bbcode($doc, 'u', [], '[u]', '[/u]');
|
|
||||||
|
|
||||||
node2bbcode($doc, 'big', [], "[size=large]", "[/size]");
|
|
||||||
node2bbcode($doc, 'small', [], "[size=small]", "[/size]");
|
|
||||||
|
|
||||||
node2bbcode($doc, 'blockquote', [], '[quote]', '[/quote]');
|
|
||||||
|
|
||||||
node2bbcode($doc, 'br', [], "\n", '');
|
|
||||||
|
|
||||||
node2bbcode($doc, 'p', ['class'=>'MsoNormal'], "\n", "");
|
|
||||||
node2bbcode($doc, 'div', ['class'=>'MsoNormal'], "\r", "");
|
|
||||||
|
|
||||||
node2bbcode($doc, 'span', [], "", "");
|
|
||||||
|
|
||||||
node2bbcode($doc, 'span', [], "", "");
|
|
||||||
node2bbcode($doc, 'pre', [], "", "");
|
|
||||||
|
|
||||||
node2bbcode($doc, 'div', [], "\r", "\r");
|
|
||||||
node2bbcode($doc, 'p', [], "\n", "\n");
|
|
||||||
|
|
||||||
node2bbcode($doc, 'ul', [], "[list]", "[/list]");
|
|
||||||
node2bbcode($doc, 'ol', [], "[list=1]", "[/list]");
|
|
||||||
node2bbcode($doc, 'li', [], "[*]", "");
|
|
||||||
|
|
||||||
node2bbcode($doc, 'hr', [], "[hr]", "");
|
|
||||||
|
|
||||||
node2bbcode($doc, 'table', [], "", "");
|
|
||||||
node2bbcode($doc, 'tr', [], "\n", "");
|
|
||||||
node2bbcode($doc, 'td', [], "\t", "");
|
|
||||||
//node2bbcode($doc, 'table', array(), "[table]", "[/table]");
|
|
||||||
//node2bbcode($doc, 'th', array(), "[th]", "[/th]");
|
|
||||||
//node2bbcode($doc, 'tr', array(), "[tr]", "[/tr]");
|
|
||||||
//node2bbcode($doc, 'td', array(), "[td]", "[/td]");
|
|
||||||
|
|
||||||
//node2bbcode($doc, 'h1', array(), "\n\n[size=xx-large][b]", "[/b][/size]\n");
|
|
||||||
//node2bbcode($doc, 'h2', array(), "\n\n[size=x-large][b]", "[/b][/size]\n");
|
|
||||||
//node2bbcode($doc, 'h3', array(), "\n\n[size=large][b]", "[/b][/size]\n");
|
|
||||||
//node2bbcode($doc, 'h4', array(), "\n\n[size=medium][b]", "[/b][/size]\n");
|
|
||||||
//node2bbcode($doc, 'h5', array(), "\n\n[size=small][b]", "[/b][/size]\n");
|
|
||||||
//node2bbcode($doc, 'h6', array(), "\n\n[size=x-small][b]", "[/b][/size]\n");
|
|
||||||
|
|
||||||
node2bbcode($doc, 'h1', [], "\n\n[h1]", "[/h1]\n");
|
|
||||||
node2bbcode($doc, 'h2', [], "\n\n[h2]", "[/h2]\n");
|
|
||||||
node2bbcode($doc, 'h3', [], "\n\n[h3]", "[/h3]\n");
|
|
||||||
node2bbcode($doc, 'h4', [], "\n\n[h4]", "[/h4]\n");
|
|
||||||
node2bbcode($doc, 'h5', [], "\n\n[h5]", "[/h5]\n");
|
|
||||||
node2bbcode($doc, 'h6', [], "\n\n[h6]", "[/h6]\n");
|
|
||||||
|
|
||||||
node2bbcode($doc, 'a', ['href'=>'/mailto:(.+)/'], '[mail=$1]', '[/mail]');
|
|
||||||
node2bbcode($doc, 'a', ['href'=>'/(.+)/'], '[url=$1]', '[/url]');
|
|
||||||
|
|
||||||
node2bbcode($doc, 'img', ['src'=>'/(.+)/', 'width'=>'/(\d+)/', 'height'=>'/(\d+)/'], '[img=$2x$3]$1', '[/img]');
|
|
||||||
node2bbcode($doc, 'img', ['src'=>'/(.+)/'], '[img]$1', '[/img]');
|
|
||||||
|
|
||||||
|
|
||||||
node2bbcode($doc, 'video', ['src'=>'/(.+)/'], '[video]$1', '[/video]');
|
|
||||||
node2bbcode($doc, 'audio', ['src'=>'/(.+)/'], '[audio]$1', '[/audio]');
|
|
||||||
node2bbcode($doc, 'iframe', ['src'=>'/(.+)/'], '[iframe]$1', '[/iframe]');
|
|
||||||
|
|
||||||
node2bbcode($doc, 'key', [], '[code]', '[/code]');
|
|
||||||
node2bbcode($doc, 'code', [], '[code]', '[/code]');
|
|
||||||
|
|
||||||
$message = $doc->saveHTML();
|
|
||||||
|
|
||||||
// I'm removing something really disturbing
|
|
||||||
// Don't know exactly what it is
|
|
||||||
$message = str_replace(chr(194).chr(160), ' ', $message);
|
|
||||||
|
|
||||||
$message = str_replace(" ", " ", $message);
|
|
||||||
|
|
||||||
// removing multiple DIVs
|
|
||||||
$message = preg_replace('=\r *\r=i', "\n", $message);
|
|
||||||
$message = str_replace("\r", "\n", $message);
|
|
||||||
|
|
||||||
Addon::callHooks('html2bbcode', $message);
|
|
||||||
|
|
||||||
$message = strip_tags($message);
|
|
||||||
|
|
||||||
$message = html_entity_decode($message, ENT_QUOTES, 'UTF-8');
|
|
||||||
|
|
||||||
$message = str_replace(["<"], ["<"], $message);
|
|
||||||
|
|
||||||
// remove quotes if they don't make sense
|
|
||||||
$message = preg_replace('=\[/quote\][\s]*\[quote\]=i', "\n", $message);
|
|
||||||
|
|
||||||
$message = preg_replace('=\[quote\]\s*=i', "[quote]", $message);
|
|
||||||
$message = preg_replace('=\s*\[/quote\]=i', "[/quote]", $message);
|
|
||||||
|
|
||||||
do {
|
|
||||||
$oldmessage = $message;
|
|
||||||
$message = str_replace("\n \n", "\n\n", $message);
|
|
||||||
} while ($oldmessage != $message);
|
|
||||||
|
|
||||||
do {
|
|
||||||
$oldmessage = $message;
|
|
||||||
$message = str_replace("\n\n\n", "\n\n", $message);
|
|
||||||
} while ($oldmessage != $message);
|
|
||||||
|
|
||||||
do {
|
|
||||||
$oldmessage = $message;
|
|
||||||
$message = str_replace(
|
|
||||||
[
|
|
||||||
"[/size]\n\n",
|
|
||||||
"\n[hr]",
|
|
||||||
"[hr]\n",
|
|
||||||
"\n[list",
|
|
||||||
"[/list]\n",
|
|
||||||
"\n[/",
|
|
||||||
"[list]\n",
|
|
||||||
"[list=1]\n",
|
|
||||||
"\n[*]"],
|
|
||||||
[
|
|
||||||
"[/size]\n",
|
|
||||||
"[hr]",
|
|
||||||
"[hr]",
|
|
||||||
"[list",
|
|
||||||
"[/list]",
|
|
||||||
"[/",
|
|
||||||
"[list]",
|
|
||||||
"[list=1]",
|
|
||||||
"[*]"],
|
|
||||||
$message
|
|
||||||
);
|
|
||||||
} while ($message != $oldmessage);
|
|
||||||
|
|
||||||
$message = str_replace(
|
|
||||||
['[b][b]', '[/b][/b]', '[i][i]', '[/i][/i]'],
|
|
||||||
['[b]', '[/b]', '[i]', '[/i]'],
|
|
||||||
$message
|
|
||||||
);
|
|
||||||
|
|
||||||
// Handling Yahoo style of mails
|
|
||||||
$message = str_replace('[hr][b]From:[/b]', '[quote][b]From:[/b]', $message);
|
|
||||||
|
|
||||||
// Restore code blocks
|
|
||||||
$message = preg_replace_callback(
|
|
||||||
'#\[codeblock-([0-9]+)\]#iU',
|
|
||||||
function ($matches) use ($codeblocks) {
|
|
||||||
$return = '';
|
|
||||||
if (isset($codeblocks[intval($matches[1])])) {
|
|
||||||
$return = $codeblocks[$matches[1]];
|
|
||||||
}
|
|
||||||
return $return;
|
|
||||||
},
|
|
||||||
$message
|
|
||||||
);
|
|
||||||
|
|
||||||
$message = trim($message);
|
|
||||||
|
|
||||||
if ($basepath != '') {
|
|
||||||
$message = addHostname($message, $basepath);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $message;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Sub function to complete incomplete URL
|
|
||||||
*
|
|
||||||
* @param array $matches Result of preg_replace_callback
|
|
||||||
* @param string $basepath Basepath that is used to complete the URL
|
|
||||||
*
|
|
||||||
* @return string The expanded URL
|
|
||||||
*/
|
|
||||||
function addHostnameSub($matches, $basepath)
|
|
||||||
{
|
|
||||||
$base = parse_url($basepath);
|
|
||||||
unset($base['query']);
|
|
||||||
unset($base['fragment']);
|
|
||||||
|
|
||||||
$link = $matches[0];
|
|
||||||
$url = $matches[1];
|
|
||||||
|
|
||||||
$parts = array_merge($base, parse_url($url));
|
|
||||||
$url2 = Network::unparseURL($parts);
|
|
||||||
|
|
||||||
return str_replace($url, $url2, $link);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Complete incomplete URLs in BBCode
|
|
||||||
*
|
|
||||||
* @param string $body Body with URLs
|
|
||||||
* @param string $basepath Basepath that is used to complete the URL
|
|
||||||
*
|
|
||||||
* @return string Body with expanded URLs
|
|
||||||
*/
|
|
||||||
function addHostname($body, $basepath)
|
|
||||||
{
|
|
||||||
$URLSearchString = "^\[\]";
|
|
||||||
|
|
||||||
$matches = ["/\[url\=([$URLSearchString]*)\].*?\[\/url\]/ism",
|
|
||||||
"/\[url\]([$URLSearchString]*)\[\/url\]/ism",
|
|
||||||
"/\[img\=[0-9]*x[0-9]*\](.*?)\[\/img\]/ism",
|
|
||||||
"/\[img\](.*?)\[\/img\]/ism",
|
|
||||||
"/\[zmg\=[0-9]*x[0-9]*\](.*?)\[\/img\]/ism",
|
|
||||||
"/\[zmg\](.*?)\[\/zmg\]/ism",
|
|
||||||
"/\[video\](.*?)\[\/video\]/ism",
|
|
||||||
"/\[audio\](.*?)\[\/audio\]/ism",
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($matches as $match) {
|
|
||||||
$body = preg_replace_callback(
|
|
||||||
$match,
|
|
||||||
function ($match) use ($basepath) {
|
|
||||||
return addHostnameSub($match, $basepath);
|
|
||||||
},
|
|
||||||
$body
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return $body;
|
|
||||||
}
|
|
|
@ -1,246 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
require_once 'include/html2bbcode.php';
|
|
||||||
|
|
||||||
function breaklines($line, $level, $wraplength = 75)
|
|
||||||
{
|
|
||||||
if ($wraplength == 0) {
|
|
||||||
$wraplength = 2000000;
|
|
||||||
}
|
|
||||||
|
|
||||||
$wraplen = $wraplength - $level;
|
|
||||||
|
|
||||||
$newlines = [];
|
|
||||||
|
|
||||||
do {
|
|
||||||
$oldline = $line;
|
|
||||||
|
|
||||||
$subline = substr($line, 0, $wraplen);
|
|
||||||
|
|
||||||
$pos = strrpos($subline, ' ');
|
|
||||||
|
|
||||||
if ($pos == 0) {
|
|
||||||
$pos = strpos($line, ' ');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($pos > 0) && strlen($line) > $wraplen) {
|
|
||||||
$newline = trim(substr($line, 0, $pos));
|
|
||||||
if ($level > 0) {
|
|
||||||
$newline = str_repeat(">", $level) . ' ' . $newline;
|
|
||||||
}
|
|
||||||
|
|
||||||
$newlines[] = $newline . " ";
|
|
||||||
$line = substr($line, $pos + 1);
|
|
||||||
}
|
|
||||||
} while ((strlen($line) > $wraplen) && !($oldline == $line));
|
|
||||||
|
|
||||||
if ($level > 0) {
|
|
||||||
$line = str_repeat(">", $level) . ' ' . $line;
|
|
||||||
}
|
|
||||||
|
|
||||||
$newlines[] = $line;
|
|
||||||
|
|
||||||
return implode($newlines, "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
function quotelevel($message, $wraplength = 75)
|
|
||||||
{
|
|
||||||
$lines = explode("\n", $message);
|
|
||||||
|
|
||||||
$newlines = [];
|
|
||||||
$level = 0;
|
|
||||||
foreach ($lines as $line) {
|
|
||||||
$line = trim($line);
|
|
||||||
$startquote = false;
|
|
||||||
while (strpos("*" . $line, '[quote]') > 0) {
|
|
||||||
$level++;
|
|
||||||
$pos = strpos($line, '[quote]');
|
|
||||||
$line = substr($line, 0, $pos) . substr($line, $pos + 7);
|
|
||||||
$startquote = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$currlevel = $level;
|
|
||||||
|
|
||||||
while (strpos("*" . $line, '[/quote]') > 0) {
|
|
||||||
$level--;
|
|
||||||
if ($level < 0) {
|
|
||||||
$level = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$pos = strpos($line, '[/quote]');
|
|
||||||
$line = substr($line, 0, $pos) . substr($line, $pos + 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$startquote || ($line != '')) {
|
|
||||||
$newlines[] = breaklines($line, $currlevel, $wraplength);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return implode($newlines, "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
function collecturls($message)
|
|
||||||
{
|
|
||||||
$pattern = '/<a.*?href="(.*?)".*?>(.*?)<\/a>/is';
|
|
||||||
preg_match_all($pattern, $message, $result, PREG_SET_ORDER);
|
|
||||||
|
|
||||||
$urls = [];
|
|
||||||
foreach ($result as $treffer) {
|
|
||||||
$ignore = false;
|
|
||||||
|
|
||||||
// A list of some links that should be ignored
|
|
||||||
$list = ["/user/", "/tag/", "/group/", "/profile/", "/search?search=", "/search?tag=", "mailto:", "/u/", "/node/",
|
|
||||||
"//facebook.com/profile.php?id=", "//plus.google.com/", "//twitter.com/"];
|
|
||||||
foreach ($list as $listitem) {
|
|
||||||
if (strpos($treffer[1], $listitem) !== false) {
|
|
||||||
$ignore = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((strpos($treffer[1], "//twitter.com/") !== false) && (strpos($treffer[1], "/status/") !== false)) {
|
|
||||||
$ignore = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((strpos($treffer[1], "//plus.google.com/") !== false) && (strpos($treffer[1], "/posts") !== false)) {
|
|
||||||
$ignore = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((strpos($treffer[1], "//plus.google.com/") !== false) && (strpos($treffer[1], "/photos") !== false)) {
|
|
||||||
$ignore = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$ignore) {
|
|
||||||
$urls[$treffer[1]] = $treffer[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $urls;
|
|
||||||
}
|
|
||||||
|
|
||||||
function html2plain($html, $wraplength = 75, $compact = false)
|
|
||||||
{
|
|
||||||
global $lang;
|
|
||||||
|
|
||||||
$message = str_replace("\r", "", $html);
|
|
||||||
|
|
||||||
$doc = new DOMDocument();
|
|
||||||
$doc->preserveWhiteSpace = false;
|
|
||||||
|
|
||||||
$message = mb_convert_encoding($message, 'HTML-ENTITIES', "UTF-8");
|
|
||||||
|
|
||||||
@$doc->loadHTML($message);
|
|
||||||
|
|
||||||
$xpath = new DomXPath($doc);
|
|
||||||
$list = $xpath->query("//pre");
|
|
||||||
foreach ($list as $node) {
|
|
||||||
$node->nodeValue = str_replace("\n", "\r", $node->nodeValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
$message = $doc->saveHTML();
|
|
||||||
$message = str_replace(["\n<", ">\n", "\r", "\n", "\xC3\x82\xC2\xA0"], ["<", ">", "<br>", " ", ""], $message);
|
|
||||||
$message = preg_replace('= [\s]*=i', " ", $message);
|
|
||||||
|
|
||||||
// Collecting all links
|
|
||||||
$urls = collecturls($message);
|
|
||||||
|
|
||||||
@$doc->loadHTML($message);
|
|
||||||
|
|
||||||
node2bbcode($doc, 'html', [], '', '');
|
|
||||||
node2bbcode($doc, 'body', [], '', '');
|
|
||||||
|
|
||||||
// MyBB-Auszeichnungen
|
|
||||||
/*
|
|
||||||
node2bbcode($doc, 'span', array('style'=>'text-decoration: underline;'), '_', '_');
|
|
||||||
node2bbcode($doc, 'span', array('style'=>'font-style: italic;'), '/', '/');
|
|
||||||
node2bbcode($doc, 'span', array('style'=>'font-weight: bold;'), '*', '*');
|
|
||||||
|
|
||||||
node2bbcode($doc, 'strong', array(), '*', '*');
|
|
||||||
node2bbcode($doc, 'b', array(), '*', '*');
|
|
||||||
node2bbcode($doc, 'i', array(), '/', '/');
|
|
||||||
node2bbcode($doc, 'u', array(), '_', '_');
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ($compact) {
|
|
||||||
node2bbcode($doc, 'blockquote', [], "»", "«");
|
|
||||||
} else {
|
|
||||||
node2bbcode($doc, 'blockquote', [], '[quote]', "[/quote]\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
node2bbcode($doc, 'br', [], "\n", '');
|
|
||||||
|
|
||||||
node2bbcode($doc, 'span', [], "", "");
|
|
||||||
node2bbcode($doc, 'pre', [], "", "");
|
|
||||||
node2bbcode($doc, 'div', [], "\r", "\r");
|
|
||||||
node2bbcode($doc, 'p', [], "\n", "\n");
|
|
||||||
|
|
||||||
//node2bbcode($doc, 'ul', array(), "\n[list]", "[/list]\n");
|
|
||||||
//node2bbcode($doc, 'ol', array(), "\n[list=1]", "[/list]\n");
|
|
||||||
node2bbcode($doc, 'li', [], "\n* ", "\n");
|
|
||||||
|
|
||||||
node2bbcode($doc, 'hr', [], "\n" . str_repeat("-", 70) . "\n", "");
|
|
||||||
|
|
||||||
node2bbcode($doc, 'tr', [], "\n", "");
|
|
||||||
node2bbcode($doc, 'td', [], "\t", "");
|
|
||||||
|
|
||||||
node2bbcode($doc, 'h1', [], "\n\n*", "*\n");
|
|
||||||
node2bbcode($doc, 'h2', [], "\n\n*", "*\n");
|
|
||||||
node2bbcode($doc, 'h3', [], "\n\n*", "*\n");
|
|
||||||
node2bbcode($doc, 'h4', [], "\n\n*", "*\n");
|
|
||||||
node2bbcode($doc, 'h5', [], "\n\n*", "*\n");
|
|
||||||
node2bbcode($doc, 'h6', [], "\n\n*", "*\n");
|
|
||||||
|
|
||||||
// Problem: there is no reliable way to detect if it is a link to a tag or profile
|
|
||||||
//node2bbcode($doc, 'a', array('href'=>'/(.+)/'), ' $1 ', ' ', true);
|
|
||||||
//node2bbcode($doc, 'a', array('href'=>'/(.+)/', 'rel'=>'oembed'), ' $1 ', '', true);
|
|
||||||
//node2bbcode($doc, 'img', array('alt'=>'/(.+)/'), '$1', '');
|
|
||||||
//node2bbcode($doc, 'img', array('title'=>'/(.+)/'), '$1', '');
|
|
||||||
//node2bbcode($doc, 'img', array(), '', '');
|
|
||||||
if (!$compact) {
|
|
||||||
node2bbcode($doc, 'img', ['src' => '/(.+)/'], ' [img]$1', '[/img] ');
|
|
||||||
} else {
|
|
||||||
node2bbcode($doc, 'img', ['src' => '/(.+)/'], ' ', ' ');
|
|
||||||
}
|
|
||||||
|
|
||||||
node2bbcode($doc, 'iframe', ['src' => '/(.+)/'], ' $1 ', '');
|
|
||||||
|
|
||||||
$message = $doc->saveHTML();
|
|
||||||
|
|
||||||
if (!$compact) {
|
|
||||||
$message = str_replace("[img]", "", $message);
|
|
||||||
$message = str_replace("[/img]", "", $message);
|
|
||||||
}
|
|
||||||
|
|
||||||
// was ersetze ich da?
|
|
||||||
// Irgendein stoerrisches UTF-Zeug
|
|
||||||
$message = str_replace(chr(194) . chr(160), ' ', $message);
|
|
||||||
|
|
||||||
$message = str_replace(" ", " ", $message);
|
|
||||||
|
|
||||||
// Aufeinanderfolgende DIVs
|
|
||||||
$message = preg_replace('=\r *\r=i', "\n", $message);
|
|
||||||
$message = str_replace("\r", "\n", $message);
|
|
||||||
|
|
||||||
$message = strip_tags($message);
|
|
||||||
|
|
||||||
$message = html_entity_decode($message, ENT_QUOTES, 'UTF-8');
|
|
||||||
|
|
||||||
if (!$compact && ($message != '')) {
|
|
||||||
foreach ($urls as $id => $url) {
|
|
||||||
if ($url != '' && strpos($message, $url) === false) {
|
|
||||||
$message .= "\n" . $url . ' ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$message = str_replace("\n«", "«\n", $message);
|
|
||||||
$message = str_replace("»\n", "\n»", $message);
|
|
||||||
|
|
||||||
do {
|
|
||||||
$oldmessage = $message;
|
|
||||||
$message = str_replace("\n\n\n", "\n\n", $message);
|
|
||||||
} while ($oldmessage != $message);
|
|
||||||
|
|
||||||
$message = quotelevel(trim($message), $wraplength);
|
|
||||||
|
|
||||||
return trim($message);
|
|
||||||
}
|
|
|
@ -14,6 +14,7 @@ use Friendica\Core\L10n;
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBM;
|
use Friendica\Database\DBM;
|
||||||
|
use Friendica\Model\Event;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Model\Profile;
|
||||||
use Friendica\Render\FriendicaSmarty;
|
use Friendica\Render\FriendicaSmarty;
|
||||||
|
@ -21,7 +22,6 @@ use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Map;
|
use Friendica\Util\Map;
|
||||||
|
|
||||||
require_once "mod/proxy.php";
|
require_once "mod/proxy.php";
|
||||||
require_once "include/event.php";
|
|
||||||
require_once "include/conversation.php";
|
require_once "include/conversation.php";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1235,37 +1235,37 @@ function prepare_body(&$item, $attach = false, $preview = false) {
|
||||||
// In order to provide theme developers more possibilities, event items
|
// In order to provide theme developers more possibilities, event items
|
||||||
// are treated differently.
|
// are treated differently.
|
||||||
if ($item['object-type'] === ACTIVITY_OBJ_EVENT && isset($item['event-id'])) {
|
if ($item['object-type'] === ACTIVITY_OBJ_EVENT && isset($item['event-id'])) {
|
||||||
$ev = format_event_item($item);
|
$ev = Event::getItemHTML($item);
|
||||||
return $ev;
|
return $ev;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Config::get('system','suppress_tags')) {
|
$taglist = dba::p("SELECT `type`, `term`, `url` FROM `term` WHERE `otype` = ? AND `oid` = ? AND `type` IN (?, ?) ORDER BY `tid`",
|
||||||
$taglist = dba::p("SELECT `type`, `term`, `url` FROM `term` WHERE `otype` = ? AND `oid` = ? AND `type` IN (?, ?) ORDER BY `tid`",
|
intval(TERM_OBJ_POST), intval($item['id']), intval(TERM_HASHTAG), intval(TERM_MENTION));
|
||||||
intval(TERM_OBJ_POST), intval($item['id']), intval(TERM_HASHTAG), intval(TERM_MENTION));
|
|
||||||
|
|
||||||
while ($tag = dba::fetch($taglist)) {
|
while ($tag = dba::fetch($taglist)) {
|
||||||
if ($tag["url"] == "") {
|
if ($tag["url"] == "") {
|
||||||
$tag["url"] = $searchpath.strtolower($tag["term"]);
|
$tag["url"] = $searchpath . strtolower($tag["term"]);
|
||||||
}
|
|
||||||
|
|
||||||
$orig_tag = $tag["url"];
|
|
||||||
|
|
||||||
$tag["url"] = best_link_url($item, $sp, $tag["url"]);
|
|
||||||
|
|
||||||
if ($tag["type"] == TERM_HASHTAG) {
|
|
||||||
if ($orig_tag != $tag["url"]) {
|
|
||||||
$item['body'] = str_replace($orig_tag, $tag["url"], $item['body']);
|
|
||||||
}
|
|
||||||
$hashtags[] = "#<a href=\"".$tag["url"]."\" target=\"_blank\">".$tag["term"]."</a>";
|
|
||||||
$prefix = "#";
|
|
||||||
} elseif ($tag["type"] == TERM_MENTION) {
|
|
||||||
$mentions[] = "@<a href=\"".$tag["url"]."\" target=\"_blank\">".$tag["term"]."</a>";
|
|
||||||
$prefix = "@";
|
|
||||||
}
|
|
||||||
$tags[] = $prefix."<a href=\"".$tag["url"]."\" target=\"_blank\">".$tag["term"]."</a>";
|
|
||||||
}
|
}
|
||||||
dba::close($taglist);
|
|
||||||
|
$orig_tag = $tag["url"];
|
||||||
|
|
||||||
|
$tag["url"] = best_link_url($item, $sp, $tag["url"]);
|
||||||
|
|
||||||
|
if ($tag["type"] == TERM_HASHTAG) {
|
||||||
|
if ($orig_tag != $tag["url"]) {
|
||||||
|
$item['body'] = str_replace($orig_tag, $tag["url"], $item['body']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$hashtags[] = "#<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>";
|
||||||
|
$prefix = "#";
|
||||||
|
} elseif ($tag["type"] == TERM_MENTION) {
|
||||||
|
$mentions[] = "@<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>";
|
||||||
|
$prefix = "@";
|
||||||
|
}
|
||||||
|
|
||||||
|
$tags[] = $prefix . "<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>";
|
||||||
}
|
}
|
||||||
|
dba::close($taglist);
|
||||||
|
|
||||||
$item['tags'] = $tags;
|
$item['tags'] = $tags;
|
||||||
$item['hashtags'] = $hashtags;
|
$item['hashtags'] = $hashtags;
|
||||||
|
@ -2030,6 +2030,10 @@ function text_highlight($s, $lang) {
|
||||||
$lang = 'javascript';
|
$lang = 'javascript';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($lang === 'bash') {
|
||||||
|
$lang = 'sh';
|
||||||
|
}
|
||||||
|
|
||||||
// @TODO: Replace Text_Highlighter_Renderer_Html by scrivo/highlight.php
|
// @TODO: Replace Text_Highlighter_Renderer_Html by scrivo/highlight.php
|
||||||
|
|
||||||
// Autoload the library to make constants available
|
// Autoload the library to make constants available
|
||||||
|
|
11
index.php
11
index.php
|
@ -24,9 +24,7 @@ use Friendica\Module\Login;
|
||||||
|
|
||||||
require_once 'boot.php';
|
require_once 'boot.php';
|
||||||
|
|
||||||
if (empty($a)) {
|
$a = new App(__DIR__);
|
||||||
$a = new App(__DIR__);
|
|
||||||
}
|
|
||||||
BaseObject::setApp($a);
|
BaseObject::setApp($a);
|
||||||
|
|
||||||
// We assume that the index.php is called by a frontend process
|
// We assume that the index.php is called by a frontend process
|
||||||
|
@ -53,9 +51,13 @@ if (!$install) {
|
||||||
require_once "include/dba.php";
|
require_once "include/dba.php";
|
||||||
|
|
||||||
if (!$install) {
|
if (!$install) {
|
||||||
dba::connect($db_host, $db_user, $db_pass, $db_data, $install);
|
$result = dba::connect($db_host, $db_user, $db_pass, $db_data);
|
||||||
unset($db_host, $db_user, $db_pass, $db_data);
|
unset($db_host, $db_user, $db_pass, $db_data);
|
||||||
|
|
||||||
|
if (!$result) {
|
||||||
|
System::unavailable();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load configs from db. Overwrite configs from .htconfig.php
|
* Load configs from db. Overwrite configs from .htconfig.php
|
||||||
*/
|
*/
|
||||||
|
@ -78,6 +80,7 @@ if (!$install) {
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Config::init();
|
||||||
Session::init();
|
Session::init();
|
||||||
Addon::loadHooks();
|
Addon::loadHooks();
|
||||||
Addon::callHooks('init_1');
|
Addon::callHooks('init_1');
|
||||||
|
|
313
mod/acl.php
313
mod/acl.php
|
@ -1,12 +1,315 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/* ACL selector json backend */
|
/* ACL selector json backend */
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
|
use Friendica\Content\Widget;
|
||||||
|
use Friendica\Core\ACL;
|
||||||
|
use Friendica\Core\Addon;
|
||||||
|
use Friendica\Database\DBM;
|
||||||
|
use Friendica\Model\Contact;
|
||||||
|
|
||||||
require_once 'include/acl_selectors.php';
|
require_once 'include/dba.php';
|
||||||
|
require_once 'mod/proxy.php';
|
||||||
|
|
||||||
function acl_init(App $a) {
|
function acl_content(App $a)
|
||||||
acl_lookup($a);
|
{
|
||||||
|
if (!local_user()) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$start = defaults($_REQUEST, 'start' , 0);
|
||||||
|
$count = defaults($_REQUEST, 'count' , 100);
|
||||||
|
$search = defaults($_REQUEST, 'search' , '');
|
||||||
|
$type = defaults($_REQUEST, 'type' , '');
|
||||||
|
$conv_id = defaults($_REQUEST, 'conversation', null);
|
||||||
|
|
||||||
|
// For use with jquery.textcomplete for private mail completion
|
||||||
|
if (!empty($_REQUEST['query'])) {
|
||||||
|
if (!$type) {
|
||||||
|
$type = 'm';
|
||||||
|
}
|
||||||
|
$search = $_REQUEST['query'];
|
||||||
|
}
|
||||||
|
|
||||||
|
logger("Searching for ".$search." - type ".$type." conversation ".$conv_id, LOGGER_DEBUG);
|
||||||
|
|
||||||
|
if ($search != '') {
|
||||||
|
$sql_extra = "AND `name` LIKE '%%" . dbesc($search) . "%%'";
|
||||||
|
$sql_extra2 = "AND (`attag` LIKE '%%" . dbesc($search) . "%%' OR `name` LIKE '%%" . dbesc($search) . "%%' OR `nick` LIKE '%%" . dbesc($search) . "%%')";
|
||||||
|
} else {
|
||||||
|
/// @TODO Avoid these needless else blocks by putting variable-initialization atop of if()
|
||||||
|
$sql_extra = $sql_extra2 = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// count groups and contacts
|
||||||
|
$group_count = 0;
|
||||||
|
if ($type == '' || $type == 'g') {
|
||||||
|
$r = q("SELECT COUNT(*) AS g FROM `group` WHERE `deleted` = 0 AND `uid` = %d $sql_extra",
|
||||||
|
intval(local_user())
|
||||||
|
);
|
||||||
|
$group_count = (int) $r[0]['g'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql_extra2 .= ' ' . Widget::unavailableNetworks();
|
||||||
|
|
||||||
|
$contact_count = 0;
|
||||||
|
if ($type == '' || $type == 'c') {
|
||||||
|
// autocomplete for editor mentions
|
||||||
|
$r = q("SELECT COUNT(*) AS c FROM `contact`
|
||||||
|
WHERE `uid` = %d AND NOT `self`
|
||||||
|
AND NOT `blocked` AND NOT `pending` AND NOT `archive`
|
||||||
|
AND `success_update` >= `failure_update`
|
||||||
|
AND `notify` != '' $sql_extra2",
|
||||||
|
intval(local_user())
|
||||||
|
);
|
||||||
|
$contact_count = (int) $r[0]['c'];
|
||||||
|
} elseif ($type == 'f') {
|
||||||
|
// autocomplete for editor mentions of forums
|
||||||
|
$r = q("SELECT COUNT(*) AS c FROM `contact`
|
||||||
|
WHERE `uid` = %d AND NOT `self`
|
||||||
|
AND NOT `blocked` AND NOT `pending` AND NOT `archive`
|
||||||
|
AND (`forum` OR `prv`)
|
||||||
|
AND `success_update` >= `failure_update`
|
||||||
|
AND `notify` != '' $sql_extra2",
|
||||||
|
intval(local_user())
|
||||||
|
);
|
||||||
|
$contact_count = (int) $r[0]['c'];
|
||||||
|
} elseif ($type == 'm') {
|
||||||
|
// autocomplete for Private Messages
|
||||||
|
$r = q("SELECT COUNT(*) AS c FROM `contact`
|
||||||
|
WHERE `uid` = %d AND NOT `self`
|
||||||
|
AND NOT `blocked` AND NOT `pending` AND NOT `archive`
|
||||||
|
AND `success_update` >= `failure_update`
|
||||||
|
AND `network` IN ('%s', '%s') $sql_extra2",
|
||||||
|
intval(local_user()),
|
||||||
|
dbesc(NETWORK_DFRN),
|
||||||
|
dbesc(NETWORK_DIASPORA)
|
||||||
|
);
|
||||||
|
$contact_count = (int) $r[0]['c'];
|
||||||
|
} elseif ($type == 'a') {
|
||||||
|
// autocomplete for Contacts
|
||||||
|
$r = q("SELECT COUNT(*) AS c FROM `contact`
|
||||||
|
WHERE `uid` = %d AND NOT `self`
|
||||||
|
AND NOT `pending` $sql_extra2",
|
||||||
|
intval(local_user())
|
||||||
|
);
|
||||||
|
$contact_count = (int) $r[0]['c'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$tot = $group_count + $contact_count;
|
||||||
|
|
||||||
|
$groups = [];
|
||||||
|
$contacts = [];
|
||||||
|
|
||||||
|
if ($type == '' || $type == 'g') {
|
||||||
|
/// @todo We should cache this query.
|
||||||
|
// This can be done when we can delete cache entries via wildcard
|
||||||
|
$r = q("SELECT `group`.`id`, `group`.`name`, GROUP_CONCAT(DISTINCT `group_member`.`contact-id` SEPARATOR ',') AS uids
|
||||||
|
FROM `group`
|
||||||
|
INNER JOIN `group_member` ON `group_member`.`gid`=`group`.`id`
|
||||||
|
WHERE NOT `group`.`deleted` AND `group`.`uid` = %d
|
||||||
|
$sql_extra
|
||||||
|
GROUP BY `group`.`name`, `group`.`id`
|
||||||
|
ORDER BY `group`.`name`
|
||||||
|
LIMIT %d,%d",
|
||||||
|
intval(local_user()),
|
||||||
|
intval($start),
|
||||||
|
intval($count)
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($r as $g) {
|
||||||
|
$groups[] = [
|
||||||
|
'type' => 'g',
|
||||||
|
'photo' => 'images/twopeople.png',
|
||||||
|
'name' => htmlentities($g['name']),
|
||||||
|
'id' => intval($g['id']),
|
||||||
|
'uids' => array_map('intval', explode(',', $g['uids'])),
|
||||||
|
'link' => '',
|
||||||
|
'forum' => '0'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
if ((count($groups) > 0) && ($search == '')) {
|
||||||
|
$groups[] = ['separator' => true];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$r = [];
|
||||||
|
if ($type == '') {
|
||||||
|
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv`, (`prv` OR `forum`) AS `frm` FROM `contact`
|
||||||
|
WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
|
||||||
|
AND `success_update` >= `failure_update` AND NOT (`network` IN ('%s', '%s'))
|
||||||
|
$sql_extra2
|
||||||
|
ORDER BY `name` ASC ",
|
||||||
|
intval(local_user()),
|
||||||
|
dbesc(NETWORK_OSTATUS),
|
||||||
|
dbesc(NETWORK_STATUSNET)
|
||||||
|
);
|
||||||
|
} elseif ($type == 'c') {
|
||||||
|
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv` FROM `contact`
|
||||||
|
WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
|
||||||
|
AND `success_update` >= `failure_update` AND NOT (`network` IN ('%s'))
|
||||||
|
$sql_extra2
|
||||||
|
ORDER BY `name` ASC ",
|
||||||
|
intval(local_user()),
|
||||||
|
dbesc(NETWORK_STATUSNET)
|
||||||
|
);
|
||||||
|
} elseif ($type == 'f') {
|
||||||
|
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv` FROM `contact`
|
||||||
|
WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
|
||||||
|
AND `success_update` >= `failure_update` AND NOT (`network` IN ('%s'))
|
||||||
|
AND (`forum` OR `prv`)
|
||||||
|
$sql_extra2
|
||||||
|
ORDER BY `name` ASC ",
|
||||||
|
intval(local_user()),
|
||||||
|
dbesc(NETWORK_STATUSNET)
|
||||||
|
);
|
||||||
|
} elseif ($type == 'm') {
|
||||||
|
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr` FROM `contact`
|
||||||
|
WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive`
|
||||||
|
AND `success_update` >= `failure_update` AND `network` IN ('%s', '%s')
|
||||||
|
$sql_extra2
|
||||||
|
ORDER BY `name` ASC ",
|
||||||
|
intval(local_user()),
|
||||||
|
dbesc(NETWORK_DFRN),
|
||||||
|
dbesc(NETWORK_DIASPORA)
|
||||||
|
);
|
||||||
|
} elseif ($type == 'a') {
|
||||||
|
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv` FROM `contact`
|
||||||
|
WHERE `uid` = %d AND `pending` = 0 AND `success_update` >= `failure_update`
|
||||||
|
$sql_extra2
|
||||||
|
ORDER BY `name` ASC ",
|
||||||
|
intval(local_user())
|
||||||
|
);
|
||||||
|
} elseif ($type == 'x') {
|
||||||
|
// autocomplete for global contact search (e.g. navbar search)
|
||||||
|
$search = notags(trim($_REQUEST['search']));
|
||||||
|
$mode = $_REQUEST['smode'];
|
||||||
|
|
||||||
|
$r = ACL::contactAutocomplete($search, $mode);
|
||||||
|
|
||||||
|
$contacts = [];
|
||||||
|
foreach ($r as $g) {
|
||||||
|
$contacts[] = [
|
||||||
|
'photo' => proxy_url($g['photo'], false, PROXY_SIZE_MICRO),
|
||||||
|
'name' => $g['name'],
|
||||||
|
'nick' => defaults($g, 'addr', $g['url']),
|
||||||
|
'network' => $g['network'],
|
||||||
|
'link' => $g['url'],
|
||||||
|
'forum' => !empty($g['community']) ? 1 : 0,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$o = [
|
||||||
|
'start' => $start,
|
||||||
|
'count' => $count,
|
||||||
|
'items' => $contacts,
|
||||||
|
];
|
||||||
|
echo json_encode($o);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DBM::is_result($r)) {
|
||||||
|
$forums = [];
|
||||||
|
foreach ($r as $g) {
|
||||||
|
$entry = [
|
||||||
|
'type' => 'c',
|
||||||
|
'photo' => proxy_url($g['micro'], false, PROXY_SIZE_MICRO),
|
||||||
|
'name' => htmlentities($g['name']),
|
||||||
|
'id' => intval($g['id']),
|
||||||
|
'network' => $g['network'],
|
||||||
|
'link' => $g['url'],
|
||||||
|
'nick' => htmlentities(defaults($g, 'attag', $g['nick'])),
|
||||||
|
'addr' => htmlentities(defaults($g, 'addr', $g['url'])),
|
||||||
|
'forum' => !empty($g['forum']) || !empty($g['prv']) ? 1 : 0,
|
||||||
|
];
|
||||||
|
if ($entry['forum']) {
|
||||||
|
$forums[] = $entry;
|
||||||
|
} else {
|
||||||
|
$contacts[] = $entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count($forums) > 0) {
|
||||||
|
if ($search == '') {
|
||||||
|
$forums[] = ['separator' => true];
|
||||||
|
}
|
||||||
|
$contacts = array_merge($forums, $contacts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$items = array_merge($groups, $contacts);
|
||||||
|
|
||||||
|
if ($conv_id) {
|
||||||
|
// In multi threaded posts the conv_id is not the parent of the whole thread
|
||||||
|
$parent_item = dba::selectFirst('item', ['parent'], ['id' => $conv_id]);
|
||||||
|
if (DBM::is_result($parent_item)) {
|
||||||
|
$conv_id = $parent_item['parent'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* if $conv_id is set, get unknown contacts in thread
|
||||||
|
* but first get known contacts url to filter them out
|
||||||
|
*/
|
||||||
|
$known_contacts = array_map(function ($i) {
|
||||||
|
return dbesc($i['link']);
|
||||||
|
}, $contacts);
|
||||||
|
|
||||||
|
$unknown_contacts = [];
|
||||||
|
$r = q("SELECT `author-link`
|
||||||
|
FROM `item` WHERE `parent` = %d
|
||||||
|
AND (`author-name` LIKE '%%%s%%' OR `author-link` LIKE '%%%s%%')
|
||||||
|
AND `author-link` NOT IN ('%s')
|
||||||
|
GROUP BY `author-link`, `author-avatar`, `author-name`
|
||||||
|
ORDER BY `author-name` ASC
|
||||||
|
",
|
||||||
|
intval($conv_id),
|
||||||
|
dbesc($search),
|
||||||
|
dbesc($search),
|
||||||
|
implode("', '", $known_contacts)
|
||||||
|
);
|
||||||
|
if (DBM::is_result($r)) {
|
||||||
|
foreach ($r as $row) {
|
||||||
|
$contact = Contact::getDetailsByURL($row['author-link']);
|
||||||
|
|
||||||
|
if (count($contact) > 0) {
|
||||||
|
$unknown_contacts[] = [
|
||||||
|
'type' => 'c',
|
||||||
|
'photo' => proxy_url($contact['micro'], false, PROXY_SIZE_MICRO),
|
||||||
|
'name' => htmlentities($contact['name']),
|
||||||
|
'id' => intval($contact['cid']),
|
||||||
|
'network' => $contact['network'],
|
||||||
|
'link' => $contact['url'],
|
||||||
|
'nick' => htmlentities(defaults($contact, 'nick', $contact['addr'])),
|
||||||
|
'addr' => htmlentities(defaults($contact, 'addr', $contact['url'])),
|
||||||
|
'forum' => $contact['forum']
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$items = array_merge($items, $unknown_contacts);
|
||||||
|
$tot += count($unknown_contacts);
|
||||||
|
}
|
||||||
|
|
||||||
|
$results = [
|
||||||
|
'tot' => $tot,
|
||||||
|
'start' => $start,
|
||||||
|
'count' => $count,
|
||||||
|
'groups' => $groups,
|
||||||
|
'contacts' => $contacts,
|
||||||
|
'items' => $items,
|
||||||
|
'type' => $type,
|
||||||
|
'search' => $search,
|
||||||
|
];
|
||||||
|
|
||||||
|
Addon::callHooks('acl_lookup_end', $results);
|
||||||
|
|
||||||
|
$o = [
|
||||||
|
'tot' => $results['tot'],
|
||||||
|
'start' => $results['start'],
|
||||||
|
'count' => $results['count'],
|
||||||
|
'items' => $results['items'],
|
||||||
|
];
|
||||||
|
|
||||||
|
echo json_encode($o);
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
110
mod/admin.php
110
mod/admin.php
|
@ -109,6 +109,9 @@ function admin_post(App $a)
|
||||||
}
|
}
|
||||||
$return_path = 'admin/themes/' . $theme;
|
$return_path = 'admin/themes/' . $theme;
|
||||||
break;
|
break;
|
||||||
|
case 'tos':
|
||||||
|
admin_page_tos_post($a);
|
||||||
|
break;
|
||||||
case 'features':
|
case 'features':
|
||||||
admin_page_features_post($a);
|
admin_page_features_post($a);
|
||||||
break;
|
break;
|
||||||
|
@ -181,7 +184,8 @@ function admin_content(App $a)
|
||||||
'users' => ["admin/users/" , L10n::t("Users") , "users"],
|
'users' => ["admin/users/" , L10n::t("Users") , "users"],
|
||||||
'addons' => ["admin/addons/" , L10n::t("Addons") , "addons"],
|
'addons' => ["admin/addons/" , L10n::t("Addons") , "addons"],
|
||||||
'themes' => ["admin/themes/" , L10n::t("Themes") , "themes"],
|
'themes' => ["admin/themes/" , L10n::t("Themes") , "themes"],
|
||||||
'features' => ["admin/features/" , L10n::t("Additional features") , "features"] ]],
|
'features' => ["admin/features/" , L10n::t("Additional features") , "features"],
|
||||||
|
'tos' => ["admin/tos/" , L10n::t("Terms of Service") , "tos"] ]],
|
||||||
'database' => [ L10n::t('Database'), [
|
'database' => [ L10n::t('Database'), [
|
||||||
'dbsync' => ["admin/dbsync/" , L10n::t('DB updates') , "dbsync"],
|
'dbsync' => ["admin/dbsync/" , L10n::t('DB updates') , "dbsync"],
|
||||||
'queue' => ["admin/queue/" , L10n::t('Inspect Queue') , "queue"], ]],
|
'queue' => ["admin/queue/" , L10n::t('Inspect Queue') , "queue"], ]],
|
||||||
|
@ -265,6 +269,9 @@ function admin_content(App $a)
|
||||||
case 'deleteitem':
|
case 'deleteitem':
|
||||||
$o = admin_page_deleteitem($a);
|
$o = admin_page_deleteitem($a);
|
||||||
break;
|
break;
|
||||||
|
case 'tos':
|
||||||
|
$o = admin_page_tos($a);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
notice(L10n::t("Item not found."));
|
notice(L10n::t("Item not found."));
|
||||||
}
|
}
|
||||||
|
@ -281,6 +288,50 @@ function admin_content(App $a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Subpage to define the display of a Terms of Usage page.
|
||||||
|
*
|
||||||
|
* @param App $a
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function admin_page_tos(App $a)
|
||||||
|
{
|
||||||
|
$t = get_markup_template('admin/tos.tpl');
|
||||||
|
return replace_macros($t, [
|
||||||
|
'$title' => L10n::t('Administration'),
|
||||||
|
'$page' => L10n::t('Terms of Service'),
|
||||||
|
'$displaytos' => ['displaytos', L10n::t('Display Terms of Service'), Config::get('system', 'tosdisplay'), L10n::t('Enable the Terms of Service page. If this is enabled a link to the terms will be added to the registration form and the general information page.')],
|
||||||
|
'$displayprivstatement' => ['displayprivstatement', L10n::t('Display Privacy Statement'), Config::get('system','tosprivstatement'), L10n::t('Show some informations regarding the needed information to operate the node according e.g. to <a href="%s" target="_blank">EU-GDPR</a>.','https://en.wikipedia.org/wiki/General_Data_Protection_Regulation')],
|
||||||
|
'$tostext' => ['tostext', L10n::t('The Terms of Service'), Config::get('system', 'tostext'), L10n::t('Enter the Terms of Service for your node here. You can use BBCode. Headers of sections should be [h2] and below.')],
|
||||||
|
'$form_security_token' => get_form_security_token("admin_tos"),
|
||||||
|
'$submit' => L10n::t('Save Settings'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Process send data from Admin TOS Page
|
||||||
|
*
|
||||||
|
* @param App $a
|
||||||
|
*/
|
||||||
|
function admin_page_tos_post(App $a)
|
||||||
|
{
|
||||||
|
check_form_security_token_redirectOnErr('/admin/tos', 'admin_tos');
|
||||||
|
|
||||||
|
if (!x($_POST, "page_tos")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$displaytos = ((x($_POST, 'displaytos')) ? True : False);
|
||||||
|
$displayprivstatement = ((x($_POST, 'displayprivstatement')) ? True : False);
|
||||||
|
$tostext = ((x($_POST, 'tostext')) ? strip_tags(trim($_POST['tostext'])) : '');
|
||||||
|
|
||||||
|
Config::set('system', 'tosdisplay', $displaytos);
|
||||||
|
Config::set('system', 'tosprivstatement', $displayprivstatement);
|
||||||
|
Config::set('system', 'tostext', $tostext);
|
||||||
|
|
||||||
|
goaway('admin/tos');
|
||||||
|
|
||||||
|
return; // NOTREACHED
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Subpage to modify the server wide block list via the admin panel.
|
* @brief Subpage to modify the server wide block list via the admin panel.
|
||||||
*
|
*
|
||||||
|
@ -635,8 +686,21 @@ function admin_page_federation(App $a)
|
||||||
$v = $newVv;
|
$v = $newVv;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($v as $key => $vv)
|
// Assure that the versions are sorted correctly
|
||||||
$v[$key]["version"] = trim(strip_tags($vv["version"]));
|
$v2 = [];
|
||||||
|
$versions = [];
|
||||||
|
foreach ($v as $vv) {
|
||||||
|
$version = trim(strip_tags($vv["version"]));
|
||||||
|
$v2[$version] = $vv;
|
||||||
|
$versions[] = $version;
|
||||||
|
}
|
||||||
|
|
||||||
|
usort($versions, 'version_compare');
|
||||||
|
|
||||||
|
$v = [];
|
||||||
|
foreach ($versions as $version) {
|
||||||
|
$v[] = $v2[$version];
|
||||||
|
}
|
||||||
|
|
||||||
// the 3rd array item is needed for the JavaScript graphs as JS does
|
// the 3rd array item is needed for the JavaScript graphs as JS does
|
||||||
// not like some characters in the names of variables...
|
// not like some characters in the names of variables...
|
||||||
|
@ -718,7 +782,7 @@ function admin_page_summary(App $a)
|
||||||
$warningtext = [];
|
$warningtext = [];
|
||||||
if (DBM::is_result($r)) {
|
if (DBM::is_result($r)) {
|
||||||
$showwarning = true;
|
$showwarning = true;
|
||||||
$warningtext[] = L10n::t('Your DB still runs with MyISAM tables. You should change the engine type to InnoDB. As Friendica will use InnoDB only features in the future, you should change this! See <a href="%s">here</a> for a guide that may be helpful converting the table engines. You may also use the command <tt>php scripts/dbstructure.php toinnodb</tt> of your Friendica installation for an automatic conversion.<br />', 'https://dev.mysql.com/doc/refman/5.7/en/converting-tables-to-innodb.html');
|
$warningtext[] = L10n::t('Your DB still runs with MyISAM tables. You should change the engine type to InnoDB. As Friendica will use InnoDB only features in the future, you should change this! See <a href="%s">here</a> for a guide that may be helpful converting the table engines. You may also use the command <tt>php bin/console.php dbstructure toinnodb</tt> of your Friendica installation for an automatic conversion.<br />', 'https://dev.mysql.com/doc/refman/5.7/en/converting-tables-to-innodb.html');
|
||||||
}
|
}
|
||||||
// Check if github.com/friendica/master/VERSION is higher then
|
// Check if github.com/friendica/master/VERSION is higher then
|
||||||
// the local version of Friendica. Check is opt-in, source may be master or devel branch
|
// the local version of Friendica. Check is opt-in, source may be master or devel branch
|
||||||
|
@ -735,7 +799,7 @@ function admin_page_summary(App $a)
|
||||||
}
|
}
|
||||||
if (Config::get('system', 'dbupdate') == DB_UPDATE_FAILED) {
|
if (Config::get('system', 'dbupdate') == DB_UPDATE_FAILED) {
|
||||||
$showwarning = true;
|
$showwarning = true;
|
||||||
$warningtext[] = L10n::t('The database update failed. Please run "php scripts/dbstructure.php update" from the command line and have a look at the errors that might appear.');
|
$warningtext[] = L10n::t('The database update failed. Please run "php bin/console.php dbstructure update" from the command line and have a look at the errors that might appear.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$last_worker_call = Config::get('system', 'last_poller_execution', false);
|
$last_worker_call = Config::get('system', 'last_poller_execution', false);
|
||||||
|
@ -871,8 +935,9 @@ function admin_page_site_post(App $a)
|
||||||
update_table("gcontact", ['connect', 'addr'], $old_host, $new_host);
|
update_table("gcontact", ['connect', 'addr'], $old_host, $new_host);
|
||||||
|
|
||||||
// update config
|
// update config
|
||||||
$a->set_baseurl($new_url);
|
Config::set('system', 'hostname', parse_url($new_url, PHP_URL_HOST));
|
||||||
Config::set('system', 'url', $new_url);
|
Config::set('system', 'url', $new_url);
|
||||||
|
$a->set_baseurl($new_url);
|
||||||
|
|
||||||
// send relocate
|
// send relocate
|
||||||
$users = q("SELECT `uid` FROM `user` WHERE `account_removed` = 0 AND `account_expired` = 0");
|
$users = q("SELECT `uid` FROM `user` WHERE `account_removed` = 0 AND `account_expired` = 0");
|
||||||
|
@ -906,7 +971,7 @@ function admin_page_site_post(App $a)
|
||||||
$daily_registrations = ((x($_POST,'max_daily_registrations')) ? intval(trim($_POST['max_daily_registrations'])) :0);
|
$daily_registrations = ((x($_POST,'max_daily_registrations')) ? intval(trim($_POST['max_daily_registrations'])) :0);
|
||||||
$abandon_days = ((x($_POST,'abandon_days')) ? intval(trim($_POST['abandon_days'])) : 0);
|
$abandon_days = ((x($_POST,'abandon_days')) ? intval(trim($_POST['abandon_days'])) : 0);
|
||||||
|
|
||||||
$register_text = ((x($_POST,'register_text')) ? notags(trim($_POST['register_text'])) : '');
|
$register_text = ((x($_POST,'register_text')) ? strip_tags(trim($_POST['register_text'])) : '');
|
||||||
|
|
||||||
$allowed_sites = ((x($_POST,'allowed_sites')) ? notags(trim($_POST['allowed_sites'])) : '');
|
$allowed_sites = ((x($_POST,'allowed_sites')) ? notags(trim($_POST['allowed_sites'])) : '');
|
||||||
$allowed_email = ((x($_POST,'allowed_email')) ? notags(trim($_POST['allowed_email'])) : '');
|
$allowed_email = ((x($_POST,'allowed_email')) ? notags(trim($_POST['allowed_email'])) : '');
|
||||||
|
@ -960,11 +1025,19 @@ function admin_page_site_post(App $a)
|
||||||
$only_tag_search = ((x($_POST,'only_tag_search')) ? True : False);
|
$only_tag_search = ((x($_POST,'only_tag_search')) ? True : False);
|
||||||
$rino = ((x($_POST,'rino')) ? intval($_POST['rino']) : 0);
|
$rino = ((x($_POST,'rino')) ? intval($_POST['rino']) : 0);
|
||||||
$check_new_version_url = ((x($_POST, 'check_new_version_url')) ? notags(trim($_POST['check_new_version_url'])) : 'none');
|
$check_new_version_url = ((x($_POST, 'check_new_version_url')) ? notags(trim($_POST['check_new_version_url'])) : 'none');
|
||||||
|
|
||||||
$worker_queues = ((x($_POST,'worker_queues')) ? intval($_POST['worker_queues']) : 4);
|
$worker_queues = ((x($_POST,'worker_queues')) ? intval($_POST['worker_queues']) : 4);
|
||||||
$worker_dont_fork = ((x($_POST,'worker_dont_fork')) ? True : False);
|
$worker_dont_fork = ((x($_POST,'worker_dont_fork')) ? True : False);
|
||||||
$worker_fastlane = ((x($_POST,'worker_fastlane')) ? True : False);
|
$worker_fastlane = ((x($_POST,'worker_fastlane')) ? True : False);
|
||||||
$worker_frontend = ((x($_POST,'worker_frontend')) ? True : False);
|
$worker_frontend = ((x($_POST,'worker_frontend')) ? True : False);
|
||||||
|
|
||||||
|
$relay_directly = ((x($_POST,'relay_directly')) ? True : False);
|
||||||
|
$relay_server = ((x($_POST,'relay_server')) ? notags(trim($_POST['relay_server'])) : '');
|
||||||
|
$relay_subscribe = ((x($_POST,'relay_subscribe')) ? True : False);
|
||||||
|
$relay_scope = ((x($_POST,'relay_scope')) ? notags(trim($_POST['relay_scope'])) : '');
|
||||||
|
$relay_server_tags = ((x($_POST,'relay_server_tags')) ? notags(trim($_POST['relay_server_tags'])) : '');
|
||||||
|
$relay_user_tags = ((x($_POST,'relay_user_tags')) ? True : False);
|
||||||
|
|
||||||
// Has the directory url changed? If yes, then resubmit the existing profiles there
|
// Has the directory url changed? If yes, then resubmit the existing profiles there
|
||||||
if ($global_directory != Config::get('system', 'directory') && ($global_directory != '')) {
|
if ($global_directory != Config::get('system', 'directory') && ($global_directory != '')) {
|
||||||
Config::set('system', 'directory', $global_directory);
|
Config::set('system', 'directory', $global_directory);
|
||||||
|
@ -1118,10 +1191,19 @@ function admin_page_site_post(App $a)
|
||||||
Config::set('system', 'basepath', $basepath);
|
Config::set('system', 'basepath', $basepath);
|
||||||
Config::set('system', 'proxy_disabled', $proxy_disabled);
|
Config::set('system', 'proxy_disabled', $proxy_disabled);
|
||||||
Config::set('system', 'only_tag_search', $only_tag_search);
|
Config::set('system', 'only_tag_search', $only_tag_search);
|
||||||
|
|
||||||
Config::set('system', 'worker_queues', $worker_queues);
|
Config::set('system', 'worker_queues', $worker_queues);
|
||||||
Config::set('system', 'worker_dont_fork', $worker_dont_fork);
|
Config::set('system', 'worker_dont_fork', $worker_dont_fork);
|
||||||
Config::set('system', 'worker_fastlane', $worker_fastlane);
|
Config::set('system', 'worker_fastlane', $worker_fastlane);
|
||||||
Config::set('system', 'frontend_worker', $worker_frontend);
|
Config::set('system', 'frontend_worker', $worker_frontend);
|
||||||
|
|
||||||
|
Config::set('system', 'relay_directly', $relay_directly);
|
||||||
|
Config::set('system', 'relay_server', $relay_server);
|
||||||
|
Config::set('system', 'relay_subscribe', $relay_subscribe);
|
||||||
|
Config::set('system', 'relay_scope', $relay_scope);
|
||||||
|
Config::set('system', 'relay_server_tags', $relay_server_tags);
|
||||||
|
Config::set('system', 'relay_user_tags', $relay_user_tags);
|
||||||
|
|
||||||
Config::set('system', 'rino_encrypt', $rino);
|
Config::set('system', 'rino_encrypt', $rino);
|
||||||
|
|
||||||
info(L10n::t('Site settings updated.') . EOL);
|
info(L10n::t('Site settings updated.') . EOL);
|
||||||
|
@ -1270,6 +1352,7 @@ function admin_page_site(App $a)
|
||||||
'$portable_contacts' => L10n::t('Auto Discovered Contact Directory'),
|
'$portable_contacts' => L10n::t('Auto Discovered Contact Directory'),
|
||||||
'$performance' => L10n::t('Performance'),
|
'$performance' => L10n::t('Performance'),
|
||||||
'$worker_title' => L10n::t('Worker'),
|
'$worker_title' => L10n::t('Worker'),
|
||||||
|
'$relay_title' => L10n::t('Message Relay'),
|
||||||
'$relocate' => L10n::t('Relocate - WARNING: advanced function. Could make this server unreachable.'),
|
'$relocate' => L10n::t('Relocate - WARNING: advanced function. Could make this server unreachable.'),
|
||||||
'$baseurl' => System::baseUrl(true),
|
'$baseurl' => System::baseUrl(true),
|
||||||
// name, label, value, help string, extra data...
|
// name, label, value, help string, extra data...
|
||||||
|
@ -1293,7 +1376,7 @@ function admin_page_site(App $a)
|
||||||
|
|
||||||
'$register_policy' => ['register_policy', L10n::t("Register policy"), $a->config['register_policy'], "", $register_choices],
|
'$register_policy' => ['register_policy', L10n::t("Register policy"), $a->config['register_policy'], "", $register_choices],
|
||||||
'$daily_registrations' => ['max_daily_registrations', L10n::t("Maximum Daily Registrations"), Config::get('system', 'max_daily_registrations'), L10n::t("If registration is permitted above, this sets the maximum number of new user registrations to accept per day. If register is set to closed, this setting has no effect.")],
|
'$daily_registrations' => ['max_daily_registrations', L10n::t("Maximum Daily Registrations"), Config::get('system', 'max_daily_registrations'), L10n::t("If registration is permitted above, this sets the maximum number of new user registrations to accept per day. If register is set to closed, this setting has no effect.")],
|
||||||
'$register_text' => ['register_text', L10n::t("Register text"), $a->config['register_text'], L10n::t("Will be displayed prominently on the registration page.")],
|
'$register_text' => ['register_text', L10n::t("Register text"), $a->config['register_text'], L10n::t("Will be displayed prominently on the registration page. You can use BBCode here.")],
|
||||||
'$abandon_days' => ['abandon_days', L10n::t('Accounts abandoned after x days'), Config::get('system','account_abandon_days'), L10n::t('Will not waste system resources polling external sites for abandonded accounts. Enter 0 for no time limit.')],
|
'$abandon_days' => ['abandon_days', L10n::t('Accounts abandoned after x days'), Config::get('system','account_abandon_days'), L10n::t('Will not waste system resources polling external sites for abandonded accounts. Enter 0 for no time limit.')],
|
||||||
'$allowed_sites' => ['allowed_sites', L10n::t("Allowed friend domains"), Config::get('system','allowed_sites'), L10n::t("Comma separated list of domains which are allowed to establish friendships with this site. Wildcards are accepted. Empty to allow any domains")],
|
'$allowed_sites' => ['allowed_sites', L10n::t("Allowed friend domains"), Config::get('system','allowed_sites'), L10n::t("Comma separated list of domains which are allowed to establish friendships with this site. Wildcards are accepted. Empty to allow any domains")],
|
||||||
'$allowed_email' => ['allowed_email', L10n::t("Allowed email domains"), Config::get('system','allowed_email'), L10n::t("Comma separated list of domains which are allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains")],
|
'$allowed_email' => ['allowed_email', L10n::t("Allowed email domains"), Config::get('system','allowed_email'), L10n::t("Comma separated list of domains which are allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains")],
|
||||||
|
@ -1349,13 +1432,20 @@ function admin_page_site(App $a)
|
||||||
|
|
||||||
'$relocate_url' => ['relocate_url', L10n::t("New base url"), System::baseUrl(), L10n::t("Change base url for this server. Sends relocate message to all Friendica and Diaspora* contacts of all users.")],
|
'$relocate_url' => ['relocate_url', L10n::t("New base url"), System::baseUrl(), L10n::t("Change base url for this server. Sends relocate message to all Friendica and Diaspora* contacts of all users.")],
|
||||||
|
|
||||||
'$rino' => ['rino', L10n::t("RINO Encryption"), intval(Config::get('system','rino_encrypt')), L10n::t("Encryption layer between nodes."), [0 => "Disabled", 1 => "Enabled"]],
|
'$rino' => ['rino', L10n::t("RINO Encryption"), intval(Config::get('system','rino_encrypt')), L10n::t("Encryption layer between nodes."), [0 => L10n::t("Disabled"), 1 => L10n::t("Enabled")]],
|
||||||
|
|
||||||
'$worker_queues' => ['worker_queues', L10n::t("Maximum number of parallel workers"), Config::get('system','worker_queues'), L10n::t("On shared hosters set this to 2. On larger systems, values of 10 are great. Default value is 4.")],
|
'$worker_queues' => ['worker_queues', L10n::t("Maximum number of parallel workers"), Config::get('system','worker_queues'), L10n::t("On shared hosters set this to 2. On larger systems, values of 10 are great. Default value is 4.")],
|
||||||
'$worker_dont_fork' => ['worker_dont_fork', L10n::t("Don't use 'proc_open' with the worker"), Config::get('system','worker_dont_fork'), L10n::t("Enable this if your system doesn't allow the use of 'proc_open'. This can happen on shared hosters. If this is enabled you should increase the frequency of worker calls in your crontab.")],
|
'$worker_dont_fork' => ['worker_dont_fork', L10n::t("Don't use 'proc_open' with the worker"), Config::get('system','worker_dont_fork'), L10n::t("Enable this if your system doesn't allow the use of 'proc_open'. This can happen on shared hosters. If this is enabled you should increase the frequency of worker calls in your crontab.")],
|
||||||
'$worker_fastlane' => ['worker_fastlane', L10n::t("Enable fastlane"), Config::get('system','worker_fastlane'), L10n::t("When enabed, the fastlane mechanism starts an additional worker if processes with higher priority are blocked by processes of lower priority.")],
|
'$worker_fastlane' => ['worker_fastlane', L10n::t("Enable fastlane"), Config::get('system','worker_fastlane'), L10n::t("When enabed, the fastlane mechanism starts an additional worker if processes with higher priority are blocked by processes of lower priority.")],
|
||||||
'$worker_frontend' => ['worker_frontend', L10n::t('Enable frontend worker'), Config::get('system','frontend_worker'), L10n::t('When enabled the Worker process is triggered when backend access is performed \x28e.g. messages being delivered\x29. On smaller sites you might want to call %s/worker on a regular basis via an external cron job. You should only enable this option if you cannot utilize cron/scheduled jobs on your server.', System::baseUrl())],
|
'$worker_frontend' => ['worker_frontend', L10n::t('Enable frontend worker'), Config::get('system','frontend_worker'), L10n::t('When enabled the Worker process is triggered when backend access is performed \x28e.g. messages being delivered\x29. On smaller sites you might want to call %s/worker on a regular basis via an external cron job. You should only enable this option if you cannot utilize cron/scheduled jobs on your server.', System::baseUrl())],
|
||||||
|
|
||||||
|
'$relay_subscribe' => ['relay_subscribe', L10n::t("Subscribe to relay"), Config::get('system','relay_subscribe'), L10n::t("Enables the receiving of public posts from the relay. They will be included in the search, subscribed tags and on the global community page.")],
|
||||||
|
'$relay_server' => ['relay_server', L10n::t("Relay server"), Config::get('system','relay_server'), L10n::t("Address of the relay server where public posts should be send to. For example https://relay.diasp.org")],
|
||||||
|
'$relay_directly' => ['relay_directly', L10n::t("Direct relay transfer"), Config::get('system','relay_directly'), L10n::t("Enables the direct transfer to other servers without using the relay servers")],
|
||||||
|
'$relay_scope' => ['relay_scope', L10n::t("Relay scope"), Config::get('system','relay_scope'), L10n::t("Can be 'all' or 'tags'. 'all' means that every public post should be received. 'tags' means that only posts with selected tags should be received."), ['' => L10n::t('Disabled'), 'all' => L10n::t('all'), 'tags' => L10n::t('tags')]],
|
||||||
|
'$relay_server_tags' => ['relay_server_tags', L10n::t("Server tags"), Config::get('system','relay_server_tags'), L10n::t("Comma separated list of tags for the 'tags' subscription.")],
|
||||||
|
'$relay_user_tags' => ['relay_user_tags', L10n::t("Allow user tags"), Config::get('system','relay_user_tags'), L10n::t("If enabled, the tags from the saved searches will used for the 'tags' subscription in addition to the 'relay_server_tags'.")],
|
||||||
|
|
||||||
'$form_security_token' => get_form_security_token("admin_site")
|
'$form_security_token' => get_form_security_token("admin_site")
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -1508,6 +1598,8 @@ function admin_page_users_post(App $a)
|
||||||
If you are new and do not know anybody here, they may help
|
If you are new and do not know anybody here, they may help
|
||||||
you to make some new and interesting friends.
|
you to make some new and interesting friends.
|
||||||
|
|
||||||
|
If you ever want to delete your account, you can do so at %1$s/removeme
|
||||||
|
|
||||||
Thank you and welcome to %4$s.'));
|
Thank you and welcome to %4$s.'));
|
||||||
|
|
||||||
$preamble = sprintf($preamble, $user['username'], $a->config['sitename']);
|
$preamble = sprintf($preamble, $user['username'], $a->config['sitename']);
|
||||||
|
|
136
mod/babel.php
136
mod/babel.php
|
@ -3,13 +3,9 @@
|
||||||
* @file mod/babel.php
|
* @file mod/babel.php
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text;
|
||||||
use Friendica\Content\Text\Markdown;
|
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
|
|
||||||
require_once 'include/bb2diaspora.php';
|
|
||||||
require_once 'include/html2bbcode.php';
|
|
||||||
|
|
||||||
function visible_lf($s)
|
function visible_lf($s)
|
||||||
{
|
{
|
||||||
return str_replace("\n", '<br />', $s);
|
return str_replace("\n", '<br />', $s);
|
||||||
|
@ -17,64 +13,104 @@ function visible_lf($s)
|
||||||
|
|
||||||
function babel_content()
|
function babel_content()
|
||||||
{
|
{
|
||||||
$o = '<h1>Babel Diagnostic</h1>';
|
$results = [];
|
||||||
|
if (!empty($_REQUEST['text'])) {
|
||||||
|
switch (defaults($_REQUEST, 'type', 'bbcode')) {
|
||||||
|
case 'bbcode':
|
||||||
|
$bbcode = trim($_REQUEST['text']);
|
||||||
|
$results[] = [
|
||||||
|
'title' => L10n::t('Source input'),
|
||||||
|
'content' => visible_lf($bbcode)
|
||||||
|
];
|
||||||
|
|
||||||
$o .= '<form action="babel" method="post">';
|
$html = Text\BBCode::convert($bbcode);
|
||||||
$o .= L10n::t("Source \x28bbcode\x29 text:") . EOL;
|
$results[] = [
|
||||||
$o .= '<textarea name="text" cols="80" rows="10">' . htmlspecialchars($_REQUEST['text']) . '</textarea>' . EOL;
|
'title' => L10n::t("BBCode::convert \x28raw HTML\x29"),
|
||||||
$o .= '<input type="submit" name="submit" value="Submit" /></form>';
|
'content' => htmlspecialchars($html)
|
||||||
|
];
|
||||||
|
|
||||||
$o .= '<br /><br />';
|
$results[] = [
|
||||||
|
'title' => L10n::t('BBCode::convert'),
|
||||||
|
'content' => $html
|
||||||
|
];
|
||||||
|
|
||||||
$o .= '<form action="babel" method="post">';
|
$bbcode2 = Text\HTML::toBBCode($html);
|
||||||
$o .= L10n::t("Source \x28Diaspora\x29 text to convert to BBcode:") . EOL;
|
$results[] = [
|
||||||
$o .= '<textarea name="d2bbtext" cols="80" rows="10">' . htmlspecialchars($_REQUEST['d2bbtext']) . '</textarea>' . EOL;
|
'title' => L10n::t('BBCode::convert => HTML::toBBCode'),
|
||||||
$o .= '<input type="submit" name="submit" value="Submit" /></form>';
|
'content' => visible_lf($bbcode2)
|
||||||
|
];
|
||||||
|
|
||||||
$o .= '<br /><br />';
|
$markdown = Text\BBCode::toMarkdown($bbcode);
|
||||||
|
$results[] = [
|
||||||
|
'title' => L10n::t('BBCode::toMarkdown'),
|
||||||
|
'content' => visible_lf($markdown)
|
||||||
|
];
|
||||||
|
|
||||||
if (x($_REQUEST, 'text')) {
|
$html2 = Text\Markdown::convert($markdown);
|
||||||
$text = trim($_REQUEST['text']);
|
$results[] = [
|
||||||
$o .= '<h2>' . L10n::t('Source input: ') . '</h2>' . EOL . EOL;
|
'title' => L10n::t('BBCode::toMarkdown => Markdown::convert'),
|
||||||
$o .= visible_lf($text) . EOL . EOL;
|
'content' => $html2
|
||||||
|
];
|
||||||
|
|
||||||
$html = BBCode::convert($text);
|
$bbcode3 = Text\Markdown::toBBCode($markdown);
|
||||||
$o .= '<h2>' . L10n::t("bbcode \x28raw HTML\x29: ") . '</h2>' . EOL . EOL;
|
$results[] = [
|
||||||
$o .= htmlspecialchars($html) . EOL . EOL;
|
'title' => L10n::t('BBCode::toMarkdown => Markdown::toBBCode'),
|
||||||
|
'content' => visible_lf($bbcode3)
|
||||||
|
];
|
||||||
|
|
||||||
$o .= '<h2>' . L10n::t('bbcode: ') . '</h2>' . EOL . EOL;
|
$bbcode4 = Text\HTML::toBBCode($html2);
|
||||||
$o .= $html . EOL . EOL;
|
$results[] = [
|
||||||
|
'title' => L10n::t('BBCode::toMarkdown => Markdown::convert => HTML::toBBCode'),
|
||||||
|
'content' => visible_lf($bbcode4)
|
||||||
|
];
|
||||||
|
break;
|
||||||
|
case 'markdown':
|
||||||
|
$markdown = trim($_REQUEST['text']);
|
||||||
|
$results[] = [
|
||||||
|
'title' => L10n::t('Source input \x28Diaspora format\x29'),
|
||||||
|
'content' => '<pre>' . $markdown . '</pre>'
|
||||||
|
];
|
||||||
|
|
||||||
$bbcode = html2bbcode($html);
|
$bbcode = Text\Markdown::toBBCode($markdown);
|
||||||
$o .= '<h2>' . L10n::t('bbcode => html2bbcode: ') . '</h2>' . EOL . EOL;
|
$results[] = [
|
||||||
$o .= visible_lf($bbcode) . EOL . EOL;
|
'title' => L10n::t('Markdown::toBBCode'),
|
||||||
|
'content' => '<pre>' . $bbcode . '</pre>'
|
||||||
|
];
|
||||||
|
break;
|
||||||
|
case 'html' :
|
||||||
|
$html = trim($_REQUEST['text']);
|
||||||
|
$results[] = [
|
||||||
|
'title' => L10n::t("Raw HTML input"),
|
||||||
|
'content' => htmlspecialchars($html)
|
||||||
|
];
|
||||||
|
|
||||||
$diaspora = bb2diaspora($text);
|
$results[] = [
|
||||||
$o .= '<h2>' . L10n::t('bb2diaspora: ') . '</h2>' . EOL . EOL;
|
'title' => L10n::t('HTML Input'),
|
||||||
$o .= visible_lf($diaspora) . EOL . EOL;
|
'content' => $html
|
||||||
|
];
|
||||||
|
|
||||||
$html = Markdown::convert($diaspora);
|
$bbcode = Text\HTML::toBBCode($html);
|
||||||
$o .= '<h2>' . L10n::t('bb2diaspora => Markdown: ') . '</h2>' . EOL . EOL;
|
$results[] = [
|
||||||
$o .= $html . EOL . EOL;
|
'title' => L10n::t('HTML::toBBCode'),
|
||||||
|
'content' => visible_lf($bbcode)
|
||||||
|
];
|
||||||
|
|
||||||
$bbcode = diaspora2bb($diaspora);
|
$text = Text\HTML::toPlaintext($html);
|
||||||
$o .= '<h2>' . L10n::t('bb2diaspora => diaspora2bb: ') . '</h2>' . EOL . EOL;
|
$results[] = [
|
||||||
$o .= visible_lf($bbcode) . EOL . EOL;
|
'title' => L10n::t('HTML::toPlaintext'),
|
||||||
|
'content' => '<pre>' . $text . '</pre>'
|
||||||
$bbcode = html2bbcode($html);
|
];
|
||||||
$o .= '<h2>' . L10n::t('bbcode => html2bbcode: ') . '</h2>' . EOL . EOL;
|
}
|
||||||
$o .= visible_lf($bbcode) . EOL . EOL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x($_REQUEST, 'd2bbtext')) {
|
$tpl = get_markup_template('babel.tpl');
|
||||||
$d2bbtext = trim($_REQUEST['d2bbtext']);
|
$o = replace_macros($tpl, [
|
||||||
$o .= '<h2>' . L10n::t("Source input \x28Diaspora format\x29: ") . '</h2>' . EOL . EOL;
|
'$text' => ['text', L10n::t('Source text'), defaults($_REQUEST, 'text', ''), ''],
|
||||||
$o .= '<pre>' . $d2bbtext . '</pre>' . EOL . EOL;
|
'$type_bbcode' => ['type', L10n::t('BBCode'), 'bbcode', '', defaults($_REQUEST, 'type', 'bbcode') == 'bbcode'],
|
||||||
|
'$type_markdown' => ['type', L10n::t('Markdown'), 'markdown', '', defaults($_REQUEST, 'type', 'bbcode') == 'markdown'],
|
||||||
$bb = diaspora2bb($d2bbtext);
|
'$type_html' => ['type', L10n::t('HTML'), 'html', '', defaults($_REQUEST, 'type', 'bbcode') == 'html'],
|
||||||
$o .= '<h2>' . L10n::t('diaspora2bb: ') . '</h2>' . EOL . EOL;
|
'$results' => $results
|
||||||
$o .= '<pre>' . $bb . '</pre>' . EOL . EOL;
|
]);
|
||||||
}
|
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
/**
|
/**
|
||||||
* @file mod/bookmarklet.php
|
* @file mod/bookmarklet.php
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
|
use Friendica\Core\ACL;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Module\Login;
|
use Friendica\Module\Login;
|
||||||
|
@ -35,8 +37,8 @@ function bookmarklet_content(App $a)
|
||||||
'default_location' => $a->user['default-location'],
|
'default_location' => $a->user['default-location'],
|
||||||
'nickname' => $a->user['nickname'],
|
'nickname' => $a->user['nickname'],
|
||||||
'lockstate' => ((is_array($a->user) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid'])))) ? 'lock' : 'unlock'),
|
'lockstate' => ((is_array($a->user) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid'])))) ? 'lock' : 'unlock'),
|
||||||
'default_perms' => get_acl_permissions($a->user),
|
'default_perms' => ACL::getDefaultUserPermissions($a->user),
|
||||||
'acl' => populate_acl($a->user, true),
|
'acl' => ACL::getFullSelectorHTML($a->user, true),
|
||||||
'bang' => '',
|
'bang' => '',
|
||||||
'visitor' => 'block',
|
'visitor' => 'block',
|
||||||
'profile_uid' => local_user(),
|
'profile_uid' => local_user(),
|
||||||
|
|
30
mod/cal.php
30
mod/cal.php
|
@ -9,19 +9,19 @@
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\Content\Feature;
|
use Friendica\Content\Feature;
|
||||||
use Friendica\Content\Nav;
|
use Friendica\Content\Nav;
|
||||||
|
use Friendica\Content\Widget;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBM;
|
use Friendica\Database\DBM;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
|
use Friendica\Model\Event;
|
||||||
use Friendica\Model\Group;
|
use Friendica\Model\Group;
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Model\Profile;
|
||||||
use Friendica\Protocol\DFRN;
|
use Friendica\Protocol\DFRN;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Temporal;
|
use Friendica\Util\Temporal;
|
||||||
|
|
||||||
require_once 'include/event.php';
|
|
||||||
|
|
||||||
function cal_init(App $a)
|
function cal_init(App $a)
|
||||||
{
|
{
|
||||||
if ($a->argc > 1) {
|
if ($a->argc > 1) {
|
||||||
|
@ -64,7 +64,7 @@ function cal_init(App $a)
|
||||||
'$pdesc' => (($profile['pdesc'] != "") ? $profile['pdesc'] : ""),
|
'$pdesc' => (($profile['pdesc'] != "") ? $profile['pdesc'] : ""),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$cal_widget = widget_events();
|
$cal_widget = Widget\CalendarExport::getHTML();
|
||||||
|
|
||||||
if (!x($a->page, 'aside')) {
|
if (!x($a->page, 'aside')) {
|
||||||
$a->page['aside'] = '';
|
$a->page['aside'] = '';
|
||||||
|
@ -82,7 +82,7 @@ function cal_content(App $a)
|
||||||
Nav::setSelected('events');
|
Nav::setSelected('events');
|
||||||
|
|
||||||
// get the translation strings for the callendar
|
// get the translation strings for the callendar
|
||||||
$i18n = get_event_strings();
|
$i18n = Event::getStrings();
|
||||||
|
|
||||||
$htpl = get_markup_template('event_head.tpl');
|
$htpl = get_markup_template('event_head.tpl');
|
||||||
$a->page['htmlhead'] .= replace_macros($htpl, [
|
$a->page['htmlhead'] .= replace_macros($htpl, [
|
||||||
|
@ -212,25 +212,25 @@ function cal_content(App $a)
|
||||||
|
|
||||||
// put the event parametes in an array so we can better transmit them
|
// put the event parametes in an array so we can better transmit them
|
||||||
$event_params = [
|
$event_params = [
|
||||||
'event_id' => (x($_GET, 'id') ? $_GET["id"] : 0),
|
'event_id' => intval(defaults($_GET, 'id', 0)),
|
||||||
'start' => $start,
|
'start' => $start,
|
||||||
'finish' => $finish,
|
'finish' => $finish,
|
||||||
'adjust_start' => $adjust_start,
|
'adjust_start' => $adjust_start,
|
||||||
'adjust_finish' => $adjust_finish,
|
'adjust_finish' => $adjust_finish,
|
||||||
'ignored' => $ignored,
|
'ignore' => $ignored,
|
||||||
];
|
];
|
||||||
|
|
||||||
// get events by id or by date
|
// get events by id or by date
|
||||||
if (x($_GET, 'id')) {
|
if ($event_params['event_id']) {
|
||||||
$r = event_by_id($owner_uid, $event_params, $sql_extra);
|
$r = Event::getListById($owner_uid, $event_params['event-id'], $sql_extra);
|
||||||
} else {
|
} else {
|
||||||
$r = events_by_date($owner_uid, $event_params, $sql_extra);
|
$r = Event::getListByDate($owner_uid, $event_params, $sql_extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
$links = [];
|
$links = [];
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
if (DBM::is_result($r)) {
|
||||||
$r = sort_by_date($r);
|
$r = Event::sortByDate($r);
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
$j = $rr['adjust'] ? DateTimeFormat::local($rr['start'], 'j') : DateTimeFormat::utc($rr['start'], 'j');
|
$j = $rr['adjust'] ? DateTimeFormat::local($rr['start'], 'j') : DateTimeFormat::utc($rr['start'], 'j');
|
||||||
if (!x($links, $j)) {
|
if (!x($links, $j)) {
|
||||||
|
@ -240,7 +240,7 @@ function cal_content(App $a)
|
||||||
}
|
}
|
||||||
|
|
||||||
// transform the event in a usable array
|
// transform the event in a usable array
|
||||||
$events = process_events($r);
|
$events = Event::prepareListForTemplate($r);
|
||||||
|
|
||||||
if ($a->argv[2] === 'json') {
|
if ($a->argv[2] === 'json') {
|
||||||
echo json_encode($events);
|
echo json_encode($events);
|
||||||
|
@ -306,7 +306,7 @@ function cal_content(App $a)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the export data by uid
|
// Get the export data by uid
|
||||||
$evexport = event_export($owner_uid, $format);
|
$evexport = Event::exportListByUserId($owner_uid, $format);
|
||||||
|
|
||||||
if (!$evexport["success"]) {
|
if (!$evexport["success"]) {
|
||||||
if ($evexport["content"]) {
|
if ($evexport["content"]) {
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
/**
|
/**
|
||||||
* @file mod/community.php
|
* @file mod/community.php
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\Content\Nav;
|
use Friendica\Content\Nav;
|
||||||
|
use Friendica\Core\ACL;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
|
@ -104,7 +106,7 @@ function community_content(App $a, $update = 0)
|
||||||
'default_location' => $a->user['default-location'],
|
'default_location' => $a->user['default-location'],
|
||||||
'nickname' => $a->user['nickname'],
|
'nickname' => $a->user['nickname'],
|
||||||
'lockstate' => (is_array($a->user) && (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || strlen($a->user['deny_cid']) || strlen($a->user['deny_gid'])) ? 'lock' : 'unlock'),
|
'lockstate' => (is_array($a->user) && (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || strlen($a->user['deny_cid']) || strlen($a->user['deny_gid'])) ? 'lock' : 'unlock'),
|
||||||
'acl' => populate_acl($a->user, true),
|
'acl' => ACL::getFullSelectorHTML($a->user, true),
|
||||||
'bang' => '',
|
'bang' => '',
|
||||||
'visitor' => 'block',
|
'visitor' => 'block',
|
||||||
'profile_uid' => local_user(),
|
'profile_uid' => local_user(),
|
||||||
|
|
|
@ -12,16 +12,58 @@ use Friendica\Core\System;
|
||||||
use Friendica\Database\DBM;
|
use Friendica\Database\DBM;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Protocol\DFRN;
|
use Friendica\Protocol\DFRN;
|
||||||
|
use Friendica\Protocol\Diaspora;
|
||||||
|
|
||||||
require_once 'include/items.php';
|
require_once 'include/items.php';
|
||||||
require_once 'include/event.php';
|
|
||||||
|
|
||||||
function dfrn_notify_post(App $a) {
|
function dfrn_notify_post(App $a) {
|
||||||
logger(__function__, LOGGER_TRACE);
|
logger(__function__, LOGGER_TRACE);
|
||||||
|
|
||||||
if (empty($_POST)) {
|
$postdata = file_get_contents('php://input');
|
||||||
require_once 'mod/salmon.php';
|
|
||||||
salmon_post($a);
|
if (empty($_POST) || !empty($postdata)) {
|
||||||
|
$data = json_decode($postdata);
|
||||||
|
if (is_object($data)) {
|
||||||
|
$nick = defaults($a->argv, 1, '');
|
||||||
|
$user = dba::selectFirst('user', [], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]);
|
||||||
|
if (!DBM::is_result($user)) {
|
||||||
|
System::httpExit(500);
|
||||||
|
}
|
||||||
|
$msg = Diaspora::decodeRaw($user, $postdata);
|
||||||
|
|
||||||
|
// Check if the user has got this contact
|
||||||
|
$cid = Contact::getIdForURL($msg['author'], $user['uid']);
|
||||||
|
if (!$cid) {
|
||||||
|
// Otherwise there should be a public contact
|
||||||
|
$cid = Contact::getIdForURL($msg['author']);
|
||||||
|
if (!$cid) {
|
||||||
|
logger('Contact not found for address ' . $msg['author']);
|
||||||
|
System::xmlExit(3, 'Contact not found');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// We now have some contact, so we fetch it
|
||||||
|
$importer = dba::fetch_first("SELECT *, `name` as `senderName`
|
||||||
|
FROM `contact`
|
||||||
|
WHERE NOT `blocked` AND `id` = ? LIMIT 1",
|
||||||
|
$cid);
|
||||||
|
|
||||||
|
// This should never fail
|
||||||
|
if (!DBM::is_result($importer)) {
|
||||||
|
logger('Contact not found for address ' . $msg['author']);
|
||||||
|
System::xmlExit(3, 'Contact not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the user id. This is important if this is a public contact
|
||||||
|
$importer['importer_uid'] = $user['uid'];
|
||||||
|
|
||||||
|
// Now we should be able to import it
|
||||||
|
$ret = DFRN::import($msg['message'], $importer);
|
||||||
|
System::xmlExit($ret, 'Done');
|
||||||
|
} else {
|
||||||
|
require_once 'mod/salmon.php';
|
||||||
|
salmon_post($a, $postdata);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$dfrn_id = ((x($_POST,'dfrn_id')) ? notags(trim($_POST['dfrn_id'])) : '');
|
$dfrn_id = ((x($_POST,'dfrn_id')) ? notags(trim($_POST['dfrn_id'])) : '');
|
||||||
|
|
|
@ -78,13 +78,12 @@ function directory_content(App $a)
|
||||||
(`profile`.`prv_keywords` LIKE '%$search%'))";
|
(`profile`.`prv_keywords` LIKE '%$search%'))";
|
||||||
}
|
}
|
||||||
|
|
||||||
$publish = ((Config::get('system', 'publish_all')) ? '' : " AND `publish` = 1 " );
|
$publish = (Config::get('system', 'publish_all') ? '' : " AND `publish` = 1 " );
|
||||||
|
|
||||||
|
|
||||||
$cnt = dba::selectFirst("SELECT COUNT(*) AS `total` FROM `profile`
|
$cnt = dba::fetch_first("SELECT COUNT(*) AS `total` FROM `profile`
|
||||||
LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
|
LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
|
||||||
WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra "
|
WHERE `is-default` $publish AND NOT `user`.`blocked` $sql_extra");
|
||||||
);
|
|
||||||
if (DBM::is_result($cnt)) {
|
if (DBM::is_result($cnt)) {
|
||||||
$a->set_pager_total($cnt['total']);
|
$a->set_pager_total($cnt['total']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
|
use Friendica\Content\Text\HTML;
|
||||||
|
use Friendica\Core\ACL;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
|
@ -204,7 +206,6 @@ function display_content(App $a, $update = false, $update_uid = 0) {
|
||||||
|
|
||||||
require_once 'include/security.php';
|
require_once 'include/security.php';
|
||||||
require_once 'include/conversation.php';
|
require_once 'include/conversation.php';
|
||||||
require_once 'include/acl_selectors.php';
|
|
||||||
|
|
||||||
$o = '';
|
$o = '';
|
||||||
|
|
||||||
|
@ -321,7 +322,7 @@ function display_content(App $a, $update = false, $update_uid = 0) {
|
||||||
'default_location' => $a->user['default-location'],
|
'default_location' => $a->user['default-location'],
|
||||||
'nickname' => $a->user['nickname'],
|
'nickname' => $a->user['nickname'],
|
||||||
'lockstate' => (is_array($a->user) && (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || strlen($a->user['deny_cid']) || strlen($a->user['deny_gid'])) ? 'lock' : 'unlock'),
|
'lockstate' => (is_array($a->user) && (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || strlen($a->user['deny_cid']) || strlen($a->user['deny_gid'])) ? 'lock' : 'unlock'),
|
||||||
'acl' => populate_acl($a->user, true),
|
'acl' => ACL::getFullSelectorHTML($a->user, true),
|
||||||
'bang' => '',
|
'bang' => '',
|
||||||
'visitor' => 'block',
|
'visitor' => 'block',
|
||||||
'profile_uid' => local_user(),
|
'profile_uid' => local_user(),
|
||||||
|
@ -371,10 +372,8 @@ function display_content(App $a, $update = false, $update_uid = 0) {
|
||||||
$o .= conversation($a, $items, 'display', $update_uid);
|
$o .= conversation($a, $items, 'display', $update_uid);
|
||||||
|
|
||||||
// Preparing the meta header
|
// Preparing the meta header
|
||||||
require_once 'include/html2plain.php';
|
$description = trim(HTML::toPlaintext(BBCode::convert($s[0]["body"], false), 0, true));
|
||||||
|
$title = trim(HTML::toPlaintext(BBCode::convert($s[0]["title"], false), 0, true));
|
||||||
$description = trim(html2plain(BBCode::convert($s[0]["body"], false), 0, true));
|
|
||||||
$title = trim(html2plain(BBCode::convert($s[0]["title"], false), 0, true));
|
|
||||||
$author_name = $s[0]["author-name"];
|
$author_name = $s[0]["author-name"];
|
||||||
|
|
||||||
$image = $a->remove_baseurl($s[0]["author-thumb"]);
|
$image = $a->remove_baseurl($s[0]["author-thumb"]);
|
||||||
|
|
|
@ -10,8 +10,6 @@ use Friendica\Core\L10n;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBM;
|
use Friendica\Database\DBM;
|
||||||
|
|
||||||
require_once 'include/acl_selectors.php';
|
|
||||||
|
|
||||||
function editpost_content(App $a) {
|
function editpost_content(App $a) {
|
||||||
|
|
||||||
$o = '';
|
$o = '';
|
||||||
|
|
|
@ -6,16 +6,18 @@
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\Content\Nav;
|
use Friendica\Content\Nav;
|
||||||
|
use Friendica\Content\Widget\CalendarExport;
|
||||||
|
use Friendica\Core\ACL;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
use Friendica\Database\DBM;
|
use Friendica\Database\DBM;
|
||||||
|
use Friendica\Model\Event;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Model\Profile;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Temporal;
|
use Friendica\Util\Temporal;
|
||||||
|
|
||||||
require_once 'include/event.php';
|
|
||||||
require_once 'include/items.php';
|
require_once 'include/items.php';
|
||||||
|
|
||||||
function events_init(App $a) {
|
function events_init(App $a) {
|
||||||
|
@ -23,22 +25,22 @@ function events_init(App $a) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($a->argc > 1) {
|
// If it's a json request abort here because we don't
|
||||||
// If it's a json request abort here because we don't
|
// need the widget data
|
||||||
// need the widget data
|
if ($a->argc > 1 && $a->argv[1] === 'json') {
|
||||||
if ($a->argv[1] === 'json') {
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$cal_widget = widget_events();
|
|
||||||
|
|
||||||
if (! x($a->page,'aside')) {
|
|
||||||
$a->page['aside'] = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$a->page['aside'] .= $cal_widget;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($a->page['aside'])) {
|
||||||
|
$a->page['aside'] = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$a->data['user'] = $_SESSION['user'];
|
||||||
|
|
||||||
|
$cal_widget = CalendarExport::getHTML();
|
||||||
|
|
||||||
|
$a->page['aside'] .= $cal_widget;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +156,6 @@ function events_post(App $a) {
|
||||||
|
|
||||||
|
|
||||||
$datarray = [];
|
$datarray = [];
|
||||||
$datarray['guid'] = get_guid(32);
|
|
||||||
$datarray['start'] = $start;
|
$datarray['start'] = $start;
|
||||||
$datarray['finish'] = $finish;
|
$datarray['finish'] = $finish;
|
||||||
$datarray['summary'] = $summary;
|
$datarray['summary'] = $summary;
|
||||||
|
@ -169,18 +170,16 @@ function events_post(App $a) {
|
||||||
$datarray['allow_gid'] = $str_group_allow;
|
$datarray['allow_gid'] = $str_group_allow;
|
||||||
$datarray['deny_cid'] = $str_contact_deny;
|
$datarray['deny_cid'] = $str_contact_deny;
|
||||||
$datarray['deny_gid'] = $str_group_deny;
|
$datarray['deny_gid'] = $str_group_deny;
|
||||||
$datarray['private'] = (($private_event) ? 1 : 0);
|
$datarray['private'] = $private_event;
|
||||||
$datarray['id'] = $event_id;
|
$datarray['id'] = $event_id;
|
||||||
$datarray['created'] = $created;
|
|
||||||
$datarray['edited'] = $edited;
|
|
||||||
|
|
||||||
if (intval($_REQUEST['preview'])) {
|
if (intval($_REQUEST['preview'])) {
|
||||||
$html = format_event_html($datarray);
|
$html = Event::getHTML($datarray);
|
||||||
echo $html;
|
echo $html;
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
||||||
$item_id = event_store($datarray);
|
$item_id = Event::store($datarray);
|
||||||
|
|
||||||
if (! $cid) {
|
if (! $cid) {
|
||||||
Worker::add(PRIORITY_HIGH, "Notifier", "event", $item_id);
|
Worker::add(PRIORITY_HIGH, "Notifier", "event", $item_id);
|
||||||
|
@ -221,7 +220,7 @@ function events_content(App $a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the translation strings for the callendar
|
// get the translation strings for the callendar
|
||||||
$i18n = get_event_strings();
|
$i18n = Event::getStrings();
|
||||||
|
|
||||||
$htpl = get_markup_template('event_head.tpl');
|
$htpl = get_markup_template('event_head.tpl');
|
||||||
$a->page['htmlhead'] .= replace_macros($htpl, [
|
$a->page['htmlhead'] .= replace_macros($htpl, [
|
||||||
|
@ -330,25 +329,25 @@ function events_content(App $a) {
|
||||||
|
|
||||||
// put the event parametes in an array so we can better transmit them
|
// put the event parametes in an array so we can better transmit them
|
||||||
$event_params = [
|
$event_params = [
|
||||||
'event_id' => (x($_GET, 'id') ? $_GET['id'] : 0),
|
'event_id' => intval(defaults($_GET, 'id', 0)),
|
||||||
'start' => $start,
|
'start' => $start,
|
||||||
'finish' => $finish,
|
'finish' => $finish,
|
||||||
'adjust_start' => $adjust_start,
|
'adjust_start' => $adjust_start,
|
||||||
'adjust_finish' => $adjust_finish,
|
'adjust_finish' => $adjust_finish,
|
||||||
'ignored' => $ignored,
|
'ignore' => $ignored,
|
||||||
];
|
];
|
||||||
|
|
||||||
// get events by id or by date
|
// get events by id or by date
|
||||||
if (x($_GET, 'id')) {
|
if ($event_params['event_id']) {
|
||||||
$r = event_by_id(local_user(), $event_params);
|
$r = Event::getListById(local_user(), $event_params['event_id']);
|
||||||
} else {
|
} else {
|
||||||
$r = events_by_date(local_user(), $event_params);
|
$r = Event::getListByDate(local_user(), $event_params);
|
||||||
}
|
}
|
||||||
|
|
||||||
$links = [];
|
$links = [];
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
if (DBM::is_result($r)) {
|
||||||
$r = sort_by_date($r);
|
$r = Event::sortByDate($r);
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
$j = $rr['adjust'] ? DateTimeFormat::local($rr['start'], 'j') : DateTimeFormat::utc($rr['start'], 'j');
|
$j = $rr['adjust'] ? DateTimeFormat::local($rr['start'], 'j') : DateTimeFormat::utc($rr['start'], 'j');
|
||||||
if (! x($links,$j)) {
|
if (! x($links,$j)) {
|
||||||
|
@ -361,8 +360,8 @@ function events_content(App $a) {
|
||||||
|
|
||||||
// transform the event in a usable array
|
// transform the event in a usable array
|
||||||
if (DBM::is_result($r)) {
|
if (DBM::is_result($r)) {
|
||||||
$r = sort_by_date($r);
|
$r = Event::sortByDate($r);
|
||||||
$events = process_events($r);
|
$events = Event::prepareListForTemplate($r);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($a->argc > 1 && $a->argv[1] === 'json'){
|
if ($a->argc > 1 && $a->argv[1] === 'json'){
|
||||||
|
@ -371,7 +370,7 @@ function events_content(App $a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x($_GET, 'id')) {
|
if (x($_GET, 'id')) {
|
||||||
$tpl = get_markup_template("event.tpl");
|
$tpl = get_markup_template("event.tpl");
|
||||||
} else {
|
} else {
|
||||||
$tpl = get_markup_template("events_js.tpl");
|
$tpl = get_markup_template("events_js.tpl");
|
||||||
}
|
}
|
||||||
|
@ -478,12 +477,10 @@ function events_content(App $a) {
|
||||||
$fhour = ((x($orig_event)) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'H') : '00');
|
$fhour = ((x($orig_event)) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'H') : '00');
|
||||||
$fminute = ((x($orig_event)) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'i') : '00');
|
$fminute = ((x($orig_event)) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'i') : '00');
|
||||||
|
|
||||||
require_once 'include/acl_selectors.php' ;
|
$perms = ACL::getDefaultUserPermissions($orig_event);
|
||||||
|
|
||||||
$perms = get_acl_permissions($orig_event);
|
|
||||||
|
|
||||||
if ($mode === 'new' || $mode === 'copy') {
|
if ($mode === 'new' || $mode === 'copy') {
|
||||||
$acl = (($cid) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $a->user)));
|
$acl = (($cid) ? '' : ACL::getFullSelectorHTML(((x($orig_event)) ? $orig_event : $a->user)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we copy an old event, we need to remove the ID and URI
|
// If we copy an old event, we need to remove the ID and URI
|
||||||
|
@ -544,8 +541,7 @@ function events_content(App $a) {
|
||||||
if ($mode === 'drop' && $event_id) {
|
if ($mode === 'drop' && $event_id) {
|
||||||
$del = 0;
|
$del = 0;
|
||||||
|
|
||||||
$params = ['event_id' => ($event_id)];
|
$ev = Event::getListById(local_user(), $event_id);
|
||||||
$ev = event_by_id(local_user(), $params);
|
|
||||||
|
|
||||||
// Delete only real events (no birthdays)
|
// Delete only real events (no birthdays)
|
||||||
if (DBM::is_result($ev) && $ev[0]['type'] == 'event') {
|
if (DBM::is_result($ev) && $ev[0]['type'] == 'event') {
|
||||||
|
|
53
mod/feedtest.php
Normal file
53
mod/feedtest.php
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file_tag_list_to_file mod/feedtest.php
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
|
use Friendica\Model\Contact;
|
||||||
|
use Friendica\Protocol\Feed;
|
||||||
|
use Friendica\Util\Network;
|
||||||
|
|
||||||
|
require_once 'boot.php';
|
||||||
|
require_once 'include/dba.php';
|
||||||
|
require_once 'include/text.php';
|
||||||
|
|
||||||
|
function feedtest_content(App $a)
|
||||||
|
{
|
||||||
|
if (!local_user()) {
|
||||||
|
info(L10n::t('You must be logged in to use this module'));
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
$result = [];
|
||||||
|
if (!empty($_REQUEST['url'])) {
|
||||||
|
$url = $_REQUEST['url'];
|
||||||
|
|
||||||
|
$importer = dba::selectFirst('user', [], ['uid' => local_user()]);
|
||||||
|
|
||||||
|
$contact_id = Contact::getIdForURL($url, local_user(), true);
|
||||||
|
|
||||||
|
$contact = dba::selectFirst('contact', [], ['id' => $contact_id]);
|
||||||
|
|
||||||
|
$ret = Network::curl($contact['poll']);
|
||||||
|
$xml = $ret['body'];
|
||||||
|
|
||||||
|
$dummy = null;
|
||||||
|
$import_result = Feed::import($xml, $importer, $contact, $dummy, true);
|
||||||
|
|
||||||
|
$result = [
|
||||||
|
'input' => text_highlight($xml, 'xml'),
|
||||||
|
'output' => var_export($import_result, true),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$tpl = get_markup_template('feedtest.tpl');
|
||||||
|
$o = replace_macros($tpl, [
|
||||||
|
'$url' => ['url', L10n::t('Source URL'), defaults($_REQUEST, 'url', ''), ''],
|
||||||
|
'$result' => $result
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $o;
|
||||||
|
}
|
135
mod/follow.php
135
mod/follow.php
|
@ -11,10 +11,10 @@ use Friendica\Model\Profile;
|
||||||
use Friendica\Network\Probe;
|
use Friendica\Network\Probe;
|
||||||
use Friendica\Database\DBM;
|
use Friendica\Database\DBM;
|
||||||
|
|
||||||
function follow_post(App $a) {
|
function follow_post(App $a)
|
||||||
|
{
|
||||||
if (!local_user()) {
|
if (!local_user()) {
|
||||||
notice(L10n::t('Permission denied.') . EOL);
|
notice(L10n::t('Permission denied.'));
|
||||||
goaway($_SESSION['return_url']);
|
goaway($_SESSION['return_url']);
|
||||||
// NOTREACHED
|
// NOTREACHED
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ function follow_post(App $a) {
|
||||||
|
|
||||||
// Makes the connection request for friendica contacts easier
|
// Makes the connection request for friendica contacts easier
|
||||||
// This is just a precaution if maybe this page is called somewhere directly via POST
|
// This is just a precaution if maybe this page is called somewhere directly via POST
|
||||||
$_SESSION["fastlane"] = $url;
|
$_SESSION['fastlane'] = $url;
|
||||||
|
|
||||||
$result = Contact::createFromProbe($uid, $url, true);
|
$result = Contact::createFromProbe($uid, $url, true);
|
||||||
|
|
||||||
|
@ -39,19 +39,19 @@ function follow_post(App $a) {
|
||||||
}
|
}
|
||||||
goaway($return_url);
|
goaway($return_url);
|
||||||
} elseif ($result['cid']) {
|
} elseif ($result['cid']) {
|
||||||
goaway(System::baseUrl().'/contacts/'.$result['cid']);
|
goaway(System::baseUrl() . '/contacts/' . $result['cid']);
|
||||||
}
|
}
|
||||||
|
|
||||||
info(L10n::t('The contact could not be added.').EOL);
|
info(L10n::t('The contact could not be added.'));
|
||||||
|
|
||||||
goaway($return_url);
|
goaway($return_url);
|
||||||
// NOTREACHED
|
// NOTREACHED
|
||||||
}
|
}
|
||||||
|
|
||||||
function follow_content(App $a) {
|
function follow_content(App $a)
|
||||||
|
{
|
||||||
if (!local_user()) {
|
if (!local_user()) {
|
||||||
notice(L10n::t('Permission denied.') . EOL);
|
notice(L10n::t('Permission denied.'));
|
||||||
goaway($_SESSION['return_url']);
|
goaway($_SESSION['return_url']);
|
||||||
// NOTREACHED
|
// NOTREACHED
|
||||||
}
|
}
|
||||||
|
@ -70,8 +70,8 @@ function follow_content(App $a) {
|
||||||
|
|
||||||
if ($r) {
|
if ($r) {
|
||||||
if ($r[0]['pending']) {
|
if ($r[0]['pending']) {
|
||||||
notice(L10n::t('You already added this contact.').EOL);
|
notice(L10n::t('You already added this contact.'));
|
||||||
$submit = "";
|
$submit = '';
|
||||||
//goaway($_SESSION['return_url']);
|
//goaway($_SESSION['return_url']);
|
||||||
// NOTREACHED
|
// NOTREACHED
|
||||||
}
|
}
|
||||||
|
@ -79,104 +79,107 @@ function follow_content(App $a) {
|
||||||
|
|
||||||
$ret = Probe::uri($url);
|
$ret = Probe::uri($url);
|
||||||
|
|
||||||
if (($ret["network"] == NETWORK_DIASPORA) && !Config::get('system', 'diaspora_enabled')) {
|
if (($ret['network'] == NETWORK_DIASPORA) && !Config::get('system', 'diaspora_enabled')) {
|
||||||
notice(L10n::t("Diaspora support isn't enabled. Contact can't be added.") . EOL);
|
notice(L10n::t("Diaspora support isn't enabled. Contact can't be added."));
|
||||||
$submit = "";
|
$submit = '';
|
||||||
//goaway($_SESSION['return_url']);
|
//goaway($_SESSION['return_url']);
|
||||||
// NOTREACHED
|
// NOTREACHED
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($ret["network"] == NETWORK_OSTATUS) && Config::get('system', 'ostatus_disabled')) {
|
if (($ret['network'] == NETWORK_OSTATUS) && Config::get('system', 'ostatus_disabled')) {
|
||||||
notice(L10n::t("OStatus support is disabled. Contact can't be added.") . EOL);
|
notice(L10n::t("OStatus support is disabled. Contact can't be added."));
|
||||||
$submit = "";
|
$submit = '';
|
||||||
//goaway($_SESSION['return_url']);
|
//goaway($_SESSION['return_url']);
|
||||||
// NOTREACHED
|
// NOTREACHED
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ret["network"] == NETWORK_PHANTOM) {
|
if ($ret['network'] == NETWORK_PHANTOM) {
|
||||||
notice(L10n::t("The network type couldn't be detected. Contact can't be added.") . EOL);
|
notice(L10n::t("The network type couldn't be detected. Contact can't be added."));
|
||||||
$submit = "";
|
$submit = '';
|
||||||
//goaway($_SESSION['return_url']);
|
//goaway($_SESSION['return_url']);
|
||||||
// NOTREACHED
|
// NOTREACHED
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ret["network"] == NETWORK_MAIL) {
|
if ($ret['network'] == NETWORK_MAIL) {
|
||||||
$ret["url"] = $ret["addr"];
|
$ret['url'] = $ret['addr'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($ret['network'] === NETWORK_DFRN) && !DBM::is_result($r)) {
|
if (($ret['network'] === NETWORK_DFRN) && !DBM::is_result($r)) {
|
||||||
$request = $ret["request"];
|
$request = $ret['request'];
|
||||||
$tpl = get_markup_template('dfrn_request.tpl');
|
$tpl = get_markup_template('dfrn_request.tpl');
|
||||||
} else {
|
} else {
|
||||||
$request = System::baseUrl()."/follow";
|
$request = System::baseUrl() . '/follow';
|
||||||
$tpl = get_markup_template('auto_request.tpl');
|
$tpl = get_markup_template('auto_request.tpl');
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval($uid));
|
$r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval($uid));
|
||||||
|
|
||||||
if (!$r) {
|
if (!$r) {
|
||||||
notice(L10n::t('Permission denied.') . EOL);
|
notice(L10n::t('Permission denied.'));
|
||||||
goaway($_SESSION['return_url']);
|
goaway($_SESSION['return_url']);
|
||||||
// NOTREACHED
|
// NOTREACHED
|
||||||
}
|
}
|
||||||
|
|
||||||
$myaddr = $r[0]["url"];
|
$myaddr = $r[0]['url'];
|
||||||
$gcontact_id = 0;
|
$gcontact_id = 0;
|
||||||
|
|
||||||
// Makes the connection request for friendica contacts easier
|
// Makes the connection request for friendica contacts easier
|
||||||
$_SESSION["fastlane"] = $ret["url"];
|
$_SESSION['fastlane'] = $ret['url'];
|
||||||
|
|
||||||
$r = q("SELECT `id`, `location`, `about`, `keywords` FROM `gcontact` WHERE `nurl` = '%s'",
|
$r = q("SELECT `id`, `location`, `about`, `keywords` FROM `gcontact` WHERE `nurl` = '%s'",
|
||||||
normalise_link($ret["url"]));
|
normalise_link($ret['url']));
|
||||||
|
|
||||||
if (!$r) {
|
if (!$r) {
|
||||||
$r = [["location" => "", "about" => "", "keywords" => ""]];
|
$r = [['location' => '', 'about' => '', 'keywords' => '']];
|
||||||
} else {
|
} else {
|
||||||
$gcontact_id = $r[0]["id"];
|
$gcontact_id = $r[0]['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ret['network'] === NETWORK_DIASPORA) {
|
if ($ret['network'] === NETWORK_DIASPORA) {
|
||||||
$r[0]["location"] = "";
|
$r[0]['location'] = '';
|
||||||
$r[0]["about"] = "";
|
$r[0]['about'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$header = L10n::t("Connect/Follow");
|
$header = L10n::t('Connect/Follow');
|
||||||
|
|
||||||
$o = replace_macros($tpl, [
|
$o = replace_macros($tpl, [
|
||||||
'$header' => htmlentities($header),
|
'$header' => htmlentities($header),
|
||||||
//'$photo' => proxy_url($ret["photo"], false, PROXY_SIZE_SMALL),
|
//'$photo' => proxy_url($ret['photo'], false, PROXY_SIZE_SMALL),
|
||||||
'$desc' => "",
|
'$desc' => '',
|
||||||
'$pls_answer' => L10n::t('Please answer the following:'),
|
'$pls_answer' => L10n::t('Please answer the following:'),
|
||||||
'$does_know_you' => ['knowyou', L10n::t('Does %s know you?', $ret["name"]), false, '', [L10n::t('No'), L10n::t('Yes')]],
|
'$does_know_you' => ['knowyou', L10n::t('Does %s know you?', $ret['name']), false, '', [L10n::t('No'), L10n::t('Yes')]],
|
||||||
'$add_note' => L10n::t('Add a personal note:'),
|
'$add_note' => L10n::t('Add a personal note:'),
|
||||||
'$page_desc' => "",
|
'$page_desc' => '',
|
||||||
'$friendica' => "",
|
'$friendica' => '',
|
||||||
'$statusnet' => "",
|
'$statusnet' => '',
|
||||||
'$diaspora' => "",
|
'$diaspora' => '',
|
||||||
'$diasnote' => "",
|
'$diasnote' => '',
|
||||||
'$your_address' => L10n::t('Your Identity Address:'),
|
'$your_address' => L10n::t('Your Identity Address:'),
|
||||||
'$invite_desc' => "",
|
'$invite_desc' => '',
|
||||||
'$emailnet' => "",
|
'$emailnet' => '',
|
||||||
'$submit' => $submit,
|
'$submit' => $submit,
|
||||||
'$cancel' => L10n::t('Cancel'),
|
'$cancel' => L10n::t('Cancel'),
|
||||||
'$nickname' => "",
|
'$nickname' => '',
|
||||||
'$name' => $ret["name"],
|
'$name' => $ret['name'],
|
||||||
'$url' => $ret["url"],
|
'$url' => $ret['url'],
|
||||||
'$zrl' => Profile::zrl($ret["url"]),
|
'$zrl' => Profile::zrl($ret['url']),
|
||||||
'$url_label' => L10n::t("Profile URL"),
|
'$url_label' => L10n::t('Profile URL'),
|
||||||
'$myaddr' => $myaddr,
|
'$myaddr' => $myaddr,
|
||||||
'$request' => $request,
|
'$request' => $request,
|
||||||
/*'$location' => Friendica\Content\Text\BBCode::::convert($r[0]["location"]),
|
/*'$location' => Friendica\Content\Text\BBCode::::convert($r[0]['location']),
|
||||||
'$location_label' => L10n::t("Location:"),
|
'$location_label'=> L10n::t('Location:'),
|
||||||
'$about' => Friendica\Content\Text\BBCode::::convert($r[0]["about"], false, false),
|
'$about' => Friendica\Content\Text\BBCode::::convert($r[0]['about'], false, false),
|
||||||
'$about_label' => L10n::t("About:"), */
|
'$about_label' => L10n::t('About:'),*/
|
||||||
'$keywords' => $r[0]["keywords"],
|
'$keywords' => $r[0]['keywords'],
|
||||||
'$keywords_label' => L10n::t("Tags:")
|
'$keywords_label'=> L10n::t('Tags:')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$a->page['aside'] = "";
|
$a->page['aside'] = '';
|
||||||
|
|
||||||
Profile::load($a, "", 0, Contact::getDetailsByURL($ret["url"]), false);
|
$profiledata = Contact::getDetailsByURL($ret['url']);
|
||||||
|
if ($profiledata) {
|
||||||
|
Profile::load($a, '', 0, $profiledata, false);
|
||||||
|
}
|
||||||
|
|
||||||
if ($gcontact_id <> 0) {
|
if ($gcontact_id <> 0) {
|
||||||
$o .= replace_macros(get_markup_template('section_title.tpl'),
|
$o .= replace_macros(get_markup_template('section_title.tpl'),
|
||||||
|
@ -184,7 +187,7 @@ function follow_content(App $a) {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Show last public posts
|
// Show last public posts
|
||||||
$o .= Contact::getPostsFromUrl($ret["url"]);
|
$o .= Contact::getPostsFromUrl($ret['url']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
|
|
|
@ -116,6 +116,11 @@ function friendica_content(App $a)
|
||||||
} else {
|
} else {
|
||||||
$o .= '<p>' . L10n::t('No installed addons/apps') . '</p>' . PHP_EOL;
|
$o .= '<p>' . L10n::t('No installed addons/apps') . '</p>' . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Config::get('system', 'tosdisplay'))
|
||||||
|
{
|
||||||
|
$o .= '<p>'.L10n::t('Read about the <a href="%1$s/tos">Terms of Service</a> of this node.', System::baseurl()).'</p>';
|
||||||
|
}
|
||||||
|
|
||||||
$blocklist = Config::get('system', 'blocklist');
|
$blocklist = Config::get('system', 'blocklist');
|
||||||
if (count($blocklist)) {
|
if (count($blocklist)) {
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
|
use Friendica\Core\ACL;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
use Friendica\Database\DBM;
|
use Friendica\Database\DBM;
|
||||||
|
@ -75,8 +76,6 @@ function fsuggest_post(App $a)
|
||||||
|
|
||||||
function fsuggest_content(App $a)
|
function fsuggest_content(App $a)
|
||||||
{
|
{
|
||||||
require_once 'include/acl_selectors.php';
|
|
||||||
|
|
||||||
if (! local_user()) {
|
if (! local_user()) {
|
||||||
notice(L10n::t('Permission denied.') . EOL);
|
notice(L10n::t('Permission denied.') . EOL);
|
||||||
return;
|
return;
|
||||||
|
@ -105,11 +104,10 @@ function fsuggest_content(App $a)
|
||||||
|
|
||||||
$o .= '<form id="fsuggest-form" action="fsuggest/' . $contact_id . '" method="post" >';
|
$o .= '<form id="fsuggest-form" action="fsuggest/' . $contact_id . '" method="post" >';
|
||||||
|
|
||||||
$o .= contact_selector(
|
$o .= ACL::getSuggestContactSelectHTML(
|
||||||
'suggest',
|
'suggest',
|
||||||
'suggest-select',
|
'suggest-select',
|
||||||
['size' => 4, 'exclude' => $contact_id, 'networks' => 'DFRN_ONLY', 'single' => true],
|
['size' => 4, 'exclude' => $contact_id, 'networks' => 'DFRN_ONLY', 'single' => true]
|
||||||
false
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,6 @@ function group_content(App $a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($a->argc > 1) && (intval($a->argv[1]))) {
|
if (($a->argc > 1) && (intval($a->argv[1]))) {
|
||||||
require_once 'include/acl_selectors.php';
|
|
||||||
require_once 'mod/contacts.php';
|
require_once 'mod/contacts.php';
|
||||||
|
|
||||||
$r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1",
|
$r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1",
|
||||||
|
|
|
@ -808,7 +808,6 @@ function item_post(App $a) {
|
||||||
$link = '<a href="' . System::baseUrl() . '/profile/' . $a->user['nickname'] . '"><img src="' . $author['thumb'] . '" alt="' . $a->user['username'] . '" /></a><br /><br />';
|
$link = '<a href="' . System::baseUrl() . '/profile/' . $a->user['nickname'] . '"><img src="' . $author['thumb'] . '" alt="' . $a->user['username'] . '" /></a><br /><br />';
|
||||||
$html = prepare_body($datarray);
|
$html = prepare_body($datarray);
|
||||||
$message = '<html><body>' . $link . $html . $disclaimer . '</body></html>';
|
$message = '<html><body>' . $link . $html . $disclaimer . '</body></html>';
|
||||||
include_once 'include/html2plain.php';
|
|
||||||
$params = [
|
$params = [
|
||||||
'fromName' => $a->user['username'],
|
'fromName' => $a->user['username'],
|
||||||
'fromEmail' => $a->user['email'],
|
'fromEmail' => $a->user['email'],
|
||||||
|
@ -816,7 +815,7 @@ function item_post(App $a) {
|
||||||
'replyTo' => $a->user['email'],
|
'replyTo' => $a->user['email'],
|
||||||
'messageSubject' => $subject,
|
'messageSubject' => $subject,
|
||||||
'htmlVersion' => $message,
|
'htmlVersion' => $message,
|
||||||
'textVersion' => html2plain($html.$disclaimer)
|
'textVersion' => Friendica\Content\Text\HTML::toPlaintext($html.$disclaimer)
|
||||||
];
|
];
|
||||||
Emailer::send($params);
|
Emailer::send($params);
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,7 @@ function lostpass_post(App $a)
|
||||||
notification([
|
notification([
|
||||||
'type' => SYSTEM_EMAIL,
|
'type' => SYSTEM_EMAIL,
|
||||||
'to_email' => $user['email'],
|
'to_email' => $user['email'],
|
||||||
|
'uid' => $user['uid'],
|
||||||
'subject' => L10n::t('Password reset requested at %s', $sitename),
|
'subject' => L10n::t('Password reset requested at %s', $sitename),
|
||||||
'preamble' => $preamble,
|
'preamble' => $preamble,
|
||||||
'body' => $body
|
'body' => $body
|
||||||
|
@ -164,6 +165,7 @@ function lostpass_generate_password($user)
|
||||||
notification([
|
notification([
|
||||||
'type' => SYSTEM_EMAIL,
|
'type' => SYSTEM_EMAIL,
|
||||||
'to_email' => $user['email'],
|
'to_email' => $user['email'],
|
||||||
|
'uid' => $user['uid'],
|
||||||
'subject' => L10n::t('Your password has been changed at %s', $sitename),
|
'subject' => L10n::t('Your password has been changed at %s', $sitename),
|
||||||
'preamble' => $preamble,
|
'preamble' => $preamble,
|
||||||
'body' => $body
|
'body' => $body
|
||||||
|
|
|
@ -7,6 +7,7 @@ use Friendica\App;
|
||||||
use Friendica\Content\Nav;
|
use Friendica\Content\Nav;
|
||||||
use Friendica\Content\Smilies;
|
use Friendica\Content\Smilies;
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
|
use Friendica\Core\ACL;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBM;
|
use Friendica\Database\DBM;
|
||||||
|
@ -15,7 +16,6 @@ use Friendica\Model\Mail;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Temporal;
|
use Friendica\Util\Temporal;
|
||||||
|
|
||||||
require_once 'include/acl_selectors.php';
|
|
||||||
require_once 'include/conversation.php';
|
require_once 'include/conversation.php';
|
||||||
|
|
||||||
function message_init(App $a)
|
function message_init(App $a)
|
||||||
|
@ -207,7 +207,7 @@ function message_content(App $a)
|
||||||
'$linkurl' => L10n::t('Please enter a link URL:')
|
'$linkurl' => L10n::t('Please enter a link URL:')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$preselect = isset($a->argv[2]) ? [$a->argv[2]] : false;
|
$preselect = isset($a->argv[2]) ? [$a->argv[2]] : [];
|
||||||
|
|
||||||
$prename = $preurl = $preid = '';
|
$prename = $preurl = $preid = '';
|
||||||
|
|
||||||
|
@ -236,14 +236,14 @@ function message_content(App $a)
|
||||||
$preid = $r[0]['id'];
|
$preid = $r[0]['id'];
|
||||||
$preselect = [$preid];
|
$preselect = [$preid];
|
||||||
} else {
|
} else {
|
||||||
$preselect = false;
|
$preselect = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$prefill = $preselect ? $prename : '';
|
$prefill = $preselect ? $prename : '';
|
||||||
|
|
||||||
// the ugly select box
|
// the ugly select box
|
||||||
$select = contact_select('messageto', 'message-to-select', $preselect, 4, true, false, false, 10);
|
$select = ACL::getMessageContactSelectHTML('messageto', 'message-to-select', $preselect, 4, 10);
|
||||||
|
|
||||||
$tpl = get_markup_template('prv_message.tpl');
|
$tpl = get_markup_template('prv_message.tpl');
|
||||||
$o .= replace_macros($tpl, [
|
$o .= replace_macros($tpl, [
|
||||||
|
|
|
@ -9,6 +9,7 @@ use Friendica\Content\Feature;
|
||||||
use Friendica\Content\ForumManager;
|
use Friendica\Content\ForumManager;
|
||||||
use Friendica\Content\Nav;
|
use Friendica\Content\Nav;
|
||||||
use Friendica\Content\Widget;
|
use Friendica\Content\Widget;
|
||||||
|
use Friendica\Core\ACL;
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
|
@ -24,7 +25,6 @@ use Friendica\Util\DateTimeFormat;
|
||||||
|
|
||||||
require_once 'include/conversation.php';
|
require_once 'include/conversation.php';
|
||||||
require_once 'include/items.php';
|
require_once 'include/items.php';
|
||||||
require_once 'include/acl_selectors.php';
|
|
||||||
|
|
||||||
function network_init(App $a)
|
function network_init(App $a)
|
||||||
{
|
{
|
||||||
|
@ -427,8 +427,8 @@ function networkFlatView(App $a, $update = 0)
|
||||||
'lockstate' => (((is_array($a->user) &&
|
'lockstate' => (((is_array($a->user) &&
|
||||||
((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) ||
|
((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) ||
|
||||||
(strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid']))))) ? 'lock' : 'unlock'),
|
(strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid']))))) ? 'lock' : 'unlock'),
|
||||||
'default_perms' => get_acl_permissions($a->user),
|
'default_perms' => ACL::getDefaultUserPermissions($a->user),
|
||||||
'acl' => populate_acl($a->user, true),
|
'acl' => ACL::getFullSelectorHTML($a->user, true),
|
||||||
'bang' => '',
|
'bang' => '',
|
||||||
'visitor' => 'block',
|
'visitor' => 'block',
|
||||||
'profile_uid' => local_user(),
|
'profile_uid' => local_user(),
|
||||||
|
@ -576,8 +576,8 @@ function networkThreadedView(App $a, $update, $parent)
|
||||||
'lockstate' => ((($gid) || ($cid) || ($nets) || (is_array($a->user) &&
|
'lockstate' => ((($gid) || ($cid) || ($nets) || (is_array($a->user) &&
|
||||||
((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) ||
|
((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) ||
|
||||||
(strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid']))))) ? 'lock' : 'unlock'),
|
(strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid']))))) ? 'lock' : 'unlock'),
|
||||||
'default_perms' => get_acl_permissions($a->user),
|
'default_perms' => ACL::getDefaultUserPermissions($a->user),
|
||||||
'acl' => populate_acl((($gid || $cid || $nets) ? $def_acl : $a->user), true),
|
'acl' => ACL::getFullSelectorHTML((($gid || $cid || $nets) ? $def_acl : $a->user), true),
|
||||||
'bang' => (($gid || $cid || $nets) ? '!' : ''),
|
'bang' => (($gid || $cid || $nets) ? '!' : ''),
|
||||||
'visitor' => 'block',
|
'visitor' => 'block',
|
||||||
'profile_uid' => local_user(),
|
'profile_uid' => local_user(),
|
||||||
|
|
|
@ -33,7 +33,6 @@ function notes_content(App $a, $update = false)
|
||||||
|
|
||||||
require_once 'include/security.php';
|
require_once 'include/security.php';
|
||||||
require_once 'include/conversation.php';
|
require_once 'include/conversation.php';
|
||||||
require_once 'include/acl_selectors.php';
|
|
||||||
$groups = [];
|
$groups = [];
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,13 +46,11 @@ function oexchange_content(App $a) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once('include/html2bbcode.php');
|
|
||||||
|
|
||||||
$post = [];
|
$post = [];
|
||||||
|
|
||||||
$post['profile_uid'] = local_user();
|
$post['profile_uid'] = local_user();
|
||||||
$post['return'] = '/oexchange/done' ;
|
$post['return'] = '/oexchange/done' ;
|
||||||
$post['body'] = html2bbcode($s);
|
$post['body'] = Friendica\Content\Text\HTML::toBBCode($s);
|
||||||
$post['type'] = 'wall';
|
$post['type'] = 'wall';
|
||||||
|
|
||||||
$_REQUEST = $post;
|
$_REQUEST = $post;
|
||||||
|
|
|
@ -7,6 +7,7 @@ use Friendica\App;
|
||||||
use Friendica\Content\Feature;
|
use Friendica\Content\Feature;
|
||||||
use Friendica\Content\Nav;
|
use Friendica\Content\Nav;
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
|
use Friendica\Core\ACL;
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
|
@ -26,7 +27,6 @@ use Friendica\Util\Map;
|
||||||
use Friendica\Util\Temporal;
|
use Friendica\Util\Temporal;
|
||||||
|
|
||||||
require_once 'include/items.php';
|
require_once 'include/items.php';
|
||||||
require_once 'include/acl_selectors.php';
|
|
||||||
require_once 'include/security.php';
|
require_once 'include/security.php';
|
||||||
|
|
||||||
function photos_init(App $a) {
|
function photos_init(App $a) {
|
||||||
|
@ -1084,7 +1084,7 @@ function photos_content(App $a)
|
||||||
|
|
||||||
$tpl = get_markup_template('photos_upload.tpl');
|
$tpl = get_markup_template('photos_upload.tpl');
|
||||||
|
|
||||||
$aclselect_e = ($visitor ? '' : populate_acl($a->user));
|
$aclselect_e = ($visitor ? '' : ACL::getFullSelectorHTML($a->user));
|
||||||
|
|
||||||
$o .= replace_macros($tpl,[
|
$o .= replace_macros($tpl,[
|
||||||
'$pagename' => L10n::t('Upload Photos'),
|
'$pagename' => L10n::t('Upload Photos'),
|
||||||
|
@ -1425,7 +1425,7 @@ function photos_content(App $a)
|
||||||
|
|
||||||
$album_e = $ph[0]['album'];
|
$album_e = $ph[0]['album'];
|
||||||
$caption_e = $ph[0]['desc'];
|
$caption_e = $ph[0]['desc'];
|
||||||
$aclselect_e = populate_acl($ph[0]);
|
$aclselect_e = ACL::getFullSelectorHTML($ph[0]);
|
||||||
|
|
||||||
$edit = replace_macros($edit_tpl, [
|
$edit = replace_macros($edit_tpl, [
|
||||||
'$id' => $ph[0]['id'],
|
'$id' => $ph[0]['id'],
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\Content\Nav;
|
use Friendica\Content\Nav;
|
||||||
use Friendica\Content\Widget;
|
use Friendica\Content\Widget;
|
||||||
|
use Friendica\Core\ACL;
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
|
@ -118,7 +119,6 @@ function profile_content(App $a, $update = 0)
|
||||||
|
|
||||||
require_once 'include/security.php';
|
require_once 'include/security.php';
|
||||||
require_once 'include/conversation.php';
|
require_once 'include/conversation.php';
|
||||||
require_once 'include/acl_selectors.php';
|
|
||||||
require_once 'include/items.php';
|
require_once 'include/items.php';
|
||||||
|
|
||||||
$groups = [];
|
$groups = [];
|
||||||
|
@ -213,7 +213,7 @@ function profile_content(App $a, $update = 0)
|
||||||
|| strlen($a->user['deny_cid'])
|
|| strlen($a->user['deny_cid'])
|
||||||
|| strlen($a->user['deny_gid'])
|
|| strlen($a->user['deny_gid'])
|
||||||
) ? 'lock' : 'unlock',
|
) ? 'lock' : 'unlock',
|
||||||
'acl' => $is_owner ? populate_acl($a->user, true) : '',
|
'acl' => $is_owner ? ACL::getFullSelectorHTML($a->user, true) : '',
|
||||||
'bang' => '',
|
'bang' => '',
|
||||||
'visitor' => $is_owner || $commvisitor ? 'block' : 'none',
|
'visitor' => $is_owner || $commvisitor ? 'block' : 'none',
|
||||||
'profile_uid' => $a->profile['profile_uid'],
|
'profile_uid' => $a->profile['profile_uid'],
|
||||||
|
|
|
@ -9,6 +9,7 @@ use Friendica\Core\L10n;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
use Friendica\Database\DBM;
|
use Friendica\Database\DBM;
|
||||||
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Photo;
|
use Friendica\Model\Photo;
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Model\Profile;
|
||||||
use Friendica\Object\Image;
|
use Friendica\Object\Image;
|
||||||
|
@ -105,18 +106,11 @@ function profile_photo_post(App $a) {
|
||||||
|
|
||||||
// If setting for the default profile, unset the profile photo flag from any other photos I own
|
// If setting for the default profile, unset the profile photo flag from any other photos I own
|
||||||
|
|
||||||
if($is_default_profile) {
|
if ($is_default_profile) {
|
||||||
$r = q("UPDATE `photo` SET `profile` = 0 WHERE `profile` = 1 AND `resource-id` != '%s' AND `uid` = %d",
|
$r = q("UPDATE `photo` SET `profile` = 0 WHERE `profile` = 1 AND `resource-id` != '%s' AND `uid` = %d",
|
||||||
dbesc($base_image['resource-id']),
|
dbesc($base_image['resource-id']),
|
||||||
intval(local_user())
|
intval(local_user())
|
||||||
);
|
);
|
||||||
|
|
||||||
$r = q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `self` AND `uid` = %d",
|
|
||||||
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-4.' . $Image->getExt()),
|
|
||||||
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-5.' . $Image->getExt()),
|
|
||||||
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-6.' . $Image->getExt()),
|
|
||||||
intval(local_user())
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
$r = q("update profile set photo = '%s', thumb = '%s' where id = %d and uid = %d",
|
$r = q("update profile set photo = '%s', thumb = '%s' where id = %d and uid = %d",
|
||||||
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-4.' . $Image->getExt()),
|
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-4.' . $Image->getExt()),
|
||||||
|
@ -126,13 +120,7 @@ function profile_photo_post(App $a) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// we'll set the updated profile-photo timestamp even if it isn't the default profile,
|
Contact::updateSelfFromUserID(local_user(), true);
|
||||||
// so that browsers will do a cache update unconditionally
|
|
||||||
|
|
||||||
$r = q("UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d",
|
|
||||||
dbesc(DateTimeFormat::utcNow()),
|
|
||||||
intval(local_user())
|
|
||||||
);
|
|
||||||
|
|
||||||
info(L10n::t('Shift-reload the page or clear browser cache if the new photo does not display immediately.') . EOL);
|
info(L10n::t('Shift-reload the page or clear browser cache if the new photo does not display immediately.') . EOL);
|
||||||
// Update global directory in background
|
// Update global directory in background
|
||||||
|
@ -229,10 +217,7 @@ function profile_photo_content(App $a) {
|
||||||
dbesc($resource_id)
|
dbesc($resource_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
$r = q("UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d",
|
Contact::updateSelfFromUserID(local_user(), true);
|
||||||
dbesc(DateTimeFormat::utcNow()),
|
|
||||||
intval(local_user())
|
|
||||||
);
|
|
||||||
|
|
||||||
// Update global directory in background
|
// Update global directory in background
|
||||||
$url = $_SESSION['my_url'];
|
$url = $_SESSION['my_url'];
|
||||||
|
|
|
@ -14,6 +14,7 @@ use Friendica\Core\PConfig;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
use Friendica\Database\DBM;
|
use Friendica\Database\DBM;
|
||||||
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\GContact;
|
use Friendica\Model\GContact;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Model\Profile;
|
||||||
|
@ -485,29 +486,15 @@ function profiles_post(App $a) {
|
||||||
info(L10n::t('Profile updated.') . EOL);
|
info(L10n::t('Profile updated.') . EOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($namechanged && $is_default) {
|
|
||||||
$r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `self` = 1 AND `uid` = %d",
|
|
||||||
dbesc($name),
|
|
||||||
dbesc(DateTimeFormat::utcNow()),
|
|
||||||
intval(local_user())
|
|
||||||
);
|
|
||||||
$r = q("UPDATE `user` set `username` = '%s' where `uid` = %d",
|
|
||||||
dbesc($name),
|
|
||||||
intval(local_user())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($is_default) {
|
if ($is_default) {
|
||||||
$location = Profile::formatLocation(["locality" => $locality, "region" => $region, "country-name" => $country_name]);
|
if ($namechanged) {
|
||||||
|
$r = q("UPDATE `user` set `username` = '%s' where `uid` = %d",
|
||||||
|
dbesc($name),
|
||||||
|
intval(local_user())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
q("UPDATE `contact` SET `about` = '%s', `location` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `self` AND `uid` = %d",
|
Contact::updateSelfFromUserID(local_user());
|
||||||
dbesc($about),
|
|
||||||
dbesc($location),
|
|
||||||
dbesc($pub_keywords),
|
|
||||||
dbesc($gender),
|
|
||||||
intval(local_user())
|
|
||||||
);
|
|
||||||
|
|
||||||
// Update global directory in background
|
// Update global directory in background
|
||||||
$url = $_SESSION['my_url'];
|
$url = $_SESSION['my_url'];
|
||||||
|
|
|
@ -262,7 +262,7 @@ function register_content(App $a)
|
||||||
'$invite_id' => $invite_id,
|
'$invite_id' => $invite_id,
|
||||||
'$realpeople' => $realpeople,
|
'$realpeople' => $realpeople,
|
||||||
'$regtitle' => L10n::t('Registration'),
|
'$regtitle' => L10n::t('Registration'),
|
||||||
'$registertext' => x($a->config, 'register_text') ? BBCode::convert($a->config['register_text']) : "",
|
'$registertext' => BBCode::convert(Config::get('config', 'register_text', '')),
|
||||||
'$fillwith' => $fillwith,
|
'$fillwith' => $fillwith,
|
||||||
'$fillext' => $fillext,
|
'$fillext' => $fillext,
|
||||||
'$oidlabel' => $oidlabel,
|
'$oidlabel' => $oidlabel,
|
||||||
|
@ -284,6 +284,9 @@ function register_content(App $a)
|
||||||
'$sitename' => $a->get_hostname(),
|
'$sitename' => $a->get_hostname(),
|
||||||
'$importh' => L10n::t('Import'),
|
'$importh' => L10n::t('Import'),
|
||||||
'$importt' => L10n::t('Import your profile to this friendica instance'),
|
'$importt' => L10n::t('Import your profile to this friendica instance'),
|
||||||
|
'$showtoslink' => Config::get('system', 'tosdisplay'),
|
||||||
|
'$tostext' => L10n::t('Terms of Service'),
|
||||||
|
'$baseurl' => System::baseurl(),
|
||||||
'$form_security_token' => get_form_security_token("register")
|
'$form_security_token' => get_form_security_token("register")
|
||||||
]);
|
]);
|
||||||
return $o;
|
return $o;
|
||||||
|
|
|
@ -13,9 +13,11 @@ use Friendica\Util\Crypto;
|
||||||
|
|
||||||
require_once 'include/items.php';
|
require_once 'include/items.php';
|
||||||
|
|
||||||
function salmon_post(App $a) {
|
function salmon_post(App $a, $xml = '') {
|
||||||
|
|
||||||
$xml = file_get_contents('php://input');
|
if (empty($xml)) {
|
||||||
|
$xml = file_get_contents('php://input');
|
||||||
|
}
|
||||||
|
|
||||||
logger('new salmon ' . $xml, LOGGER_DATA);
|
logger('new salmon ' . $xml, LOGGER_DATA);
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\Content\Feature;
|
use Friendica\Content\Feature;
|
||||||
use Friendica\Content\Nav;
|
use Friendica\Content\Nav;
|
||||||
|
use Friendica\Core\ACL;
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
|
@ -13,6 +14,7 @@ use Friendica\Core\PConfig;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
use Friendica\Database\DBM;
|
use Friendica\Database\DBM;
|
||||||
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\GContact;
|
use Friendica\Model\GContact;
|
||||||
use Friendica\Model\Group;
|
use Friendica\Model\Group;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
@ -386,13 +388,18 @@ function settings_post(App $a)
|
||||||
if (!x($newpass) || !x($confirm)) {
|
if (!x($newpass) || !x($confirm)) {
|
||||||
notice(L10n::t('Empty passwords are not allowed. Password unchanged.') . EOL);
|
notice(L10n::t('Empty passwords are not allowed. Password unchanged.') . EOL);
|
||||||
$err = true;
|
$err = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if the old password was supplied correctly before changing it to the new value
|
if (!Config::get('system', 'disable_password_exposed', false) && User::isPasswordExposed($newpass)) {
|
||||||
if (!User::authenticate(intval(local_user()), $_POST['opassword'])) {
|
notice(L10n::t('The new password has been exposed in a public data dump, please choose another.') . EOL);
|
||||||
notice(L10n::t('Wrong password.') . EOL);
|
$err = true;
|
||||||
$err = true;
|
}
|
||||||
}
|
|
||||||
|
// check if the old password was supplied correctly before changing it to the new value
|
||||||
|
if (!User::authenticate(intval(local_user()), $_POST['opassword'])) {
|
||||||
|
notice(L10n::t('Wrong password.') . EOL);
|
||||||
|
$err = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$err) {
|
if (!$err) {
|
||||||
$result = User::updatePassword(local_user(), $newpass);
|
$result = User::updatePassword(local_user(), $newpass);
|
||||||
|
@ -484,10 +491,7 @@ function settings_post(App $a)
|
||||||
|
|
||||||
$err = '';
|
$err = '';
|
||||||
|
|
||||||
$name_change = false;
|
|
||||||
|
|
||||||
if ($username != $a->user['username']) {
|
if ($username != $a->user['username']) {
|
||||||
$name_change = true;
|
|
||||||
if (strlen($username) > 40) {
|
if (strlen($username) > 40) {
|
||||||
$err .= L10n::t(' Please use a shorter name.');
|
$err .= L10n::t(' Please use a shorter name.');
|
||||||
}
|
}
|
||||||
|
@ -627,14 +631,7 @@ function settings_post(App $a)
|
||||||
intval(local_user())
|
intval(local_user())
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Contact::updateSelfFromUserID(local_user());
|
||||||
if ($name_change) {
|
|
||||||
q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `self`",
|
|
||||||
dbesc($username),
|
|
||||||
dbesc(DateTimeFormat::utcNow()),
|
|
||||||
intval(local_user())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($old_visibility != $net_publish) || ($page_flags != $old_page_flags)) {
|
if (($old_visibility != $net_publish) || ($page_flags != $old_page_flags)) {
|
||||||
// Update global directory in background
|
// Update global directory in background
|
||||||
|
@ -998,8 +995,6 @@ function settings_content(App $a)
|
||||||
* ACCOUNT SETTINGS
|
* ACCOUNT SETTINGS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once('include/acl_selectors.php');
|
|
||||||
|
|
||||||
$profile = dba::selectFirst('profile', [], ['is-default' => true, 'uid' => local_user()]);
|
$profile = dba::selectFirst('profile', [], ['is-default' => true, 'uid' => local_user()]);
|
||||||
if (!DBM::is_result($profile)) {
|
if (!DBM::is_result($profile)) {
|
||||||
notice(L10n::t('Unable to find your profile. Please contact your admin.') . EOL);
|
notice(L10n::t('Unable to find your profile. Please contact your admin.') . EOL);
|
||||||
|
@ -1223,7 +1218,7 @@ function settings_content(App $a)
|
||||||
'$permissions' => L10n::t('Default Post Permissions'),
|
'$permissions' => L10n::t('Default Post Permissions'),
|
||||||
'$permdesc' => L10n::t("\x28click to open/close\x29"),
|
'$permdesc' => L10n::t("\x28click to open/close\x29"),
|
||||||
'$visibility' => $profile['net-publish'],
|
'$visibility' => $profile['net-publish'],
|
||||||
'$aclselect' => populate_acl($a->user),
|
'$aclselect' => ACL::getFullSelectorHTML($a->user),
|
||||||
'$suggestme' => $suggestme,
|
'$suggestme' => $suggestme,
|
||||||
'$blockwall'=> $blockwall, // array('blockwall', L10n::t('Allow friends to post to your profile page:'), !$blockwall, ''),
|
'$blockwall'=> $blockwall, // array('blockwall', L10n::t('Allow friends to post to your profile page:'), !$blockwall, ''),
|
||||||
'$blocktags'=> $blocktags, // array('blocktags', L10n::t('Allow friends to tag your posts:'), !$blocktags, ''),
|
'$blocktags'=> $blocktags, // array('blocktags', L10n::t('Allow friends to tag your posts:'), !$blocktags, ''),
|
||||||
|
@ -1274,7 +1269,7 @@ function settings_content(App $a)
|
||||||
|
|
||||||
'$detailed_notif' => ['detailed_notif', L10n::t('Show detailled notifications'),
|
'$detailed_notif' => ['detailed_notif', L10n::t('Show detailled notifications'),
|
||||||
PConfig::get(local_user(), 'system', 'detailed_notif'),
|
PConfig::get(local_user(), 'system', 'detailed_notif'),
|
||||||
L10n::t('Per default the notificiation are condensed to a single notification per item. When enabled, every notification is displayed.')],
|
L10n::t('Per default, notifications are condensed to a single notification per item. When enabled every notification is displayed.')],
|
||||||
|
|
||||||
'$h_advn' => L10n::t('Advanced Account/Page Type Settings'),
|
'$h_advn' => L10n::t('Advanced Account/Page Type Settings'),
|
||||||
'$h_descadvn' => L10n::t('Change the behaviour of this account for special situations'),
|
'$h_descadvn' => L10n::t('Change the behaviour of this account for special situations'),
|
||||||
|
|
|
@ -19,7 +19,6 @@ use Friendica\Protocol\DFRN;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
|
|
||||||
require_once 'include/items.php';
|
require_once 'include/items.php';
|
||||||
require_once 'include/acl_selectors.php';
|
|
||||||
require_once 'include/security.php';
|
require_once 'include/security.php';
|
||||||
|
|
||||||
function videos_init(App $a) {
|
function videos_init(App $a) {
|
||||||
|
|
8
mods/sample-systemd.service
Normal file
8
mods/sample-systemd.service
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Friendica Worker
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=http
|
||||||
|
#Adapt the path in the following line to your system, use 'which php' to find php path,
|
||||||
|
#provide the absolute path for worker.php
|
||||||
|
ExecStart=/usr/bin/php /www/path/bin/worker.php &
|
|
@ -1,66 +0,0 @@
|
||||||
#!/usr/bin/env php
|
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* @file scripts/dbstructure.php
|
|
||||||
* @brief Does database updates from the command line
|
|
||||||
*/
|
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Config;
|
|
||||||
use Friendica\Database\DBStructure;
|
|
||||||
|
|
||||||
require_once "boot.php";
|
|
||||||
require_once "include/dba.php";
|
|
||||||
|
|
||||||
$a = new App(dirname(__DIR__));
|
|
||||||
|
|
||||||
@include ".htconfig.php";
|
|
||||||
dba::connect($db_host, $db_user, $db_pass, $db_data);
|
|
||||||
unset($db_host, $db_user, $db_pass, $db_data);
|
|
||||||
|
|
||||||
if ($_SERVER["argc"] == 2) {
|
|
||||||
switch ($_SERVER["argv"][1]) {
|
|
||||||
case "dryrun":
|
|
||||||
DBStructure::update(true, false);
|
|
||||||
return;
|
|
||||||
case "update":
|
|
||||||
DBStructure::update(true, true);
|
|
||||||
|
|
||||||
$build = Config::get('system','build');
|
|
||||||
if (!x($build)) {
|
|
||||||
Config::set('system', 'build', DB_UPDATE_VERSION);
|
|
||||||
$build = DB_UPDATE_VERSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
$stored = intval($build);
|
|
||||||
$current = intval(DB_UPDATE_VERSION);
|
|
||||||
|
|
||||||
// run any left update_nnnn functions in update.php
|
|
||||||
for ($x = $stored; $x < $current; $x ++) {
|
|
||||||
$r = run_update_function($x);
|
|
||||||
if (!$r) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Config::set('system','build',DB_UPDATE_VERSION);
|
|
||||||
return;
|
|
||||||
case "dumpsql":
|
|
||||||
DBStructure::printStructure();
|
|
||||||
return;
|
|
||||||
case "toinnodb":
|
|
||||||
DBStructure::convertToInnoDB();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// print help
|
|
||||||
echo $_SERVER["argv"][0]." <command>\n";
|
|
||||||
echo "\n";
|
|
||||||
echo "Commands:\n";
|
|
||||||
echo "dryrun show database update schema queries without running them\n";
|
|
||||||
echo "update update database schema\n";
|
|
||||||
echo "dumpsql dump database schema\n";
|
|
||||||
echo "toinnodb convert all tables from MyISAM to InnoDB\n";
|
|
||||||
killme();
|
|
||||||
|
|
125
src/App.php
125
src/App.php
|
@ -148,6 +148,8 @@ class App
|
||||||
$this->performance['start'] = microtime(true);
|
$this->performance['start'] = microtime(true);
|
||||||
$this->performance['database'] = 0;
|
$this->performance['database'] = 0;
|
||||||
$this->performance['database_write'] = 0;
|
$this->performance['database_write'] = 0;
|
||||||
|
$this->performance['cache'] = 0;
|
||||||
|
$this->performance['cache_write'] = 0;
|
||||||
$this->performance['network'] = 0;
|
$this->performance['network'] = 0;
|
||||||
$this->performance['file'] = 0;
|
$this->performance['file'] = 0;
|
||||||
$this->performance['rendering'] = 0;
|
$this->performance['rendering'] = 0;
|
||||||
|
@ -157,6 +159,8 @@ class App
|
||||||
|
|
||||||
$this->callstack['database'] = [];
|
$this->callstack['database'] = [];
|
||||||
$this->callstack['database_write'] = [];
|
$this->callstack['database_write'] = [];
|
||||||
|
$this->callstack['cache'] = [];
|
||||||
|
$this->callstack['cache_write'] = [];
|
||||||
$this->callstack['network'] = [];
|
$this->callstack['network'] = [];
|
||||||
$this->callstack['file'] = [];
|
$this->callstack['file'] = [];
|
||||||
$this->callstack['rendering'] = [];
|
$this->callstack['rendering'] = [];
|
||||||
|
@ -208,12 +212,6 @@ class App
|
||||||
. $this->basepath . DIRECTORY_SEPARATOR . 'library' . PATH_SEPARATOR
|
. $this->basepath . DIRECTORY_SEPARATOR . 'library' . PATH_SEPARATOR
|
||||||
. $this->basepath);
|
. $this->basepath);
|
||||||
|
|
||||||
|
|
||||||
if (is_array($_SERVER['argv']) && $_SERVER['argc'] > 1 && substr(end($_SERVER['argv']), 0, 4) == 'http') {
|
|
||||||
$this->set_baseurl(array_pop($_SERVER['argv']));
|
|
||||||
$_SERVER['argc'] --;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((x($_SERVER, 'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 9) === 'pagename=') {
|
if ((x($_SERVER, 'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 9) === 'pagename=') {
|
||||||
$this->query_string = substr($_SERVER['QUERY_STRING'], 9);
|
$this->query_string = substr($_SERVER['QUERY_STRING'], 9);
|
||||||
|
|
||||||
|
@ -864,9 +862,6 @@ class App
|
||||||
|
|
||||||
array_unshift($args, ((x($this->config, 'php_path')) && (strlen($this->config['php_path'])) ? $this->config['php_path'] : 'php'));
|
array_unshift($args, ((x($this->config, 'php_path')) && (strlen($this->config['php_path'])) ? $this->config['php_path'] : 'php'));
|
||||||
|
|
||||||
// add baseurl to args. cli scripts can't construct it
|
|
||||||
$args[] = $this->get_baseurl();
|
|
||||||
|
|
||||||
for ($x = 0; $x < count($args); $x ++) {
|
for ($x = 0; $x < count($args); $x ++) {
|
||||||
$args[$x] = escapeshellarg($args[$x]);
|
$args[$x] = escapeshellarg($args[$x]);
|
||||||
}
|
}
|
||||||
|
@ -940,4 +935,116 @@ class App
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $cat Config category
|
||||||
|
* @param string $k Config key
|
||||||
|
* @param mixed $default Default value if it isn't set
|
||||||
|
*/
|
||||||
|
public function getConfigValue($cat, $k, $default = null)
|
||||||
|
{
|
||||||
|
$return = $default;
|
||||||
|
|
||||||
|
if ($cat === 'config') {
|
||||||
|
if (isset($this->config[$k])) {
|
||||||
|
$return = $this->config[$k];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isset($this->config[$cat][$k])) {
|
||||||
|
$return = $this->config[$cat][$k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a value in the config cache. Accepts raw output from the config table
|
||||||
|
*
|
||||||
|
* @param string $cat Config category
|
||||||
|
* @param string $k Config key
|
||||||
|
* @param mixed $v Value to set
|
||||||
|
*/
|
||||||
|
public function setConfigValue($cat, $k, $v)
|
||||||
|
{
|
||||||
|
// Only arrays are serialized in database, so we have to unserialize sparingly
|
||||||
|
$value = is_string($v) && preg_match("|^a:[0-9]+:{.*}$|s", $v) ? unserialize($v) : $v;
|
||||||
|
|
||||||
|
if ($cat === 'config') {
|
||||||
|
$this->config[$k] = $value;
|
||||||
|
} else {
|
||||||
|
$this->config[$cat][$k] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a value from the config cache
|
||||||
|
*
|
||||||
|
* @param string $cat Config category
|
||||||
|
* @param string $k Config key
|
||||||
|
*/
|
||||||
|
public function deleteConfigValue($cat, $k)
|
||||||
|
{
|
||||||
|
if ($cat === 'config') {
|
||||||
|
if (isset($this->config[$k])) {
|
||||||
|
unset($this->config[$k]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isset($this->config[$cat][$k])) {
|
||||||
|
unset($this->config[$cat][$k]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a value from the user config cache
|
||||||
|
*
|
||||||
|
* @param int $uid User Id
|
||||||
|
* @param string $cat Config category
|
||||||
|
* @param string $k Config key
|
||||||
|
* @param mixed $default Default value if key isn't set
|
||||||
|
*/
|
||||||
|
public function getPConfigValue($uid, $cat, $k, $default = null)
|
||||||
|
{
|
||||||
|
$return = $default;
|
||||||
|
|
||||||
|
if (isset($this->config[$uid][$cat][$k])) {
|
||||||
|
$return = $this->config[$uid][$cat][$k];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a value in the user config cache
|
||||||
|
*
|
||||||
|
* Accepts raw output from the pconfig table
|
||||||
|
*
|
||||||
|
* @param int $uid User Id
|
||||||
|
* @param string $cat Config category
|
||||||
|
* @param string $k Config key
|
||||||
|
* @param mixed $v Value to set
|
||||||
|
*/
|
||||||
|
public function setPConfigValue($uid, $cat, $k, $v)
|
||||||
|
{
|
||||||
|
// Only arrays are serialized in database, so we have to unserialize sparingly
|
||||||
|
$value = is_string($v) && preg_match("|^a:[0-9]+:{.*}$|s", $v) ? unserialize($v) : $v;
|
||||||
|
|
||||||
|
$this->config[$uid][$cat][$k] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a value from the user config cache
|
||||||
|
*
|
||||||
|
* @param int $uid User Id
|
||||||
|
* @param string $cat Config category
|
||||||
|
* @param string $k Config key
|
||||||
|
*/
|
||||||
|
public function deletePConfigValue($uid, $cat, $k)
|
||||||
|
{
|
||||||
|
if (isset($this->config[$uid][$cat][$k])) {
|
||||||
|
unset($this->config[$uid][$cat][$k]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,9 @@ namespace Friendica;
|
||||||
* All modules in Friendica should extend BaseModule, although not all modules
|
* All modules in Friendica should extend BaseModule, although not all modules
|
||||||
* need to extend all the methods described here
|
* need to extend all the methods described here
|
||||||
*
|
*
|
||||||
|
* The filename of the module in src/Module needs to match the class name
|
||||||
|
* exactly to make the module available.
|
||||||
|
*
|
||||||
* @author Hypolite Petovan mrpetovan@gmail.com
|
* @author Hypolite Petovan mrpetovan@gmail.com
|
||||||
*/
|
*/
|
||||||
abstract class BaseModule extends BaseObject
|
abstract class BaseModule extends BaseObject
|
||||||
|
|
|
@ -1,34 +1,36 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file src/Content/Text/BBCode.php
|
* @file src/Content/Text/BBCode.php
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Friendica\Content\Text;
|
namespace Friendica\Content\Text;
|
||||||
|
|
||||||
use DOMDocument;
|
use DOMDocument;
|
||||||
use DomXPath;
|
use DOMXPath;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Friendica\BaseObject;
|
||||||
use Friendica\Content\OEmbed;
|
use Friendica\Content\OEmbed;
|
||||||
use Friendica\Content\Smilies;
|
use Friendica\Content\Smilies;
|
||||||
use Friendica\Content\Text\Plaintext;
|
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
use Friendica\Core\Cache;
|
use Friendica\Core\Cache;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Protocol;
|
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
|
use Friendica\Model\Event;
|
||||||
|
use Friendica\Network\Probe;
|
||||||
use Friendica\Object\Image;
|
use Friendica\Object\Image;
|
||||||
use Friendica\Util\Map;
|
use Friendica\Util\Map;
|
||||||
use Friendica\Util\Network;
|
use Friendica\Util\Network;
|
||||||
use Friendica\Util\ParseUrl;
|
use Friendica\Util\ParseUrl;
|
||||||
|
use League\HTMLToMarkdown\HtmlConverter;
|
||||||
|
|
||||||
require_once "include/event.php";
|
|
||||||
require_once "include/html2plain.php";
|
|
||||||
require_once "include/html2bbcode.php";
|
|
||||||
require_once "mod/proxy.php";
|
require_once "mod/proxy.php";
|
||||||
|
|
||||||
class BBCode
|
class BBCode extends BaseObject
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @brief Fetches attachment data that were generated the old way
|
* @brief Fetches attachment data that were generated the old way
|
||||||
|
@ -74,10 +76,12 @@ class BBCode
|
||||||
|
|
||||||
$picturedata = Image::getInfoFromURL($matches[1]);
|
$picturedata = Image::getInfoFromURL($matches[1]);
|
||||||
|
|
||||||
if (($picturedata[0] >= 500) && ($picturedata[0] >= $picturedata[1])) {
|
if ($picturedata) {
|
||||||
$post["image"] = $matches[1];
|
if (($picturedata[0] >= 500) && ($picturedata[0] >= $picturedata[1])) {
|
||||||
} else {
|
$post["image"] = $matches[1];
|
||||||
$post["preview"] = $matches[1];
|
} else {
|
||||||
|
$post["preview"] = $matches[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +178,7 @@ class BBCode
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($title != "") {
|
if ($title != "") {
|
||||||
$title = BBCode::convert(html_entity_decode($title, ENT_QUOTES, 'UTF-8'), false, true);
|
$title = self::convert(html_entity_decode($title, ENT_QUOTES, 'UTF-8'), false, true);
|
||||||
$title = html_entity_decode($title, ENT_QUOTES, 'UTF-8');
|
$title = html_entity_decode($title, ENT_QUOTES, 'UTF-8');
|
||||||
$title = str_replace(["[", "]"], ["[", "]"], $title);
|
$title = str_replace(["[", "]"], ["[", "]"], $title);
|
||||||
$data["title"] = $title;
|
$data["title"] = $title;
|
||||||
|
@ -264,7 +268,7 @@ class BBCode
|
||||||
$post["text"] = str_replace($pictures[0][0], "", $body);
|
$post["text"] = str_replace($pictures[0][0], "", $body);
|
||||||
} else {
|
} else {
|
||||||
$imgdata = Image::getInfoFromURL($pictures[0][1]);
|
$imgdata = Image::getInfoFromURL($pictures[0][1]);
|
||||||
if (substr($imgdata["mime"], 0, 6) == "image/") {
|
if ($imgdata && substr($imgdata["mime"], 0, 6) == "image/") {
|
||||||
$post["type"] = "photo";
|
$post["type"] = "photo";
|
||||||
$post["image"] = $pictures[0][1];
|
$post["image"] = $pictures[0][1];
|
||||||
$post["preview"] = $pictures[0][2];
|
$post["preview"] = $pictures[0][2];
|
||||||
|
@ -409,8 +413,8 @@ class BBCode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$html = BBCode::convert($post["text"].$post["after"], false, $htmlmode);
|
$html = self::convert($post["text"].$post["after"], false, $htmlmode);
|
||||||
$msg = html2plain($html, 0, true);
|
$msg = HTML::toPlaintext($html, 0, true);
|
||||||
$msg = trim(html_entity_decode($msg, ENT_QUOTES, 'UTF-8'));
|
$msg = trim(html_entity_decode($msg, ENT_QUOTES, 'UTF-8'));
|
||||||
|
|
||||||
$link = "";
|
$link = "";
|
||||||
|
@ -707,7 +711,7 @@ class BBCode
|
||||||
|
|
||||||
if ($data["description"] != "" && $data["description"] != $data["title"]) {
|
if ($data["description"] != "" && $data["description"] != $data["title"]) {
|
||||||
// Sanitize the HTML by converting it to BBCode
|
// Sanitize the HTML by converting it to BBCode
|
||||||
$bbcode = html2bbcode($data["description"]);
|
$bbcode = HTML::toBBCode($data["description"]);
|
||||||
$return .= sprintf('<blockquote>%s</blockquote>', trim(self::convert($bbcode)));
|
$return .= sprintf('<blockquote>%s</blockquote>', trim(self::convert($bbcode)));
|
||||||
}
|
}
|
||||||
if ($data["type"] == "link") {
|
if ($data["type"] == "link") {
|
||||||
|
@ -762,27 +766,6 @@ class BBCode
|
||||||
return $text . "\n" . $data["after"];
|
return $text . "\n" . $data["after"];
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function cleanCss($input)
|
|
||||||
{
|
|
||||||
$cleaned = "";
|
|
||||||
|
|
||||||
$input = strtolower($input);
|
|
||||||
|
|
||||||
for ($i = 0; $i < strlen($input); $i++) {
|
|
||||||
$char = substr($input, $i, 1);
|
|
||||||
|
|
||||||
if (($char >= "a") && ($char <= "z")) {
|
|
||||||
$cleaned .= $char;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(strpos(" #;:0123456789-_.%", $char) === false)) {
|
|
||||||
$cleaned .= $char;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $cleaned;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts [url] BBCodes in a format that looks fine on Mastodon. (callback function)
|
* Converts [url] BBCodes in a format that looks fine on Mastodon. (callback function)
|
||||||
*
|
*
|
||||||
|
@ -1197,7 +1180,7 @@ class BBCode
|
||||||
$text = Cache::get($match[1]);
|
$text = Cache::get($match[1]);
|
||||||
|
|
||||||
if (is_null($text)) {
|
if (is_null($text)) {
|
||||||
$a = get_app();
|
$a = self::getApp();
|
||||||
|
|
||||||
$stamp1 = microtime(true);
|
$stamp1 = microtime(true);
|
||||||
|
|
||||||
|
@ -1220,7 +1203,7 @@ class BBCode
|
||||||
|
|
||||||
$doc = new DOMDocument();
|
$doc = new DOMDocument();
|
||||||
@$doc->loadHTML($body);
|
@$doc->loadHTML($body);
|
||||||
$xpath = new DomXPath($doc);
|
$xpath = new DOMXPath($doc);
|
||||||
$list = $xpath->query("//meta[@name]");
|
$list = $xpath->query("//meta[@name]");
|
||||||
foreach ($list as $node) {
|
foreach ($list as $node) {
|
||||||
$attr = [];
|
$attr = [];
|
||||||
|
@ -1256,7 +1239,7 @@ class BBCode
|
||||||
$text = Cache::get($match[1]);
|
$text = Cache::get($match[1]);
|
||||||
|
|
||||||
if (is_null($text)) {
|
if (is_null($text)) {
|
||||||
$a = get_app();
|
$a = self::getApp();
|
||||||
|
|
||||||
$stamp1 = microtime(true);
|
$stamp1 = microtime(true);
|
||||||
|
|
||||||
|
@ -1280,7 +1263,7 @@ class BBCode
|
||||||
|
|
||||||
$doc = new DOMDocument();
|
$doc = new DOMDocument();
|
||||||
@$doc->loadHTML($body);
|
@$doc->loadHTML($body);
|
||||||
$xpath = new DomXPath($doc);
|
$xpath = new DOMXPath($doc);
|
||||||
$list = $xpath->query("//meta[@name]");
|
$list = $xpath->query("//meta[@name]");
|
||||||
foreach ($list as $node) {
|
foreach ($list as $node) {
|
||||||
$attr = [];
|
$attr = [];
|
||||||
|
@ -1309,13 +1292,17 @@ class BBCode
|
||||||
|
|
||||||
private static function textHighlightCallback($match)
|
private static function textHighlightCallback($match)
|
||||||
{
|
{
|
||||||
|
// Fallback in case the language doesn't exist
|
||||||
|
$return = '[code]' . $match[2] . '[/code]';
|
||||||
|
|
||||||
if (in_array(strtolower($match[1]),
|
if (in_array(strtolower($match[1]),
|
||||||
['php', 'css', 'mysql', 'sql', 'abap', 'diff', 'html', 'perl', 'ruby',
|
['php', 'css', 'mysql', 'sql', 'abap', 'diff', 'html', 'perl', 'ruby',
|
||||||
'vbscript', 'avrc', 'dtd', 'java', 'xml', 'cpp', 'python', 'javascript', 'js', 'sh'])
|
'vbscript', 'avrc', 'dtd', 'java', 'xml', 'cpp', 'python', 'javascript', 'js', 'sh', 'bash'])
|
||||||
) {
|
) {
|
||||||
return text_highlight($match[2], strtolower($match[1]));
|
$return = text_highlight($match[2], strtolower($match[1]));
|
||||||
}
|
}
|
||||||
return $match[0];
|
|
||||||
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1343,7 +1330,7 @@ class BBCode
|
||||||
*/
|
*/
|
||||||
public static function convert($text, $try_oembed = true, $simple_html = false, $for_plaintext = false)
|
public static function convert($text, $try_oembed = true, $simple_html = false, $for_plaintext = false)
|
||||||
{
|
{
|
||||||
$a = get_app();
|
$a = self::getApp();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* preg_match_callback function to replace potential Oembed tags with Oembed content
|
* preg_match_callback function to replace potential Oembed tags with Oembed content
|
||||||
|
@ -1392,7 +1379,7 @@ class BBCode
|
||||||
// After we're finished processing the bbcode we'll
|
// After we're finished processing the bbcode we'll
|
||||||
// replace all of the event code with a reformatted version.
|
// replace all of the event code with a reformatted version.
|
||||||
|
|
||||||
$ev = bbtoevent($text);
|
$ev = Event::fromBBCode($text);
|
||||||
|
|
||||||
// Replace any html brackets with HTML Entities to prevent executing HTML or script
|
// Replace any html brackets with HTML Entities to prevent executing HTML or script
|
||||||
// Don't use strip_tags here because it breaks [url] search by replacing & with amp
|
// Don't use strip_tags here because it breaks [url] search by replacing & with amp
|
||||||
|
@ -1616,7 +1603,7 @@ class BBCode
|
||||||
$text = preg_replace_callback(
|
$text = preg_replace_callback(
|
||||||
"(\[style=(.*?)\](.*?)\[\/style\])ism",
|
"(\[style=(.*?)\](.*?)\[\/style\])ism",
|
||||||
function ($match) {
|
function ($match) {
|
||||||
return "<span style=\"" . self::cleanCss($match[1]) . ";\">" . $match[2] . "</span>";
|
return "<span style=\"" . HTML::sanitizeCSS($match[1]) . ";\">" . $match[2] . "</span>";
|
||||||
},
|
},
|
||||||
$text
|
$text
|
||||||
);
|
);
|
||||||
|
@ -1625,7 +1612,7 @@ class BBCode
|
||||||
$text = preg_replace_callback(
|
$text = preg_replace_callback(
|
||||||
"(\[class=(.*?)\](.*?)\[\/class\])ism",
|
"(\[class=(.*?)\](.*?)\[\/class\])ism",
|
||||||
function ($match) {
|
function ($match) {
|
||||||
return "<span class=\"" . self::cleanCss($match[1]) . "\">" . $match[2] . "</span>";
|
return "<span class=\"" . HTML::sanitizeCSS($match[1]) . "\">" . $match[2] . "</span>";
|
||||||
},
|
},
|
||||||
$text
|
$text
|
||||||
);
|
);
|
||||||
|
@ -1830,7 +1817,7 @@ class BBCode
|
||||||
// start which is always required). Allow desc with a missing summary for compatibility.
|
// start which is always required). Allow desc with a missing summary for compatibility.
|
||||||
|
|
||||||
if ((x($ev, 'desc') || x($ev, 'summary')) && x($ev, 'start')) {
|
if ((x($ev, 'desc') || x($ev, 'summary')) && x($ev, 'start')) {
|
||||||
$sub = format_event_html($ev, $simple_html);
|
$sub = Event::getHTML($ev, $simple_html);
|
||||||
|
|
||||||
$text = preg_replace("/\[event\-summary\](.*?)\[\/event\-summary\]/ism", '', $text);
|
$text = preg_replace("/\[event\-summary\](.*?)\[\/event\-summary\]/ism", '', $text);
|
||||||
$text = preg_replace("/\[event\-description\](.*?)\[\/event\-description\]/ism", '', $text);
|
$text = preg_replace("/\[event\-description\](.*?)\[\/event\-description\]/ism", '', $text);
|
||||||
|
@ -1969,4 +1956,148 @@ class BBCode
|
||||||
|
|
||||||
return $abstract;
|
return $abstract;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Callback function to replace a Friendica style mention in a mention for Diaspora
|
||||||
|
*
|
||||||
|
* @param array $match Matching values for the callback
|
||||||
|
* @return string Replaced mention
|
||||||
|
*/
|
||||||
|
private static function bbCodeMention2DiasporaCallback($match)
|
||||||
|
{
|
||||||
|
$contact = Contact::getDetailsByURL($match[3]);
|
||||||
|
|
||||||
|
if (empty($contact['addr'])) {
|
||||||
|
$contact = Probe::uri($match[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($contact['addr'])) {
|
||||||
|
return $match[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
$mention = '@{' . $match[2] . '; ' . $contact['addr'] . '}';
|
||||||
|
return $mention;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Converts a BBCode text into Markdown
|
||||||
|
*
|
||||||
|
* This function converts a BBCode item body to be sent to Markdown-enabled
|
||||||
|
* systems like Diaspora and Libertree
|
||||||
|
*
|
||||||
|
* @param string $text
|
||||||
|
* @param bool $for_diaspora Diaspora requires more changes than Libertree
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function toMarkdown($text, $for_diaspora = true)
|
||||||
|
{
|
||||||
|
$a = self::getApp();
|
||||||
|
|
||||||
|
$original_text = $text;
|
||||||
|
|
||||||
|
// Since Diaspora is creating a summary for links, this function removes them before posting
|
||||||
|
if ($for_diaspora) {
|
||||||
|
$text = self::removeShareInformation($text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transform #tags, strip off the [url] and replace spaces with underscore
|
||||||
|
*/
|
||||||
|
$url_search_string = "^\[\]";
|
||||||
|
$text = preg_replace_callback("/#\[url\=([$url_search_string]*)\](.*?)\[\/url\]/i",
|
||||||
|
function ($matches) {
|
||||||
|
return '#' . str_replace(' ', '_', $matches[2]);
|
||||||
|
},
|
||||||
|
$text
|
||||||
|
);
|
||||||
|
|
||||||
|
// Converting images with size parameters to simple images. Markdown doesn't know it.
|
||||||
|
$text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $text);
|
||||||
|
|
||||||
|
// Extracting multi-line code blocks before the whitespace processing/code highlighter in self::convert()
|
||||||
|
$codeblocks = [];
|
||||||
|
|
||||||
|
$text = preg_replace_callback("#\[code(?:=([^\]]*))?\](.*?)\[\/code\]#is",
|
||||||
|
function ($matches) use (&$codeblocks) {
|
||||||
|
$return = $matches[0];
|
||||||
|
if (strpos($matches[2], "\n") !== false) {
|
||||||
|
$return = '#codeblock-' . count($codeblocks) . '#';
|
||||||
|
|
||||||
|
$prefix = '````' . $matches[1] . PHP_EOL;
|
||||||
|
$codeblocks[] = $prefix . trim($matches[2]) . PHP_EOL . '````';
|
||||||
|
}
|
||||||
|
return $return;
|
||||||
|
},
|
||||||
|
$text
|
||||||
|
);
|
||||||
|
|
||||||
|
// Convert it to HTML - don't try oembed
|
||||||
|
if ($for_diaspora) {
|
||||||
|
$text = self::convert($text, false, 3);
|
||||||
|
|
||||||
|
// Add all tags that maybe were removed
|
||||||
|
if (preg_match_all("/#\[url\=([$url_search_string]*)\](.*?)\[\/url\]/ism", $original_text, $tags)) {
|
||||||
|
$tagline = "";
|
||||||
|
foreach ($tags[2] as $tag) {
|
||||||
|
$tag = html_entity_decode($tag, ENT_QUOTES, 'UTF-8');
|
||||||
|
if (!strpos(html_entity_decode($text, ENT_QUOTES, 'UTF-8'), '#' . $tag)) {
|
||||||
|
$tagline .= '#' . $tag . ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$text = $text . " " . $tagline;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$text = self::convert($text, false, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
// mask some special HTML chars from conversation to markdown
|
||||||
|
$text = str_replace(['<', '>', '&'], ['&_lt_;', '&_gt_;', '&_amp_;'], $text);
|
||||||
|
|
||||||
|
// If a link is followed by a quote then there should be a newline before it
|
||||||
|
// Maybe we should make this newline at every time before a quote.
|
||||||
|
$text = str_replace(["</a><blockquote>"], ["</a><br><blockquote>"], $text);
|
||||||
|
|
||||||
|
$stamp1 = microtime(true);
|
||||||
|
|
||||||
|
// Now convert HTML to Markdown
|
||||||
|
$converter = new HtmlConverter();
|
||||||
|
$text = $converter->convert($text);
|
||||||
|
|
||||||
|
// unmask the special chars back to HTML
|
||||||
|
$text = str_replace(['&\_lt\_;', '&\_gt\_;', '&\_amp\_;'], ['<', '>', '&'], $text);
|
||||||
|
|
||||||
|
$a->save_timestamp($stamp1, "parser");
|
||||||
|
|
||||||
|
// Libertree has a problem with escaped hashtags.
|
||||||
|
$text = str_replace(['\#'], ['#'], $text);
|
||||||
|
|
||||||
|
// Remove any leading or trailing whitespace, as this will mess up
|
||||||
|
// the Diaspora signature verification and cause the item to disappear
|
||||||
|
$text = trim($text);
|
||||||
|
|
||||||
|
if ($for_diaspora) {
|
||||||
|
$url_search_string = "^\[\]";
|
||||||
|
$text = preg_replace_callback(
|
||||||
|
"/([@]\[(.*?)\])\(([$url_search_string]*?)\)/ism",
|
||||||
|
['self', 'bbCodeMention2DiasporaCallback'],
|
||||||
|
$text
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restore code blocks
|
||||||
|
$text = preg_replace_callback('/#codeblock-([0-9]+)#/iU',
|
||||||
|
function ($matches) use ($codeblocks) {
|
||||||
|
$return = '';
|
||||||
|
if (isset($codeblocks[intval($matches[1])])) {
|
||||||
|
$return = $codeblocks[$matches[1]];
|
||||||
|
}
|
||||||
|
return $return;
|
||||||
|
},
|
||||||
|
$text
|
||||||
|
);
|
||||||
|
|
||||||
|
Addon::callHooks('bb2diaspora', $text);
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
674
src/Content/Text/HTML.php
Normal file
674
src/Content/Text/HTML.php
Normal file
|
@ -0,0 +1,674 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file src/Content/Text/HTML.php
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Friendica\Content\Text;
|
||||||
|
|
||||||
|
use DOMDocument;
|
||||||
|
use DOMXPath;
|
||||||
|
use Friendica\Core\Addon;
|
||||||
|
use Friendica\Util\Network;
|
||||||
|
use Friendica\Util\XML;
|
||||||
|
|
||||||
|
class HTML
|
||||||
|
{
|
||||||
|
public static function sanitizeCSS($input)
|
||||||
|
{
|
||||||
|
$cleaned = "";
|
||||||
|
|
||||||
|
$input = strtolower($input);
|
||||||
|
|
||||||
|
for ($i = 0; $i < strlen($input); $i++) {
|
||||||
|
$char = substr($input, $i, 1);
|
||||||
|
|
||||||
|
if (($char >= "a") && ($char <= "z")) {
|
||||||
|
$cleaned .= $char;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(strpos(" #;:0123456789-_.%", $char) === false)) {
|
||||||
|
$cleaned .= $char;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $cleaned;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function tagToBBCode(DOMDocument $doc, $tag, $attributes, $startbb, $endbb)
|
||||||
|
{
|
||||||
|
do {
|
||||||
|
$done = self::tagToBBCodeSub($doc, $tag, $attributes, $startbb, $endbb);
|
||||||
|
} while ($done);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function tagToBBCodeSub(DOMDocument $doc, $tag, $attributes, $startbb, $endbb)
|
||||||
|
{
|
||||||
|
$savestart = str_replace('$', '\x01', $startbb);
|
||||||
|
$replace = false;
|
||||||
|
|
||||||
|
$xpath = new DOMXPath($doc);
|
||||||
|
|
||||||
|
$list = $xpath->query("//" . $tag);
|
||||||
|
foreach ($list as $node) {
|
||||||
|
$attr = [];
|
||||||
|
if ($node->attributes->length) {
|
||||||
|
foreach ($node->attributes as $attribute) {
|
||||||
|
$attr[$attribute->name] = $attribute->value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$replace = true;
|
||||||
|
|
||||||
|
$startbb = $savestart;
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
|
||||||
|
foreach ($attributes as $attribute => $value) {
|
||||||
|
$startbb = str_replace('\x01' . ++$i, '$1', $startbb);
|
||||||
|
if (strpos('*' . $startbb, '$1') > 0) {
|
||||||
|
if ($replace && (@$attr[$attribute] != '')) {
|
||||||
|
$startbb = preg_replace($value, $startbb, $attr[$attribute], -1, $count);
|
||||||
|
|
||||||
|
// If nothing could be changed
|
||||||
|
if ($count == 0) {
|
||||||
|
$replace = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$replace = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (@$attr[$attribute] != $value) {
|
||||||
|
$replace = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($replace) {
|
||||||
|
$StartCode = $doc->createTextNode($startbb);
|
||||||
|
$EndCode = $doc->createTextNode($endbb);
|
||||||
|
|
||||||
|
$node->parentNode->insertBefore($StartCode, $node);
|
||||||
|
|
||||||
|
if ($node->hasChildNodes()) {
|
||||||
|
foreach ($node->childNodes as $child) {
|
||||||
|
$newNode = $child->cloneNode(true);
|
||||||
|
$node->parentNode->insertBefore($newNode, $node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$node->parentNode->insertBefore($EndCode, $node);
|
||||||
|
$node->parentNode->removeChild($node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $replace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Made by: ike@piratenpartei.de
|
||||||
|
* Originally made for the syncom project: http://wiki.piratenpartei.de/Syncom
|
||||||
|
* https://github.com/annando/Syncom
|
||||||
|
*
|
||||||
|
* @brief Converter for HTML to BBCode
|
||||||
|
* @param string $message
|
||||||
|
* @param string $basepath
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function toBBCode($message, $basepath = '')
|
||||||
|
{
|
||||||
|
$message = str_replace("\r", "", $message);
|
||||||
|
|
||||||
|
// Removing code blocks before the whitespace removal processing below
|
||||||
|
$codeblocks = [];
|
||||||
|
$message = preg_replace_callback(
|
||||||
|
'#<pre><code(?: class="([^"]*)")?>(.*)</code></pre>#iUs',
|
||||||
|
function ($matches) use (&$codeblocks) {
|
||||||
|
$return = '[codeblock-' . count($codeblocks) . ']';
|
||||||
|
|
||||||
|
$prefix = '[code]';
|
||||||
|
if ($matches[1] != '') {
|
||||||
|
$prefix = '[code=' . $matches[1] . ']';
|
||||||
|
}
|
||||||
|
|
||||||
|
$codeblocks[] = $prefix . trim($matches[2]) . '[/code]';
|
||||||
|
return $return;
|
||||||
|
},
|
||||||
|
$message
|
||||||
|
);
|
||||||
|
|
||||||
|
$message = str_replace(
|
||||||
|
[
|
||||||
|
"<li><p>",
|
||||||
|
"</p></li>",
|
||||||
|
], [
|
||||||
|
"<li>",
|
||||||
|
"</li>",
|
||||||
|
], $message
|
||||||
|
);
|
||||||
|
|
||||||
|
// remove namespaces
|
||||||
|
$message = preg_replace('=<(\w+):(.+?)>=', '<removeme>', $message);
|
||||||
|
$message = preg_replace('=</(\w+):(.+?)>=', '</removeme>', $message);
|
||||||
|
|
||||||
|
$doc = new DOMDocument();
|
||||||
|
$doc->preserveWhiteSpace = false;
|
||||||
|
|
||||||
|
$message = mb_convert_encoding($message, 'HTML-ENTITIES', "UTF-8");
|
||||||
|
|
||||||
|
@$doc->loadHTML($message);
|
||||||
|
|
||||||
|
XML::deleteNode($doc, 'style');
|
||||||
|
XML::deleteNode($doc, 'head');
|
||||||
|
XML::deleteNode($doc, 'title');
|
||||||
|
XML::deleteNode($doc, 'meta');
|
||||||
|
XML::deleteNode($doc, 'xml');
|
||||||
|
XML::deleteNode($doc, 'removeme');
|
||||||
|
|
||||||
|
$xpath = new DomXPath($doc);
|
||||||
|
$list = $xpath->query("//pre");
|
||||||
|
foreach ($list as $node) {
|
||||||
|
$node->nodeValue = str_replace("\n", "\r", $node->nodeValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
$message = $doc->saveHTML();
|
||||||
|
$message = str_replace(["\n<", ">\n", "\r", "\n", "\xC3\x82\xC2\xA0"], ["<", ">", "<br />", " ", ""], $message);
|
||||||
|
$message = preg_replace('= [\s]*=i', " ", $message);
|
||||||
|
@$doc->loadHTML($message);
|
||||||
|
|
||||||
|
self::tagToBBCode($doc, 'html', [], "", "");
|
||||||
|
self::tagToBBCode($doc, 'body', [], "", "");
|
||||||
|
|
||||||
|
// Outlook-Quote - Variant 1
|
||||||
|
self::tagToBBCode($doc, 'p', ['class' => 'MsoNormal', 'style' => 'margin-left:35.4pt'], '[quote]', '[/quote]');
|
||||||
|
|
||||||
|
// Outlook-Quote - Variant 2
|
||||||
|
self::tagToBBCode($doc, 'div', ['style' => 'border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt'],
|
||||||
|
'[quote]', '[/quote]');
|
||||||
|
|
||||||
|
// MyBB-Stuff
|
||||||
|
self::tagToBBCode($doc, 'span', ['style' => 'text-decoration: underline;'], '[u]', '[/u]');
|
||||||
|
self::tagToBBCode($doc, 'span', ['style' => 'font-style: italic;'], '[i]', '[/i]');
|
||||||
|
self::tagToBBCode($doc, 'span', ['style' => 'font-weight: bold;'], '[b]', '[/b]');
|
||||||
|
|
||||||
|
/* self::node2BBCode($doc, 'font', array('face'=>'/([\w ]+)/', 'size'=>'/(\d+)/', 'color'=>'/(.+)/'), '[font=$1][size=$2][color=$3]', '[/color][/size][/font]');
|
||||||
|
self::node2BBCode($doc, 'font', array('size'=>'/(\d+)/', 'color'=>'/(.+)/'), '[size=$1][color=$2]', '[/color][/size]');
|
||||||
|
self::node2BBCode($doc, 'font', array('face'=>'/([\w ]+)/', 'size'=>'/(.+)/'), '[font=$1][size=$2]', '[/size][/font]');
|
||||||
|
self::node2BBCode($doc, 'font', array('face'=>'/([\w ]+)/', 'color'=>'/(.+)/'), '[font=$1][color=$3]', '[/color][/font]');
|
||||||
|
self::node2BBCode($doc, 'font', array('face'=>'/([\w ]+)/'), '[font=$1]', '[/font]');
|
||||||
|
self::node2BBCode($doc, 'font', array('size'=>'/(\d+)/'), '[size=$1]', '[/size]');
|
||||||
|
self::node2BBCode($doc, 'font', array('color'=>'/(.+)/'), '[color=$1]', '[/color]');
|
||||||
|
*/
|
||||||
|
// Untested
|
||||||
|
//self::node2BBCode($doc, 'span', array('style'=>'/.*font-size:\s*(.+?)[,;].*font-family:\s*(.+?)[,;].*color:\s*(.+?)[,;].*/'), '[size=$1][font=$2][color=$3]', '[/color][/font][/size]');
|
||||||
|
//self::node2BBCode($doc, 'span', array('style'=>'/.*font-size:\s*(\d+)[,;].*/'), '[size=$1]', '[/size]');
|
||||||
|
//self::node2BBCode($doc, 'span', array('style'=>'/.*font-size:\s*(.+?)[,;].*/'), '[size=$1]', '[/size]');
|
||||||
|
|
||||||
|
self::tagToBBCode($doc, 'span', ['style' => '/.*color:\s*(.+?)[,;].*/'], '[color="$1"]', '[/color]');
|
||||||
|
|
||||||
|
//self::node2BBCode($doc, 'span', array('style'=>'/.*font-family:\s*(.+?)[,;].*/'), '[font=$1]', '[/font]');
|
||||||
|
//self::node2BBCode($doc, 'div', array('style'=>'/.*font-family:\s*(.+?)[,;].*font-size:\s*(\d+?)pt.*/'), '[font=$1][size=$2]', '[/size][/font]');
|
||||||
|
//self::node2BBCode($doc, 'div', array('style'=>'/.*font-family:\s*(.+?)[,;].*font-size:\s*(\d+?)px.*/'), '[font=$1][size=$2]', '[/size][/font]');
|
||||||
|
//self::node2BBCode($doc, 'div', array('style'=>'/.*font-family:\s*(.+?)[,;].*/'), '[font=$1]', '[/font]');
|
||||||
|
// Importing the classes - interesting for importing of posts from third party networks that were exported from friendica
|
||||||
|
// Test
|
||||||
|
//self::node2BBCode($doc, 'span', array('class'=>'/([\w ]+)/'), '[class=$1]', '[/class]');
|
||||||
|
self::tagToBBCode($doc, 'span', ['class' => 'type-link'], '[class=type-link]', '[/class]');
|
||||||
|
self::tagToBBCode($doc, 'span', ['class' => 'type-video'], '[class=type-video]', '[/class]');
|
||||||
|
|
||||||
|
self::tagToBBCode($doc, 'strong', [], '[b]', '[/b]');
|
||||||
|
self::tagToBBCode($doc, 'em', [], '[i]', '[/i]');
|
||||||
|
self::tagToBBCode($doc, 'b', [], '[b]', '[/b]');
|
||||||
|
self::tagToBBCode($doc, 'i', [], '[i]', '[/i]');
|
||||||
|
self::tagToBBCode($doc, 'u', [], '[u]', '[/u]');
|
||||||
|
|
||||||
|
self::tagToBBCode($doc, 'big', [], "[size=large]", "[/size]");
|
||||||
|
self::tagToBBCode($doc, 'small', [], "[size=small]", "[/size]");
|
||||||
|
|
||||||
|
self::tagToBBCode($doc, 'blockquote', [], '[quote]', '[/quote]');
|
||||||
|
|
||||||
|
self::tagToBBCode($doc, 'br', [], "\n", '');
|
||||||
|
|
||||||
|
self::tagToBBCode($doc, 'p', ['class' => 'MsoNormal'], "\n", "");
|
||||||
|
self::tagToBBCode($doc, 'div', ['class' => 'MsoNormal'], "\r", "");
|
||||||
|
|
||||||
|
self::tagToBBCode($doc, 'span', [], "", "");
|
||||||
|
|
||||||
|
self::tagToBBCode($doc, 'span', [], "", "");
|
||||||
|
self::tagToBBCode($doc, 'pre', [], "", "");
|
||||||
|
|
||||||
|
self::tagToBBCode($doc, 'div', [], "\r", "\r");
|
||||||
|
self::tagToBBCode($doc, 'p', [], "\n", "\n");
|
||||||
|
|
||||||
|
self::tagToBBCode($doc, 'ul', [], "[list]", "[/list]");
|
||||||
|
self::tagToBBCode($doc, 'ol', [], "[list=1]", "[/list]");
|
||||||
|
self::tagToBBCode($doc, 'li', [], "[*]", "");
|
||||||
|
|
||||||
|
self::tagToBBCode($doc, 'hr', [], "[hr]", "");
|
||||||
|
|
||||||
|
self::tagToBBCode($doc, 'table', [], "", "");
|
||||||
|
self::tagToBBCode($doc, 'tr', [], "\n", "");
|
||||||
|
self::tagToBBCode($doc, 'td', [], "\t", "");
|
||||||
|
//self::node2BBCode($doc, 'table', array(), "[table]", "[/table]");
|
||||||
|
//self::node2BBCode($doc, 'th', array(), "[th]", "[/th]");
|
||||||
|
//self::node2BBCode($doc, 'tr', array(), "[tr]", "[/tr]");
|
||||||
|
//self::node2BBCode($doc, 'td', array(), "[td]", "[/td]");
|
||||||
|
//self::node2BBCode($doc, 'h1', array(), "\n\n[size=xx-large][b]", "[/b][/size]\n");
|
||||||
|
//self::node2BBCode($doc, 'h2', array(), "\n\n[size=x-large][b]", "[/b][/size]\n");
|
||||||
|
//self::node2BBCode($doc, 'h3', array(), "\n\n[size=large][b]", "[/b][/size]\n");
|
||||||
|
//self::node2BBCode($doc, 'h4', array(), "\n\n[size=medium][b]", "[/b][/size]\n");
|
||||||
|
//self::node2BBCode($doc, 'h5', array(), "\n\n[size=small][b]", "[/b][/size]\n");
|
||||||
|
//self::node2BBCode($doc, 'h6', array(), "\n\n[size=x-small][b]", "[/b][/size]\n");
|
||||||
|
|
||||||
|
self::tagToBBCode($doc, 'h1', [], "[h1]", "[/h1]");
|
||||||
|
self::tagToBBCode($doc, 'h2', [], "[h2]", "[/h2]");
|
||||||
|
self::tagToBBCode($doc, 'h3', [], "[h3]", "[/h3]");
|
||||||
|
self::tagToBBCode($doc, 'h4', [], "[h4]", "[/h4]");
|
||||||
|
self::tagToBBCode($doc, 'h5', [], "[h5]", "[/h5]");
|
||||||
|
self::tagToBBCode($doc, 'h6', [], "[h6]", "[/h6]");
|
||||||
|
|
||||||
|
self::tagToBBCode($doc, 'a', ['href' => '/mailto:(.+)/'], '[mail=$1]', '[/mail]');
|
||||||
|
self::tagToBBCode($doc, 'a', ['href' => '/(.+)/'], '[url=$1]', '[/url]');
|
||||||
|
|
||||||
|
self::tagToBBCode($doc, 'img', ['src' => '/(.+)/', 'width' => '/(\d+)/', 'height' => '/(\d+)/'], '[img=$2x$3]$1',
|
||||||
|
'[/img]');
|
||||||
|
self::tagToBBCode($doc, 'img', ['src' => '/(.+)/'], '[img]$1', '[/img]');
|
||||||
|
|
||||||
|
|
||||||
|
self::tagToBBCode($doc, 'video', ['src' => '/(.+)/'], '[video]$1', '[/video]');
|
||||||
|
self::tagToBBCode($doc, 'audio', ['src' => '/(.+)/'], '[audio]$1', '[/audio]');
|
||||||
|
self::tagToBBCode($doc, 'iframe', ['src' => '/(.+)/'], '[iframe]$1', '[/iframe]');
|
||||||
|
|
||||||
|
self::tagToBBCode($doc, 'key', [], '[code]', '[/code]');
|
||||||
|
self::tagToBBCode($doc, 'code', [], '[code]', '[/code]');
|
||||||
|
|
||||||
|
$message = $doc->saveHTML();
|
||||||
|
|
||||||
|
// I'm removing something really disturbing
|
||||||
|
// Don't know exactly what it is
|
||||||
|
$message = str_replace(chr(194) . chr(160), ' ', $message);
|
||||||
|
|
||||||
|
$message = str_replace(" ", " ", $message);
|
||||||
|
|
||||||
|
// removing multiple DIVs
|
||||||
|
$message = preg_replace('=\r *\r=i', "\n", $message);
|
||||||
|
$message = str_replace("\r", "\n", $message);
|
||||||
|
|
||||||
|
Addon::callHooks('html2bbcode', $message);
|
||||||
|
|
||||||
|
$message = strip_tags($message);
|
||||||
|
|
||||||
|
$message = html_entity_decode($message, ENT_QUOTES, 'UTF-8');
|
||||||
|
|
||||||
|
$message = str_replace(["<"], ["<"], $message);
|
||||||
|
|
||||||
|
// remove quotes if they don't make sense
|
||||||
|
$message = preg_replace('=\[/quote\][\s]*\[quote\]=i', "\n", $message);
|
||||||
|
|
||||||
|
$message = preg_replace('=\[quote\]\s*=i', "[quote]", $message);
|
||||||
|
$message = preg_replace('=\s*\[/quote\]=i', "[/quote]", $message);
|
||||||
|
|
||||||
|
do {
|
||||||
|
$oldmessage = $message;
|
||||||
|
$message = str_replace("\n \n", "\n\n", $message);
|
||||||
|
} while ($oldmessage != $message);
|
||||||
|
|
||||||
|
do {
|
||||||
|
$oldmessage = $message;
|
||||||
|
$message = str_replace("\n\n\n", "\n\n", $message);
|
||||||
|
} while ($oldmessage != $message);
|
||||||
|
|
||||||
|
do {
|
||||||
|
$oldmessage = $message;
|
||||||
|
$message = str_replace(
|
||||||
|
[
|
||||||
|
"[/size]\n\n",
|
||||||
|
"\n[hr]",
|
||||||
|
"[hr]\n",
|
||||||
|
"\n[list",
|
||||||
|
"[/list]\n",
|
||||||
|
"\n[/",
|
||||||
|
"[list]\n",
|
||||||
|
"[list=1]\n",
|
||||||
|
"\n[*]"],
|
||||||
|
[
|
||||||
|
"[/size]\n",
|
||||||
|
"[hr]",
|
||||||
|
"[hr]",
|
||||||
|
"[list",
|
||||||
|
"[/list]",
|
||||||
|
"[/",
|
||||||
|
"[list]",
|
||||||
|
"[list=1]",
|
||||||
|
"[*]"], $message
|
||||||
|
);
|
||||||
|
} while ($message != $oldmessage);
|
||||||
|
|
||||||
|
$message = str_replace(
|
||||||
|
['[b][b]', '[/b][/b]', '[i][i]', '[/i][/i]'], ['[b]', '[/b]', '[i]', '[/i]'], $message
|
||||||
|
);
|
||||||
|
|
||||||
|
// Handling Yahoo style of mails
|
||||||
|
$message = str_replace('[hr][b]From:[/b]', '[quote][b]From:[/b]', $message);
|
||||||
|
|
||||||
|
// Restore code blocks
|
||||||
|
$message = preg_replace_callback(
|
||||||
|
'#\[codeblock-([0-9]+)\]#iU',
|
||||||
|
function ($matches) use ($codeblocks) {
|
||||||
|
$return = '';
|
||||||
|
if (isset($codeblocks[intval($matches[1])])) {
|
||||||
|
$return = $codeblocks[$matches[1]];
|
||||||
|
}
|
||||||
|
return $return;
|
||||||
|
},
|
||||||
|
$message
|
||||||
|
);
|
||||||
|
|
||||||
|
$message = trim($message);
|
||||||
|
|
||||||
|
if ($basepath != '') {
|
||||||
|
$message = self::qualifyURLs($message, $basepath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sub function to complete incomplete URL
|
||||||
|
*
|
||||||
|
* @param array $matches Result of preg_replace_callback
|
||||||
|
* @param string $basepath Basepath that is used to complete the URL
|
||||||
|
*
|
||||||
|
* @return string The expanded URL
|
||||||
|
*/
|
||||||
|
private static function qualifyURLsSub($matches, $basepath)
|
||||||
|
{
|
||||||
|
$base = parse_url($basepath);
|
||||||
|
unset($base['query']);
|
||||||
|
unset($base['fragment']);
|
||||||
|
|
||||||
|
$link = $matches[0];
|
||||||
|
$url = $matches[1];
|
||||||
|
|
||||||
|
$parts = array_merge($base, parse_url($url));
|
||||||
|
$url2 = Network::unparseURL($parts);
|
||||||
|
|
||||||
|
return str_replace($url, $url2, $link);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Complete incomplete URLs in BBCode
|
||||||
|
*
|
||||||
|
* @param string $body Body with URLs
|
||||||
|
* @param string $basepath Base path that is used to complete the URL
|
||||||
|
*
|
||||||
|
* @return string Body with expanded URLs
|
||||||
|
*/
|
||||||
|
private static function qualifyURLs($body, $basepath)
|
||||||
|
{
|
||||||
|
$URLSearchString = "^\[\]";
|
||||||
|
|
||||||
|
$matches = ["/\[url\=([$URLSearchString]*)\].*?\[\/url\]/ism",
|
||||||
|
"/\[url\]([$URLSearchString]*)\[\/url\]/ism",
|
||||||
|
"/\[img\=[0-9]*x[0-9]*\](.*?)\[\/img\]/ism",
|
||||||
|
"/\[img\](.*?)\[\/img\]/ism",
|
||||||
|
"/\[zmg\=[0-9]*x[0-9]*\](.*?)\[\/img\]/ism",
|
||||||
|
"/\[zmg\](.*?)\[\/zmg\]/ism",
|
||||||
|
"/\[video\](.*?)\[\/video\]/ism",
|
||||||
|
"/\[audio\](.*?)\[\/audio\]/ism",
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($matches as $match) {
|
||||||
|
$body = preg_replace_callback(
|
||||||
|
$match, function ($match) use ($basepath) {
|
||||||
|
return self::qualifyURLsSub($match, $basepath);
|
||||||
|
},
|
||||||
|
$body
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return $body;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function breakLines($line, $level, $wraplength = 75)
|
||||||
|
{
|
||||||
|
if ($wraplength == 0) {
|
||||||
|
$wraplength = 2000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
$wraplen = $wraplength - $level;
|
||||||
|
|
||||||
|
$newlines = [];
|
||||||
|
|
||||||
|
do {
|
||||||
|
$oldline = $line;
|
||||||
|
|
||||||
|
$subline = substr($line, 0, $wraplen);
|
||||||
|
|
||||||
|
$pos = strrpos($subline, ' ');
|
||||||
|
|
||||||
|
if ($pos == 0) {
|
||||||
|
$pos = strpos($line, ' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($pos > 0) && strlen($line) > $wraplen) {
|
||||||
|
$newline = trim(substr($line, 0, $pos));
|
||||||
|
if ($level > 0) {
|
||||||
|
$newline = str_repeat(">", $level) . ' ' . $newline;
|
||||||
|
}
|
||||||
|
|
||||||
|
$newlines[] = $newline . " ";
|
||||||
|
$line = substr($line, $pos + 1);
|
||||||
|
}
|
||||||
|
} while ((strlen($line) > $wraplen) && !($oldline == $line));
|
||||||
|
|
||||||
|
if ($level > 0) {
|
||||||
|
$line = str_repeat(">", $level) . ' ' . $line;
|
||||||
|
}
|
||||||
|
|
||||||
|
$newlines[] = $line;
|
||||||
|
|
||||||
|
return implode($newlines, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function quoteLevel($message, $wraplength = 75)
|
||||||
|
{
|
||||||
|
$lines = explode("\n", $message);
|
||||||
|
|
||||||
|
$newlines = [];
|
||||||
|
$level = 0;
|
||||||
|
foreach ($lines as $line) {
|
||||||
|
$line = trim($line);
|
||||||
|
$startquote = false;
|
||||||
|
while (strpos("*" . $line, '[quote]') > 0) {
|
||||||
|
$level++;
|
||||||
|
$pos = strpos($line, '[quote]');
|
||||||
|
$line = substr($line, 0, $pos) . substr($line, $pos + 7);
|
||||||
|
$startquote = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$currlevel = $level;
|
||||||
|
|
||||||
|
while (strpos("*" . $line, '[/quote]') > 0) {
|
||||||
|
$level--;
|
||||||
|
if ($level < 0) {
|
||||||
|
$level = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pos = strpos($line, '[/quote]');
|
||||||
|
$line = substr($line, 0, $pos) . substr($line, $pos + 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$startquote || ($line != '')) {
|
||||||
|
$newlines[] = self::breakLines($line, $currlevel, $wraplength);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return implode($newlines, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function collectURLs($message)
|
||||||
|
{
|
||||||
|
$pattern = '/<a.*?href="(.*?)".*?>(.*?)<\/a>/is';
|
||||||
|
preg_match_all($pattern, $message, $result, PREG_SET_ORDER);
|
||||||
|
|
||||||
|
$urls = [];
|
||||||
|
foreach ($result as $treffer) {
|
||||||
|
$ignore = false;
|
||||||
|
|
||||||
|
// A list of some links that should be ignored
|
||||||
|
$list = ["/user/", "/tag/", "/group/", "/profile/", "/search?search=", "/search?tag=", "mailto:", "/u/", "/node/",
|
||||||
|
"//facebook.com/profile.php?id=", "//plus.google.com/", "//twitter.com/"];
|
||||||
|
foreach ($list as $listitem) {
|
||||||
|
if (strpos($treffer[1], $listitem) !== false) {
|
||||||
|
$ignore = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((strpos($treffer[1], "//twitter.com/") !== false) && (strpos($treffer[1], "/status/") !== false)) {
|
||||||
|
$ignore = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((strpos($treffer[1], "//plus.google.com/") !== false) && (strpos($treffer[1], "/posts") !== false)) {
|
||||||
|
$ignore = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((strpos($treffer[1], "//plus.google.com/") !== false) && (strpos($treffer[1], "/photos") !== false)) {
|
||||||
|
$ignore = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$ignore) {
|
||||||
|
$urls[$treffer[1]] = $treffer[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $urls;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function toPlaintext($html, $wraplength = 75, $compact = false)
|
||||||
|
{
|
||||||
|
global $lang;
|
||||||
|
|
||||||
|
$message = str_replace("\r", "", $html);
|
||||||
|
|
||||||
|
$doc = new DOMDocument();
|
||||||
|
$doc->preserveWhiteSpace = false;
|
||||||
|
|
||||||
|
$message = mb_convert_encoding($message, 'HTML-ENTITIES', "UTF-8");
|
||||||
|
|
||||||
|
@$doc->loadHTML($message);
|
||||||
|
|
||||||
|
$xpath = new DOMXPath($doc);
|
||||||
|
$list = $xpath->query("//pre");
|
||||||
|
foreach ($list as $node) {
|
||||||
|
$node->nodeValue = str_replace("\n", "\r", $node->nodeValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
$message = $doc->saveHTML();
|
||||||
|
$message = str_replace(["\n<", ">\n", "\r", "\n", "\xC3\x82\xC2\xA0"], ["<", ">", "<br>", " ", ""], $message);
|
||||||
|
$message = preg_replace('= [\s]*=i', " ", $message);
|
||||||
|
|
||||||
|
// Collecting all links
|
||||||
|
$urls = self::collectURLs($message);
|
||||||
|
|
||||||
|
@$doc->loadHTML($message);
|
||||||
|
|
||||||
|
self::tagToBBCode($doc, 'html', [], '', '');
|
||||||
|
self::tagToBBCode($doc, 'body', [], '', '');
|
||||||
|
|
||||||
|
// MyBB-Auszeichnungen
|
||||||
|
/*
|
||||||
|
self::node2BBCode($doc, 'span', array('style'=>'text-decoration: underline;'), '_', '_');
|
||||||
|
self::node2BBCode($doc, 'span', array('style'=>'font-style: italic;'), '/', '/');
|
||||||
|
self::node2BBCode($doc, 'span', array('style'=>'font-weight: bold;'), '*', '*');
|
||||||
|
|
||||||
|
self::node2BBCode($doc, 'strong', array(), '*', '*');
|
||||||
|
self::node2BBCode($doc, 'b', array(), '*', '*');
|
||||||
|
self::node2BBCode($doc, 'i', array(), '/', '/');
|
||||||
|
self::node2BBCode($doc, 'u', array(), '_', '_');
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ($compact) {
|
||||||
|
self::tagToBBCode($doc, 'blockquote', [], "»", "«");
|
||||||
|
} else {
|
||||||
|
self::tagToBBCode($doc, 'blockquote', [], '[quote]', "[/quote]\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
self::tagToBBCode($doc, 'br', [], "\n", '');
|
||||||
|
|
||||||
|
self::tagToBBCode($doc, 'span', [], "", "");
|
||||||
|
self::tagToBBCode($doc, 'pre', [], "", "");
|
||||||
|
self::tagToBBCode($doc, 'div', [], "\r", "\r");
|
||||||
|
self::tagToBBCode($doc, 'p', [], "\n", "\n");
|
||||||
|
|
||||||
|
//self::node2BBCode($doc, 'ul', array(), "\n[list]", "[/list]\n");
|
||||||
|
//self::node2BBCode($doc, 'ol', array(), "\n[list=1]", "[/list]\n");
|
||||||
|
self::tagToBBCode($doc, 'li', [], "\n* ", "\n");
|
||||||
|
|
||||||
|
self::tagToBBCode($doc, 'hr', [], "\n" . str_repeat("-", 70) . "\n", "");
|
||||||
|
|
||||||
|
self::tagToBBCode($doc, 'tr', [], "\n", "");
|
||||||
|
self::tagToBBCode($doc, 'td', [], "\t", "");
|
||||||
|
|
||||||
|
self::tagToBBCode($doc, 'h1', [], "\n\n*", "*\n");
|
||||||
|
self::tagToBBCode($doc, 'h2', [], "\n\n*", "*\n");
|
||||||
|
self::tagToBBCode($doc, 'h3', [], "\n\n*", "*\n");
|
||||||
|
self::tagToBBCode($doc, 'h4', [], "\n\n*", "*\n");
|
||||||
|
self::tagToBBCode($doc, 'h5', [], "\n\n*", "*\n");
|
||||||
|
self::tagToBBCode($doc, 'h6', [], "\n\n*", "*\n");
|
||||||
|
|
||||||
|
// Problem: there is no reliable way to detect if it is a link to a tag or profile
|
||||||
|
//self::node2BBCode($doc, 'a', array('href'=>'/(.+)/'), ' $1 ', ' ', true);
|
||||||
|
//self::node2BBCode($doc, 'a', array('href'=>'/(.+)/', 'rel'=>'oembed'), ' $1 ', '', true);
|
||||||
|
//self::node2BBCode($doc, 'img', array('alt'=>'/(.+)/'), '$1', '');
|
||||||
|
//self::node2BBCode($doc, 'img', array('title'=>'/(.+)/'), '$1', '');
|
||||||
|
//self::node2BBCode($doc, 'img', array(), '', '');
|
||||||
|
if (!$compact) {
|
||||||
|
self::tagToBBCode($doc, 'img', ['src' => '/(.+)/'], ' [img]$1', '[/img] ');
|
||||||
|
} else {
|
||||||
|
self::tagToBBCode($doc, 'img', ['src' => '/(.+)/'], ' ', ' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
self::tagToBBCode($doc, 'iframe', ['src' => '/(.+)/'], ' $1 ', '');
|
||||||
|
|
||||||
|
$message = $doc->saveHTML();
|
||||||
|
|
||||||
|
if (!$compact) {
|
||||||
|
$message = str_replace("[img]", "", $message);
|
||||||
|
$message = str_replace("[/img]", "", $message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// was ersetze ich da?
|
||||||
|
// Irgendein stoerrisches UTF-Zeug
|
||||||
|
$message = str_replace(chr(194) . chr(160), ' ', $message);
|
||||||
|
|
||||||
|
$message = str_replace(" ", " ", $message);
|
||||||
|
|
||||||
|
// Aufeinanderfolgende DIVs
|
||||||
|
$message = preg_replace('=\r *\r=i', "\n", $message);
|
||||||
|
$message = str_replace("\r", "\n", $message);
|
||||||
|
|
||||||
|
$message = strip_tags($message);
|
||||||
|
|
||||||
|
$message = html_entity_decode($message, ENT_QUOTES, 'UTF-8');
|
||||||
|
|
||||||
|
if (!$compact && ($message != '')) {
|
||||||
|
foreach ($urls as $id => $url) {
|
||||||
|
if ($url != '' && strpos($message, $url) === false) {
|
||||||
|
$message .= "\n" . $url . ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$message = str_replace("\n«", "«\n", $message);
|
||||||
|
$message = str_replace("»\n", "\n»", $message);
|
||||||
|
|
||||||
|
do {
|
||||||
|
$oldmessage = $message;
|
||||||
|
$message = str_replace("\n\n\n", "\n\n", $message);
|
||||||
|
} while ($oldmessage != $message);
|
||||||
|
|
||||||
|
$message = self::quoteLevel(trim($message), $wraplength);
|
||||||
|
|
||||||
|
return trim($message);
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,7 +7,9 @@
|
||||||
namespace Friendica\Content\Text;
|
namespace Friendica\Content\Text;
|
||||||
|
|
||||||
use Friendica\BaseObject;
|
use Friendica\BaseObject;
|
||||||
|
use Friendica\Model\Contact;
|
||||||
use Michelf\MarkdownExtra;
|
use Michelf\MarkdownExtra;
|
||||||
|
use Friendica\Content\Text\HTML;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Friendica-specific usage of Markdown
|
* Friendica-specific usage of Markdown
|
||||||
|
@ -36,4 +38,81 @@ class Markdown extends BaseObject
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Callback function to replace a Diaspora style mention in a mention for Friendica
|
||||||
|
*
|
||||||
|
* @param array $match Matching values for the callback
|
||||||
|
* @return string Replaced mention
|
||||||
|
*/
|
||||||
|
private static function diasporaMention2BBCodeCallback($match)
|
||||||
|
{
|
||||||
|
if ($match[2] == '') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = Contact::getDetailsByAddr($match[2]);
|
||||||
|
|
||||||
|
$name = $match[1];
|
||||||
|
|
||||||
|
if ($name == '') {
|
||||||
|
$name = $data['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return '@[url=' . $data['url'] . ']' . $name . '[/url]';
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* we don't want to support a bbcode specific markdown interpreter
|
||||||
|
* and the markdown library we have is pretty good, but provides HTML output.
|
||||||
|
* So we'll use that to convert to HTML, then convert the HTML back to bbcode,
|
||||||
|
* and then clean up a few Diaspora specific constructs.
|
||||||
|
*/
|
||||||
|
public static function toBBCode($s)
|
||||||
|
{
|
||||||
|
$s = html_entity_decode($s, ENT_COMPAT, 'UTF-8');
|
||||||
|
|
||||||
|
// Handles single newlines
|
||||||
|
$s = str_replace("\r\n", "\n", $s);
|
||||||
|
$s = str_replace("\n", " \n", $s);
|
||||||
|
$s = str_replace("\r", " \n", $s);
|
||||||
|
|
||||||
|
// Replace lonely stars in lines not starting with it with literal stars
|
||||||
|
$s = preg_replace('/^([^\*]+)\*([^\*]*)$/im', '$1\*$2', $s);
|
||||||
|
|
||||||
|
// The parser cannot handle paragraphs correctly
|
||||||
|
$s = str_replace(['</p>', '<p>', '<p dir="ltr">'], ['<br>', '<br>', '<br>'], $s);
|
||||||
|
|
||||||
|
// Escaping the hash tags
|
||||||
|
$s = preg_replace('/\#([^\s\#])/', '#$1', $s);
|
||||||
|
|
||||||
|
$s = self::convert($s);
|
||||||
|
|
||||||
|
$regexp = "/@\{(?:([^\}]+?); )?([^\} ]+)\}/";
|
||||||
|
$s = preg_replace_callback($regexp, ['self', 'diasporaMention2BBCodeCallback'], $s);
|
||||||
|
|
||||||
|
$s = str_replace('#', '#', $s);
|
||||||
|
|
||||||
|
$s = HTML::toBBCode($s);
|
||||||
|
|
||||||
|
// protect the recycle symbol from turning into a tag, but without unescaping angles and naked ampersands
|
||||||
|
$s = str_replace('♲', html_entity_decode('♲', ENT_QUOTES, 'UTF-8'), $s);
|
||||||
|
|
||||||
|
// Convert everything that looks like a link to a link
|
||||||
|
$s = preg_replace('/([^\]=]|^)(https?\:\/\/)([a-zA-Z0-9:\/\-?&;.=_~#%$!+,@]+(?<!,))/ism', '$1[url=$2$3]$2$3[/url]', $s);
|
||||||
|
|
||||||
|
//$s = preg_replace("/([^\]\=]|^)(https?\:\/\/)(vimeo|youtu|www\.youtube|soundcloud)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2$3$4]$2$3$4[/url]',$s);
|
||||||
|
$s = BBCode::pregReplaceInTag('/\[url\=?(.*?)\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/url\]/ism', '[youtube]$2[/youtube]', 'url', $s);
|
||||||
|
$s = BBCode::pregReplaceInTag('/\[url\=https?:\/\/www.youtube.com\/watch\?v\=(.*?)\].*?\[\/url\]/ism' , '[youtube]$1[/youtube]', 'url', $s);
|
||||||
|
$s = BBCode::pregReplaceInTag('/\[url\=?(.*?)\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/url\]/ism' , '[vimeo]$2[/vimeo]' , 'url', $s);
|
||||||
|
$s = BBCode::pregReplaceInTag('/\[url\=https?:\/\/vimeo.com\/([0-9]+)\](.*?)\[\/url\]/ism' , '[vimeo]$1[/vimeo]' , 'url', $s);
|
||||||
|
|
||||||
|
// remove duplicate adjacent code tags
|
||||||
|
$s = preg_replace('/(\[code\])+(.*?)(\[\/code\])+/ism', '[code]$2[/code]', $s);
|
||||||
|
|
||||||
|
// Don't show link to full picture (until it is fixed)
|
||||||
|
$s = BBCode::scaleExternalImages($s, false);
|
||||||
|
|
||||||
|
return $s;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
69
src/Content/Widget/CalendarExport.php
Normal file
69
src/Content/Widget/CalendarExport.php
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @file src/Content/Widget/CalendarExport.php
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Friendica\Content\Widget;
|
||||||
|
|
||||||
|
use Friendica\Content\Feature;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
|
|
||||||
|
require_once 'boot.php';
|
||||||
|
require_once 'include/text.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TagCloud widget
|
||||||
|
*
|
||||||
|
* @author Rabuzarus
|
||||||
|
*/
|
||||||
|
class CalendarExport
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief Get the events widget.
|
||||||
|
*
|
||||||
|
* @return string Formated HTML of the calendar widget.
|
||||||
|
*/
|
||||||
|
public static function getHTML() {
|
||||||
|
$a = get_app();
|
||||||
|
|
||||||
|
$owner_uid = $a->data['user']['uid'];
|
||||||
|
|
||||||
|
// The permission testing is a little bit tricky because we have to respect many cases.
|
||||||
|
|
||||||
|
// It's not the private events page (we don't get the $owner_uid for /events).
|
||||||
|
if (!local_user() && !$owner_uid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If it's a kind of profile page (intval($owner_uid)) return if the user not logged in and
|
||||||
|
* export feature isn't enabled.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Cal logged in user (test permission at foreign profile page).
|
||||||
|
* If the $owner uid is available we know it is part of one of the profile pages (like /cal).
|
||||||
|
* So we have to test if if it's the own profile page of the logged in user
|
||||||
|
* or a foreign one. For foreign profile pages we need to check if the feature
|
||||||
|
* for exporting the cal is enabled (otherwise the widget would appear for logged in users
|
||||||
|
* on foreigen profile pages even if the widget is disabled).
|
||||||
|
*/
|
||||||
|
if (local_user() != $owner_uid && !Feature::isEnabled($owner_uid, "export_calendar")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// $a->data is only available if the profile page is visited. If the visited page is not part
|
||||||
|
// of the profile page it should be the personal /events page. So we can use $a->user.
|
||||||
|
$user = defaults($a->data['user'], 'nickname', $a->user['nickname']);
|
||||||
|
|
||||||
|
$tpl = get_markup_template("events_aside.tpl");
|
||||||
|
$return = replace_macros($tpl, [
|
||||||
|
'$etitle' => L10n::t("Export"),
|
||||||
|
'$export_ical' => L10n::t("Export calendar as ical"),
|
||||||
|
'$export_csv' => L10n::t("Export calendar as csv"),
|
||||||
|
'$user' => $user
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
}
|
369
src/Core/ACL.php
Normal file
369
src/Core/ACL.php
Normal file
|
@ -0,0 +1,369 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file src/Core/Acl.php
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Friendica\Core;
|
||||||
|
|
||||||
|
use dba;
|
||||||
|
use Friendica\BaseObject;
|
||||||
|
use Friendica\Content\Feature;
|
||||||
|
use Friendica\Database\DBM;
|
||||||
|
use Friendica\Model\Contact;
|
||||||
|
use Friendica\Model\GContact;
|
||||||
|
use Friendica\Util\Network;
|
||||||
|
use const CONTACT_IS_FRIEND;
|
||||||
|
use const NETWORK_DFRN;
|
||||||
|
use const NETWORK_DIASPORA;
|
||||||
|
use const NETWORK_FACEBOOK;
|
||||||
|
use const NETWORK_MAIL;
|
||||||
|
use const NETWORK_OSTATUS;
|
||||||
|
use const PHP_EOL;
|
||||||
|
use function dbesc;
|
||||||
|
use function defaults;
|
||||||
|
use function get_markup_template;
|
||||||
|
use function get_server;
|
||||||
|
use function local_user;
|
||||||
|
use function remote_user;
|
||||||
|
use function replace_macros;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle ACL management and display
|
||||||
|
*
|
||||||
|
* @author Hypolite Petovan <mrpetovan@gmail.com>
|
||||||
|
*/
|
||||||
|
class ACL extends BaseObject
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Returns a select input tag with all the contact of the local user
|
||||||
|
*
|
||||||
|
* @param string $selname Name attribute of the select input tag
|
||||||
|
* @param string $selclass Class attribute of the select input tag
|
||||||
|
* @param array $options Available options:
|
||||||
|
* - size: length of the select box
|
||||||
|
* - mutual_friends: Only used for the hook
|
||||||
|
* - single: Only used for the hook
|
||||||
|
* - exclude: Only used for the hook
|
||||||
|
* @param array $preselected Contact ID that should be already selected
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getSuggestContactSelectHTML($selname, $selclass, array $options = [], array $preselected = [])
|
||||||
|
{
|
||||||
|
$a = self::getApp();
|
||||||
|
|
||||||
|
$networks = null;
|
||||||
|
|
||||||
|
$size = defaults($options, 'size', 4);
|
||||||
|
$mutual = !empty($options['mutual_friends']);
|
||||||
|
$single = !empty($options['single']) && empty($options['multiple']);
|
||||||
|
$exclude = defaults($options, 'exclude', false);
|
||||||
|
|
||||||
|
switch (defaults($options, 'networks', Protocol::PHANTOM)) {
|
||||||
|
case 'DFRN_ONLY':
|
||||||
|
$networks = [NETWORK_DFRN];
|
||||||
|
break;
|
||||||
|
case 'PRIVATE':
|
||||||
|
if (!empty($a->user['prvnets'])) {
|
||||||
|
$networks = [NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA];
|
||||||
|
} else {
|
||||||
|
$networks = [NETWORK_DFRN, NETWORK_FACEBOOK, NETWORK_MAIL, NETWORK_DIASPORA];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'TWO_WAY':
|
||||||
|
if (!empty($a->user['prvnets'])) {
|
||||||
|
$networks = [NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA];
|
||||||
|
} else {
|
||||||
|
$networks = [NETWORK_DFRN, NETWORK_FACEBOOK, NETWORK_MAIL, NETWORK_DIASPORA, NETWORK_OSTATUS];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default: /// @TODO Maybe log this call?
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$x = ['options' => $options, 'size' => $size, 'single' => $single, 'mutual' => $mutual, 'exclude' => $exclude, 'networks' => $networks];
|
||||||
|
|
||||||
|
Addon::callHooks('contact_select_options', $x);
|
||||||
|
|
||||||
|
$o = '';
|
||||||
|
|
||||||
|
$sql_extra = '';
|
||||||
|
|
||||||
|
if (!empty($x['mutual'])) {
|
||||||
|
$sql_extra .= sprintf(" AND `rel` = %d ", intval(CONTACT_IS_FRIEND));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($x['exclude'])) {
|
||||||
|
$sql_extra .= sprintf(" AND `id` != %d ", intval($x['exclude']));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($x['networks'])) {
|
||||||
|
/// @TODO rewrite to foreach()
|
||||||
|
array_walk($x['networks'], function (&$value) {
|
||||||
|
$value = "'" . dbesc($value) . "'";
|
||||||
|
});
|
||||||
|
$str_nets = implode(',', $x['networks']);
|
||||||
|
$sql_extra .= " AND `network` IN ( $str_nets ) ";
|
||||||
|
}
|
||||||
|
|
||||||
|
$tabindex = (!empty($options['tabindex']) ? 'tabindex="' . $options["tabindex"] . '"' : '');
|
||||||
|
|
||||||
|
if (!empty($x['single'])) {
|
||||||
|
$o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"" . $x['size'] . "\" $tabindex >\r\n";
|
||||||
|
} else {
|
||||||
|
$o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"" . $x['size'] . "$\" $tabindex >\r\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt = dba::p("SELECT `id`, `name`, `url`, `network` FROM `contact`
|
||||||
|
WHERE `uid` = ? AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
|
||||||
|
$sql_extra
|
||||||
|
ORDER BY `name` ASC ", intval(local_user())
|
||||||
|
);
|
||||||
|
|
||||||
|
$contacts = dba::inArray($stmt);
|
||||||
|
|
||||||
|
$arr = ['contact' => $contacts, 'entry' => $o];
|
||||||
|
|
||||||
|
// e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow'
|
||||||
|
Addon::callHooks($a->module . '_pre_' . $selname, $arr);
|
||||||
|
|
||||||
|
if (DBM::is_result($contacts)) {
|
||||||
|
foreach ($contacts as $contact) {
|
||||||
|
if (in_array($contact['id'], $preselected)) {
|
||||||
|
$selected = ' selected="selected" ';
|
||||||
|
} else {
|
||||||
|
$selected = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$trimmed = mb_substr($contact['name'], 0, 20);
|
||||||
|
|
||||||
|
$o .= "<option value=\"{$contact['id']}\" $selected title=\"{$contact['name']}|{$contact['url']}\" >$trimmed</option>\r\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$o .= '</select>' . PHP_EOL;
|
||||||
|
|
||||||
|
Addon::callHooks($a->module . '_post_' . $selname, $o);
|
||||||
|
|
||||||
|
return $o;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a select input tag with all the contact of the local user
|
||||||
|
*
|
||||||
|
* @param string $selname Name attribute of the select input tag
|
||||||
|
* @param string $selclass Class attribute of the select input tag
|
||||||
|
* @param array $preselected Contact IDs that should be already selected
|
||||||
|
* @param int $size Length of the select box
|
||||||
|
* @param int $tabindex Select input tag tabindex attribute
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getMessageContactSelectHTML($selname, $selclass, array $preselected = [], $size = 4, $tabindex = null)
|
||||||
|
{
|
||||||
|
$a = self::getApp();
|
||||||
|
|
||||||
|
$o = '';
|
||||||
|
|
||||||
|
// When used for private messages, we limit correspondence to mutual DFRN/Friendica friends and the selector
|
||||||
|
// to one recipient. By default our selector allows multiple selects amongst all contacts.
|
||||||
|
$sql_extra = sprintf(" AND `rel` = %d ", intval(CONTACT_IS_FRIEND));
|
||||||
|
$sql_extra .= sprintf(" AND `network` IN ('%s' , '%s') ", NETWORK_DFRN, NETWORK_DIASPORA);
|
||||||
|
|
||||||
|
$tabindex_attr = !empty($tabindex) ? ' tabindex="' . intval($tabindex) . '"' : '';
|
||||||
|
|
||||||
|
$hidepreselected = '';
|
||||||
|
if ($preselected) {
|
||||||
|
$sql_extra .= " AND `id` IN (" . implode(",", $preselected) . ")";
|
||||||
|
$hidepreselected = ' style="display: none;"';
|
||||||
|
}
|
||||||
|
|
||||||
|
$o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"$size\"$tabindex_attr$hidepreselected>\r\n";
|
||||||
|
|
||||||
|
$stmt = dba::p("SELECT `id`, `name`, `url`, `network` FROM `contact`
|
||||||
|
WHERE `uid` = ? AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
|
||||||
|
$sql_extra
|
||||||
|
ORDER BY `name` ASC ", intval(local_user())
|
||||||
|
);
|
||||||
|
|
||||||
|
$contacts = dba::inArray($stmt);
|
||||||
|
|
||||||
|
$arr = ['contact' => $contacts, 'entry' => $o];
|
||||||
|
|
||||||
|
// e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow'
|
||||||
|
Addon::callHooks($a->module . '_pre_' . $selname, $arr);
|
||||||
|
|
||||||
|
$receiverlist = [];
|
||||||
|
|
||||||
|
if (DBM::is_result($contacts)) {
|
||||||
|
foreach ($contacts as $contact) {
|
||||||
|
if (in_array($contact['id'], $preselected)) {
|
||||||
|
$selected = ' selected="selected"';
|
||||||
|
} else {
|
||||||
|
$selected = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$trimmed = Protocol::formatMention($contact['url'], $contact['name']);
|
||||||
|
|
||||||
|
$receiverlist[] = $trimmed;
|
||||||
|
|
||||||
|
$o .= "<option value=\"{$contact['id']}\"$selected title=\"{$contact['name']}|{$contact['url']}\" >$trimmed</option>\r\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$o .= '</select>' . PHP_EOL;
|
||||||
|
|
||||||
|
if ($preselected) {
|
||||||
|
$o .= implode(', ', $receiverlist);
|
||||||
|
}
|
||||||
|
|
||||||
|
Addon::callHooks($a->module . '_post_' . $selname, $o);
|
||||||
|
|
||||||
|
return $o;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function fixACL(&$item)
|
||||||
|
{
|
||||||
|
$item = intval(str_replace(['<', '>'], ['', ''], $item));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the default permission of the provided user array
|
||||||
|
*
|
||||||
|
* @param array $user
|
||||||
|
* @return array Hash of contact id lists
|
||||||
|
*/
|
||||||
|
public static function getDefaultUserPermissions(array $user = null)
|
||||||
|
{
|
||||||
|
$matches = [];
|
||||||
|
|
||||||
|
$acl_regex = '/<([0-9]+)>/i';
|
||||||
|
|
||||||
|
preg_match_all($acl_regex, defaults($user, 'allow_cid', ''), $matches);
|
||||||
|
$allow_cid = $matches[1];
|
||||||
|
preg_match_all($acl_regex, defaults($user, 'allow_gid', ''), $matches);
|
||||||
|
$allow_gid = $matches[1];
|
||||||
|
preg_match_all($acl_regex, defaults($user, 'deny_cid', ''), $matches);
|
||||||
|
$deny_cid = $matches[1];
|
||||||
|
preg_match_all($acl_regex, defaults($user, 'deny_gid', ''), $matches);
|
||||||
|
$deny_gid = $matches[1];
|
||||||
|
|
||||||
|
// Reformats the ACL data so that it is accepted by the JS frontend
|
||||||
|
array_walk($allow_cid, 'self::fixACL');
|
||||||
|
array_walk($allow_gid, 'self::fixACL');
|
||||||
|
array_walk($deny_cid, 'self::fixACL');
|
||||||
|
array_walk($deny_gid, 'self::fixACL');
|
||||||
|
|
||||||
|
Contact::pruneUnavailable($allow_cid);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'allow_cid' => $allow_cid,
|
||||||
|
'allow_gid' => $allow_gid,
|
||||||
|
'deny_cid' => $deny_cid,
|
||||||
|
'deny_gid' => $deny_gid,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the full jot ACL selector HTML
|
||||||
|
*
|
||||||
|
* @param array $user
|
||||||
|
* @param bool $show_jotnets
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getFullSelectorHTML(array $user = null, $show_jotnets = false)
|
||||||
|
{
|
||||||
|
$perms = self::getDefaultUserPermissions($user);
|
||||||
|
|
||||||
|
$jotnets = '';
|
||||||
|
if ($show_jotnets) {
|
||||||
|
$imap_disabled = !function_exists('imap_open') || Config::get('system', 'imap_disabled');
|
||||||
|
|
||||||
|
$mail_enabled = false;
|
||||||
|
$pubmail_enabled = false;
|
||||||
|
|
||||||
|
if (!$imap_disabled) {
|
||||||
|
$mailacct = dba::selectFirst('mailacct', ['pubmail'], ['`uid` = ? AND `server` != ""', local_user()]);
|
||||||
|
if (DBM::is_result($mailacct)) {
|
||||||
|
$mail_enabled = true;
|
||||||
|
$pubmail_enabled = !empty($mailacct['pubmail']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($user['hidewall'])) {
|
||||||
|
if ($mail_enabled) {
|
||||||
|
$selected = $pubmail_enabled ? ' checked="checked"' : '';
|
||||||
|
$jotnets .= '<div class="profile-jot-net"><input type="checkbox" name="pubmail_enable"' . $selected . ' value="1" /> ' . L10n::t("Post to Email") . '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
Addon::callHooks('jot_networks', $jotnets);
|
||||||
|
} else {
|
||||||
|
$jotnets .= L10n::t('Connectors disabled, since "%s" is enabled.',
|
||||||
|
L10n::t('Hide your profile details from unknown viewers?'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$tpl = get_markup_template('acl_selector.tpl');
|
||||||
|
$o = replace_macros($tpl, [
|
||||||
|
'$showall' => L10n::t('Visible to everybody'),
|
||||||
|
'$show' => L10n::t('show'),
|
||||||
|
'$hide' => L10n::t('don\'t show'),
|
||||||
|
'$allowcid' => json_encode($perms['allow_cid']),
|
||||||
|
'$allowgid' => json_encode($perms['allow_gid']),
|
||||||
|
'$denycid' => json_encode($perms['deny_cid']),
|
||||||
|
'$denygid' => json_encode($perms['deny_gid']),
|
||||||
|
'$networks' => $show_jotnets,
|
||||||
|
'$emailcc' => L10n::t('CC: email addresses'),
|
||||||
|
'$emtitle' => L10n::t('Example: bob@example.com, mary@example.com'),
|
||||||
|
'$jotnets' => $jotnets,
|
||||||
|
'$aclModalTitle' => L10n::t('Permissions'),
|
||||||
|
'$aclModalDismiss' => L10n::t('Close'),
|
||||||
|
'$features' => [
|
||||||
|
'aclautomention' => Feature::isEnabled($user['uid'], 'aclautomention') ? 'true' : 'false'
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $o;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Searching for global contacts for autocompletion
|
||||||
|
*
|
||||||
|
* @brief Searching for global contacts for autocompletion
|
||||||
|
* @param string $search Name or part of a name or nick
|
||||||
|
* @param string $mode Search mode (e.g. "community")
|
||||||
|
* @return array with the search results
|
||||||
|
*/
|
||||||
|
public static function contactAutocomplete($search, $mode)
|
||||||
|
{
|
||||||
|
if ((Config::get('system', 'block_public')) && (!local_user()) && (!remote_user())) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// don't search if search term has less than 2 characters
|
||||||
|
if (!$search || mb_strlen($search) < 2) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (substr($search, 0, 1) === '@') {
|
||||||
|
$search = substr($search, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if searching in the local global contact table is enabled
|
||||||
|
if (Config::get('system', 'poco_local_search')) {
|
||||||
|
$return = GContact::searchByName($search, $mode);
|
||||||
|
} else {
|
||||||
|
$a = self::getApp();
|
||||||
|
$p = $a->pager['page'] != 1 ? '&p=' . $a->pager['page'] : '';
|
||||||
|
|
||||||
|
$response = Network::curl(get_server() . '/lsearch?f=' . $p . '&search=' . urlencode($search));
|
||||||
|
if ($response['success']) {
|
||||||
|
$lsearch = json_decode($response['body'], true);
|
||||||
|
if (!empty($lsearch['results'])) {
|
||||||
|
$return = $lsearch['results'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return defaults($return, []);
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,83 +4,59 @@
|
||||||
*/
|
*/
|
||||||
namespace Friendica\Core;
|
namespace Friendica\Core;
|
||||||
|
|
||||||
|
use Friendica\Core\Cache;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Database\DBM;
|
|
||||||
use Friendica\Util\DateTimeFormat;
|
|
||||||
use dba;
|
|
||||||
use Memcache;
|
|
||||||
|
|
||||||
require_once 'include/dba.php';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Class for storing data for a short time
|
* @brief Class for storing data for a short time
|
||||||
*/
|
*/
|
||||||
class Cache
|
class Cache extends \Friendica\BaseObject
|
||||||
{
|
{
|
||||||
|
const MONTH = 2592000;
|
||||||
|
const WEEK = 604800;
|
||||||
|
const DAY = 86400;
|
||||||
|
const HOUR = 3600;
|
||||||
|
const HALF_HOUR = 1800;
|
||||||
|
const QUARTER_HOUR = 900;
|
||||||
|
const FIVE_MINUTES = 300;
|
||||||
|
const MINUTE = 60;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Check for Memcache and open a connection if configured
|
* @var Cache\ICacheDriver
|
||||||
*
|
|
||||||
* @return Memcache|boolean The Memcache object - or "false" if not successful
|
|
||||||
*/
|
*/
|
||||||
public static function memcache()
|
static $driver = null;
|
||||||
|
|
||||||
|
public static function init()
|
||||||
{
|
{
|
||||||
if (!class_exists('Memcache', false)) {
|
switch(Config::get('system', 'cache_driver', 'database')) {
|
||||||
return false;
|
case 'memcache':
|
||||||
|
$memcache_host = Config::get('system', 'memcache_host', '127.0.0.1');
|
||||||
|
$memcache_port = Config::get('system', 'memcache_port', 11211);
|
||||||
|
|
||||||
|
self::$driver = new Cache\MemcacheCacheDriver($memcache_host, $memcache_port);
|
||||||
|
break;
|
||||||
|
case 'memcached':
|
||||||
|
$memcached_hosts = Config::get('system', 'memcached_hosts', [['127.0.0.1', 11211]]);
|
||||||
|
|
||||||
|
self::$driver = new Cache\MemcachedCacheDriver($memcached_hosts);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
self::$driver = new Cache\DatabaseCacheDriver();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Config::get('system', 'memcache')) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$memcache_host = Config::get('system', 'memcache_host', '127.0.0.1');
|
|
||||||
$memcache_port = Config::get('system', 'memcache_port', 11211);
|
|
||||||
|
|
||||||
$memcache = new Memcache();
|
|
||||||
|
|
||||||
if (!$memcache->connect($memcache_host, $memcache_port)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $memcache;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Return the duration for a given cache level
|
* Returns the current cache driver
|
||||||
*
|
*
|
||||||
* @param integer $level Cache level
|
* @return Cache\ICacheDriver
|
||||||
*
|
|
||||||
* @return integer The cache duration in seconds
|
|
||||||
*/
|
*/
|
||||||
private static function duration($level)
|
private static function getDriver()
|
||||||
{
|
{
|
||||||
switch ($level) {
|
if (self::$driver === null) {
|
||||||
case CACHE_MONTH:
|
self::init();
|
||||||
$seconds = 2592000;
|
|
||||||
break;
|
|
||||||
case CACHE_WEEK:
|
|
||||||
$seconds = 604800;
|
|
||||||
break;
|
|
||||||
case CACHE_DAY:
|
|
||||||
$seconds = 86400;
|
|
||||||
break;
|
|
||||||
case CACHE_HOUR:
|
|
||||||
$seconds = 3600;
|
|
||||||
break;
|
|
||||||
case CACHE_HALF_HOUR:
|
|
||||||
$seconds = 1800;
|
|
||||||
break;
|
|
||||||
case CACHE_QUARTER_HOUR:
|
|
||||||
$seconds = 900;
|
|
||||||
break;
|
|
||||||
case CACHE_FIVE_MINUTES:
|
|
||||||
$seconds = 300;
|
|
||||||
break;
|
|
||||||
case CACHE_MINUTE:
|
|
||||||
default:
|
|
||||||
$seconds = 60;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return $seconds;
|
|
||||||
|
return self::$driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,40 +68,13 @@ class Cache
|
||||||
*/
|
*/
|
||||||
public static function get($key)
|
public static function get($key)
|
||||||
{
|
{
|
||||||
$memcache = self::memcache();
|
$time = microtime(true);
|
||||||
if (is_object($memcache)) {
|
|
||||||
// We fetch with the hostname as key to avoid problems with other applications
|
|
||||||
$cached = $memcache->get(get_app()->get_hostname().":".$key);
|
|
||||||
$value = @unserialize($cached);
|
|
||||||
|
|
||||||
// Only return a value if the serialized value is valid.
|
$return = self::getDriver()->get($key);
|
||||||
// We also check if the db entry is a serialized
|
|
||||||
// boolean 'false' value (which we want to return).
|
|
||||||
if ($cached === serialize(false) || $value !== false) {
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
self::getApp()->save_timestamp($time, 'cache');
|
||||||
}
|
|
||||||
|
|
||||||
// Frequently clear cache
|
return $return;
|
||||||
self::clear();
|
|
||||||
|
|
||||||
$cache = dba::selectFirst('cache', ['v'], ['k' => $key]);
|
|
||||||
|
|
||||||
if (DBM::is_result($cache)) {
|
|
||||||
$cached = $cache['v'];
|
|
||||||
$value = @unserialize($cached);
|
|
||||||
|
|
||||||
// Only return a value if the serialized value is valid.
|
|
||||||
// We also check if the db entry is a serialized
|
|
||||||
// boolean 'false' value (which we want to return).
|
|
||||||
if ($cached === serialize(false) || $value !== false) {
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -137,20 +86,35 @@ class Cache
|
||||||
* @param mixed $value The value that is about to be stored
|
* @param mixed $value The value that is about to be stored
|
||||||
* @param integer $duration The cache lifespan
|
* @param integer $duration The cache lifespan
|
||||||
*
|
*
|
||||||
* @return void
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function set($key, $value, $duration = CACHE_MONTH)
|
public static function set($key, $value, $duration = self::MONTH)
|
||||||
{
|
{
|
||||||
// Do we have an installed memcache? Use it instead.
|
$time = microtime(true);
|
||||||
$memcache = self::memcache();
|
|
||||||
if (is_object($memcache)) {
|
$return = self::getDriver()->set($key, $value, $duration);
|
||||||
// We store with the hostname as key to avoid problems with other applications
|
|
||||||
$memcache->set(get_app()->get_hostname().":".$key, serialize($value), MEMCACHE_COMPRESSED, self::duration($duration));
|
self::getApp()->save_timestamp($time, 'cache_write');
|
||||||
return;
|
|
||||||
}
|
return $return;
|
||||||
$fields = ['v' => serialize($value), 'expire_mode' => $duration, 'updated' => DateTimeFormat::utcNow()];
|
}
|
||||||
$condition = ['k' => $key];
|
|
||||||
dba::update('cache', $fields, $condition, true);
|
/**
|
||||||
|
* @brief Delete a value from the cache
|
||||||
|
*
|
||||||
|
* @param string $key The key to the cached data
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function delete($key)
|
||||||
|
{
|
||||||
|
$time = microtime(true);
|
||||||
|
|
||||||
|
$return = self::getDriver()->delete($key);
|
||||||
|
|
||||||
|
self::getApp()->save_timestamp($time, 'cache_write');
|
||||||
|
|
||||||
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -160,76 +124,8 @@ class Cache
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function clear($max_level = CACHE_MONTH)
|
public static function clear()
|
||||||
{
|
{
|
||||||
// Clear long lasting cache entries only once a day
|
return self::getDriver()->clear();
|
||||||
if (Config::get("system", "cache_cleared_day") < time() - self::duration(CACHE_DAY)) {
|
|
||||||
if ($max_level == CACHE_MONTH) {
|
|
||||||
$condition = ["`updated` < ? AND `expire_mode` = ?",
|
|
||||||
DateTimeFormat::utc("now - 30 days"),
|
|
||||||
CACHE_MONTH];
|
|
||||||
dba::delete('cache', $condition);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($max_level <= CACHE_WEEK) {
|
|
||||||
$condition = ["`updated` < ? AND `expire_mode` = ?",
|
|
||||||
DateTimeFormat::utc("now - 7 days"),
|
|
||||||
CACHE_WEEK];
|
|
||||||
dba::delete('cache', $condition);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($max_level <= CACHE_DAY) {
|
|
||||||
$condition = ["`updated` < ? AND `expire_mode` = ?",
|
|
||||||
DateTimeFormat::utc("now - 1 days"),
|
|
||||||
CACHE_DAY];
|
|
||||||
dba::delete('cache', $condition);
|
|
||||||
}
|
|
||||||
Config::set("system", "cache_cleared_day", time());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($max_level <= CACHE_HOUR) && (Config::get("system", "cache_cleared_hour")) < time() - self::duration(CACHE_HOUR)) {
|
|
||||||
$condition = ["`updated` < ? AND `expire_mode` = ?",
|
|
||||||
DateTimeFormat::utc("now - 1 hours"),
|
|
||||||
CACHE_HOUR];
|
|
||||||
dba::delete('cache', $condition);
|
|
||||||
|
|
||||||
Config::set("system", "cache_cleared_hour", time());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($max_level <= CACHE_HALF_HOUR) && (Config::get("system", "cache_cleared_half_hour")) < time() - self::duration(CACHE_HALF_HOUR)) {
|
|
||||||
$condition = ["`updated` < ? AND `expire_mode` = ?",
|
|
||||||
DateTimeFormat::utc("now - 30 minutes"),
|
|
||||||
CACHE_HALF_HOUR];
|
|
||||||
dba::delete('cache', $condition);
|
|
||||||
|
|
||||||
Config::set("system", "cache_cleared_half_hour", time());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($max_level <= CACHE_QUARTER_HOUR) && (Config::get("system", "cache_cleared_quarter_hour")) < time() - self::duration(CACHE_QUARTER_HOUR)) {
|
|
||||||
$condition = ["`updated` < ? AND `expire_mode` = ?",
|
|
||||||
DateTimeFormat::utc("now - 15 minutes"),
|
|
||||||
CACHE_QUARTER_HOUR];
|
|
||||||
dba::delete('cache', $condition);
|
|
||||||
|
|
||||||
Config::set("system", "cache_cleared_quarter_hour", time());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($max_level <= CACHE_FIVE_MINUTES) && (Config::get("system", "cache_cleared_five_minute")) < time() - self::duration(CACHE_FIVE_MINUTES)) {
|
|
||||||
$condition = ["`updated` < ? AND `expire_mode` = ?",
|
|
||||||
DateTimeFormat::utc("now - 5 minutes"),
|
|
||||||
CACHE_FIVE_MINUTES];
|
|
||||||
dba::delete('cache', $condition);
|
|
||||||
|
|
||||||
Config::set("system", "cache_cleared_five_minute", time());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($max_level <= CACHE_MINUTE) && (Config::get("system", "cache_cleared_minute")) < time() - self::duration(CACHE_MINUTE)) {
|
|
||||||
$condition = ["`updated` < ? AND `expire_mode` = ?",
|
|
||||||
DateTimeFormat::utc("now - 1 minutes"),
|
|
||||||
CACHE_MINUTE];
|
|
||||||
dba::delete('cache', $condition);
|
|
||||||
|
|
||||||
Config::set("system", "cache_cleared_minute", time());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
56
src/Core/Cache/DatabaseCacheDriver.php
Normal file
56
src/Core/Cache/DatabaseCacheDriver.php
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Friendica\Core\Cache;
|
||||||
|
|
||||||
|
use dba;
|
||||||
|
use Friendica\Core\Cache;
|
||||||
|
use Friendica\Database\DBM;
|
||||||
|
use Friendica\Util\DateTimeFormat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Database Cache Driver
|
||||||
|
*
|
||||||
|
* @author Hypolite Petovan <mrpetovan@gmail.com>
|
||||||
|
*/
|
||||||
|
class DatabaseCacheDriver implements ICacheDriver
|
||||||
|
{
|
||||||
|
public function get($key)
|
||||||
|
{
|
||||||
|
$cache = dba::selectFirst('cache', ['v'], ['`k` = ? AND `expires` >= ?', $key, DateTimeFormat::utcNow()]);
|
||||||
|
|
||||||
|
if (DBM::is_result($cache)) {
|
||||||
|
$cached = $cache['v'];
|
||||||
|
$value = @unserialize($cached);
|
||||||
|
|
||||||
|
// Only return a value if the serialized value is valid.
|
||||||
|
// We also check if the db entry is a serialized
|
||||||
|
// boolean 'false' value (which we want to return).
|
||||||
|
if ($cached === serialize(false) || $value !== false) {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set($key, $value, $duration = Cache::MONTH)
|
||||||
|
{
|
||||||
|
$fields = [
|
||||||
|
'v' => serialize($value),
|
||||||
|
'expires' => DateTimeFormat::utc('now + ' . $duration . ' seconds'),
|
||||||
|
'updated' => DateTimeFormat::utcNow()
|
||||||
|
];
|
||||||
|
|
||||||
|
return dba::update('cache', $fields, ['k' => $key], true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete($key)
|
||||||
|
{
|
||||||
|
return dba::delete('cache', ['k' => $key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clear()
|
||||||
|
{
|
||||||
|
return dba::delete('cache', ['`expires` < NOW()']);
|
||||||
|
}
|
||||||
|
}
|
50
src/Core/Cache/ICacheDriver.php
Normal file
50
src/Core/Cache/ICacheDriver.php
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Friendica\Core\Cache;
|
||||||
|
|
||||||
|
use Friendica\Core\Cache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cache Driver Interface
|
||||||
|
*
|
||||||
|
* @author Hypolite Petovan <mrpetovan@gmail.com>
|
||||||
|
*/
|
||||||
|
interface ICacheDriver
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Fetches cached data according to the key
|
||||||
|
*
|
||||||
|
* @param string $key The key to the cached data
|
||||||
|
*
|
||||||
|
* @return mixed Cached $value or "null" if not found
|
||||||
|
*/
|
||||||
|
public function get($key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores data in the cache identified by the key. The input $value can have multiple formats.
|
||||||
|
*
|
||||||
|
* @param string $key The cache key
|
||||||
|
* @param mixed $value The value to store
|
||||||
|
* @param integer $duration The cache lifespan, must be one of the Cache constants
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function set($key, $value, $duration = Cache::MONTH);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a key from the cache
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function delete($key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove outdated data from the cache
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function clear();
|
||||||
|
}
|
77
src/Core/Cache/MemcacheCacheDriver.php
Normal file
77
src/Core/Cache/MemcacheCacheDriver.php
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Friendica\Core\Cache;
|
||||||
|
|
||||||
|
use Friendica\BaseObject;
|
||||||
|
use Friendica\Core\Cache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Memcache Cache Driver
|
||||||
|
*
|
||||||
|
* @author Hypolite Petovan <mrpetovan@gmail.com>
|
||||||
|
*/
|
||||||
|
class MemcacheCacheDriver extends BaseObject implements ICacheDriver
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Memcache
|
||||||
|
*/
|
||||||
|
private $memcache;
|
||||||
|
|
||||||
|
public function __construct($memcache_host, $memcache_port)
|
||||||
|
{
|
||||||
|
if (!class_exists('Memcache', false)) {
|
||||||
|
throw new \Exception('Memcache class isn\'t available');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->memcache = new \Memcache();
|
||||||
|
|
||||||
|
if (!$this->memcache->connect($memcache_host, $memcache_port)) {
|
||||||
|
throw new \Exception('Expected Memcache server at ' . $memcache_host . ':' . $memcache_port . ' isn\'t available');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get($key)
|
||||||
|
{
|
||||||
|
$return = null;
|
||||||
|
|
||||||
|
// We fetch with the hostname as key to avoid problems with other applications
|
||||||
|
$cached = $this->memcache->get(self::getApp()->get_hostname() . ':' . $key);
|
||||||
|
|
||||||
|
// @see http://php.net/manual/en/memcache.get.php#84275
|
||||||
|
if (is_bool($cached) || is_double($cached) || is_long($cached)) {
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$value = @unserialize($cached);
|
||||||
|
|
||||||
|
// Only return a value if the serialized value is valid.
|
||||||
|
// We also check if the db entry is a serialized
|
||||||
|
// boolean 'false' value (which we want to return).
|
||||||
|
if ($cached === serialize(false) || $value !== false) {
|
||||||
|
$return = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set($key, $value, $duration = Cache::MONTH)
|
||||||
|
{
|
||||||
|
// We store with the hostname as key to avoid problems with other applications
|
||||||
|
return $this->memcache->set(
|
||||||
|
self::getApp()->get_hostname() . ":" . $key,
|
||||||
|
serialize($value),
|
||||||
|
MEMCACHE_COMPRESSED,
|
||||||
|
time() + $duration
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete($key)
|
||||||
|
{
|
||||||
|
return $this->memcache->delete($key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clear()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
68
src/Core/Cache/MemcachedCacheDriver.php
Normal file
68
src/Core/Cache/MemcachedCacheDriver.php
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Friendica\Core\Cache;
|
||||||
|
|
||||||
|
use Friendica\BaseObject;
|
||||||
|
use Friendica\Core\Cache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Memcached Cache Driver
|
||||||
|
*
|
||||||
|
* @author Hypolite Petovan <mrpetovan@gmail.com>
|
||||||
|
*/
|
||||||
|
class MemcachedCacheDriver extends BaseObject implements ICacheDriver
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Memcached
|
||||||
|
*/
|
||||||
|
private $memcached;
|
||||||
|
|
||||||
|
public function __construct(array $memcached_hosts)
|
||||||
|
{
|
||||||
|
if (!class_exists('Memcached', false)) {
|
||||||
|
throw new \Exception('Memcached class isn\'t available');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->memcached = new \Memcached();
|
||||||
|
|
||||||
|
$this->memcached->addServers($memcached_hosts);
|
||||||
|
|
||||||
|
if (count($this->memcached->getServerList()) == 0) {
|
||||||
|
throw new \Exception('Expected Memcached servers aren\'t available, config:' . var_export($memcached_hosts, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get($key)
|
||||||
|
{
|
||||||
|
$return = null;
|
||||||
|
|
||||||
|
// We fetch with the hostname as key to avoid problems with other applications
|
||||||
|
$value = $this->memcached->get(self::getApp()->get_hostname() . ':' . $key);
|
||||||
|
|
||||||
|
if ($this->memcached->getResultCode() === \Memcached::RES_SUCCESS) {
|
||||||
|
$return = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set($key, $value, $duration = Cache::MONTH)
|
||||||
|
{
|
||||||
|
// We store with the hostname as key to avoid problems with other applications
|
||||||
|
return $this->memcached->set(
|
||||||
|
self::getApp()->get_hostname() . ":" . $key,
|
||||||
|
$value,
|
||||||
|
time() + $duration
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete($key)
|
||||||
|
{
|
||||||
|
return $this->memcached->delete($key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clear()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,26 +8,33 @@
|
||||||
*/
|
*/
|
||||||
namespace Friendica\Core;
|
namespace Friendica\Core;
|
||||||
|
|
||||||
use Friendica\Database\DBM;
|
use Friendica\BaseObject;
|
||||||
use dba;
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
require_once 'include/dba.php';
|
require_once 'include/dba.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Arbitrary sytem configuration storage
|
* @brief Arbitrary system configuration storage
|
||||||
*
|
*
|
||||||
* Note:
|
* Note:
|
||||||
* If we ever would decide to return exactly the variable type as entered,
|
* If we ever would decide to return exactly the variable type as entered,
|
||||||
* we will have fun with the additional features. :-)
|
* we will have fun with the additional features. :-)
|
||||||
*
|
|
||||||
* The config class always returns strings but in the default features
|
|
||||||
* we use a "false" to determine if the config value isn't set.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class Config
|
class Config extends BaseObject
|
||||||
{
|
{
|
||||||
private static $cache;
|
/**
|
||||||
private static $in_db;
|
* @var Friendica\Core\Config\IConfigAdapter
|
||||||
|
*/
|
||||||
|
private static $adapter = null;
|
||||||
|
|
||||||
|
public static function init()
|
||||||
|
{
|
||||||
|
if (self::getApp()->getConfigValue('system', 'config_adapter') == 'preload') {
|
||||||
|
self::$adapter = new Config\PreloadConfigAdapter();
|
||||||
|
} else {
|
||||||
|
self::$adapter = new Config\JITConfigAdapter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Loads all configuration values of family into a cached storage.
|
* @brief Loads all configuration values of family into a cached storage.
|
||||||
|
@ -41,26 +48,11 @@ class Config
|
||||||
*/
|
*/
|
||||||
public static function load($family = "config")
|
public static function load($family = "config")
|
||||||
{
|
{
|
||||||
// We don't preload "system" anymore.
|
if (empty(self::$adapter)) {
|
||||||
// This reduces the number of database reads a lot.
|
self::init();
|
||||||
if ($family === 'system') {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$a = get_app();
|
self::$adapter->load($family);
|
||||||
|
|
||||||
$r = dba::select('config', ['v', 'k'], ['cat' => $family]);
|
|
||||||
while ($rr = dba::fetch($r)) {
|
|
||||||
$k = $rr['k'];
|
|
||||||
if ($family === 'config') {
|
|
||||||
$a->config[$k] = $rr['v'];
|
|
||||||
} else {
|
|
||||||
$a->config[$family][$k] = $rr['v'];
|
|
||||||
self::$cache[$family][$k] = $rr['v'];
|
|
||||||
self::$in_db[$family][$k] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dba::close($r);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,40 +76,11 @@ class Config
|
||||||
*/
|
*/
|
||||||
public static function get($family, $key, $default_value = null, $refresh = false)
|
public static function get($family, $key, $default_value = null, $refresh = false)
|
||||||
{
|
{
|
||||||
$a = get_app();
|
if (empty(self::$adapter)) {
|
||||||
|
self::init();
|
||||||
if (!$refresh) {
|
|
||||||
// Do we have the cached value? Then return it
|
|
||||||
if (isset(self::$cache[$family][$key])) {
|
|
||||||
if (self::$cache[$family][$key] === '!<unset>!') {
|
|
||||||
return $default_value;
|
|
||||||
} else {
|
|
||||||
return self::$cache[$family][$key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$config = dba::selectFirst('config', ['v'], ['cat' => $family, 'k' => $key]);
|
return self::$adapter->get($family, $key, $default_value, $refresh);
|
||||||
if (DBM::is_result($config)) {
|
|
||||||
// manage array value
|
|
||||||
$val = (preg_match("|^a:[0-9]+:{.*}$|s", $config['v']) ? unserialize($config['v']) : $config['v']);
|
|
||||||
|
|
||||||
// Assign the value from the database to the cache
|
|
||||||
self::$cache[$family][$key] = $val;
|
|
||||||
self::$in_db[$family][$key] = true;
|
|
||||||
return $val;
|
|
||||||
} elseif (isset($a->config[$family][$key])) {
|
|
||||||
// Assign the value (mostly) from the .htconfig.php to the cache
|
|
||||||
self::$cache[$family][$key] = $a->config[$family][$key];
|
|
||||||
self::$in_db[$family][$key] = false;
|
|
||||||
|
|
||||||
return $a->config[$family][$key];
|
|
||||||
}
|
|
||||||
|
|
||||||
self::$cache[$family][$key] = '!<unset>!';
|
|
||||||
self::$in_db[$family][$key] = false;
|
|
||||||
|
|
||||||
return $default_value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,38 +99,11 @@ class Config
|
||||||
*/
|
*/
|
||||||
public static function set($family, $key, $value)
|
public static function set($family, $key, $value)
|
||||||
{
|
{
|
||||||
$a = get_app();
|
if (empty(self::$adapter)) {
|
||||||
|
self::init();
|
||||||
// We store our setting values in a string variable.
|
|
||||||
// So we have to do the conversion here so that the compare below works.
|
|
||||||
// The exception are array values.
|
|
||||||
$dbvalue = (!is_array($value) ? (string)$value : $value);
|
|
||||||
|
|
||||||
$stored = self::get($family, $key, null, true);
|
|
||||||
|
|
||||||
if (($stored === $dbvalue) && self::$in_db[$family][$key]) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($family === 'config') {
|
return self::$adapter->set($family, $key, $value);
|
||||||
$a->config[$key] = $dbvalue;
|
|
||||||
} elseif ($family != 'system') {
|
|
||||||
$a->config[$family][$key] = $dbvalue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assign the just added value to the cache
|
|
||||||
self::$cache[$family][$key] = $dbvalue;
|
|
||||||
|
|
||||||
// manage array value
|
|
||||||
$dbvalue = (is_array($value) ? serialize($value) : $dbvalue);
|
|
||||||
|
|
||||||
$ret = dba::update('config', ['v' => $dbvalue], ['cat' => $family, 'k' => $key], true);
|
|
||||||
|
|
||||||
if ($ret) {
|
|
||||||
self::$in_db[$family][$key] = true;
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
return $ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -183,13 +119,10 @@ class Config
|
||||||
*/
|
*/
|
||||||
public static function delete($family, $key)
|
public static function delete($family, $key)
|
||||||
{
|
{
|
||||||
if (isset(self::$cache[$family][$key])) {
|
if (empty(self::$adapter)) {
|
||||||
unset(self::$cache[$family][$key]);
|
self::init();
|
||||||
unset(self::$in_db[$family][$key]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = dba::delete('config', ['cat' => $family, 'k' => $key]);
|
return self::$adapter->delete($family, $key);
|
||||||
|
|
||||||
return $ret;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
72
src/Core/Config/IConfigAdapter.php
Normal file
72
src/Core/Config/IConfigAdapter.php
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Friendica\Core\Config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Hypolite Petovan <mrpetovan@gmail.com>
|
||||||
|
*/
|
||||||
|
interface IConfigAdapter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief Loads all configuration values into a cached storage.
|
||||||
|
*
|
||||||
|
* All configuration values of the system are stored in global cache
|
||||||
|
* which is available under the global variable $a->config
|
||||||
|
*
|
||||||
|
* @param string $cat The category of the configuration values to load
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function load($cat = "config");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get a particular user's config variable given the category name
|
||||||
|
* ($family) and a key.
|
||||||
|
*
|
||||||
|
* Get a particular config value from the given category ($family)
|
||||||
|
* and the $key from a cached storage in $a->config[$uid].
|
||||||
|
* $instore is only used by the set_config function
|
||||||
|
* to determine if the key already exists in the DB
|
||||||
|
* If a key is found in the DB but doesn't exist in
|
||||||
|
* local config cache, pull it into the cache so we don't have
|
||||||
|
* to hit the DB again for this item.
|
||||||
|
*
|
||||||
|
* @param string $cat The category of the configuration value
|
||||||
|
* @param string $k The configuration key to query
|
||||||
|
* @param mixed $default_value optional, The value to return if key is not set (default: null)
|
||||||
|
* @param boolean $refresh optional, If true the config is loaded from the db and not from the cache (default: false)
|
||||||
|
*
|
||||||
|
* @return mixed Stored value or null if it does not exist
|
||||||
|
*/
|
||||||
|
public function get($cat, $k, $default_value = null, $refresh = false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets a configuration value for system config
|
||||||
|
*
|
||||||
|
* Stores a config value ($value) in the category ($family) under the key ($key)
|
||||||
|
* for the user_id $uid.
|
||||||
|
*
|
||||||
|
* Note: Please do not store booleans - convert to 0/1 integer values!
|
||||||
|
*
|
||||||
|
* @param string $family The category of the configuration value
|
||||||
|
* @param string $key The configuration key to set
|
||||||
|
* @param mixed $value The value to store
|
||||||
|
*
|
||||||
|
* @return mixed Stored $value or false if the database update failed
|
||||||
|
*/
|
||||||
|
public function set($cat, $k, $value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Deletes the given key from the system configuration.
|
||||||
|
*
|
||||||
|
* Removes the configured value from the stored cache in $a->config
|
||||||
|
* and removes it from the database.
|
||||||
|
*
|
||||||
|
* @param string $cat The category of the configuration value
|
||||||
|
* @param string $k The configuration key to delete
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function delete($cat, $k);
|
||||||
|
}
|
77
src/Core/Config/IPConfigAdapter.php
Normal file
77
src/Core/Config/IPConfigAdapter.php
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Friendica\Core\Config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author benlo
|
||||||
|
*/
|
||||||
|
interface IPConfigAdapter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief Loads all configuration values of a user's config family into a cached storage.
|
||||||
|
*
|
||||||
|
* All configuration values of the given user are stored in global cache
|
||||||
|
* which is available under the global variable $a->config[$uid].
|
||||||
|
*
|
||||||
|
* @param string $uid The user_id
|
||||||
|
* @param string $cat The category of the configuration value
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function load($uid, $cat);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get a particular user's config variable given the category name
|
||||||
|
* ($family) and a key.
|
||||||
|
*
|
||||||
|
* Get a particular user's config value from the given category ($family)
|
||||||
|
* and the $key from a cached storage in $a->config[$uid].
|
||||||
|
*
|
||||||
|
* @param string $uid The user_id
|
||||||
|
* @param string $cat The category of the configuration value
|
||||||
|
* @param string $k The configuration key to query
|
||||||
|
* @param mixed $default_value optional, The value to return if key is not set (default: null)
|
||||||
|
* @param boolean $refresh optional, If true the config is loaded from the db and not from the cache (default: false)
|
||||||
|
*
|
||||||
|
* @return mixed Stored value or null if it does not exist
|
||||||
|
*/
|
||||||
|
public function get($uid, $cat, $k, $default_value = null, $refresh = false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets a configuration value for a user
|
||||||
|
*
|
||||||
|
* Stores a config value ($value) in the category ($family) under the key ($key)
|
||||||
|
* for the user_id $uid.
|
||||||
|
*
|
||||||
|
* @note Please do not store booleans - convert to 0/1 integer values!
|
||||||
|
*
|
||||||
|
* @param string $uid The user_id
|
||||||
|
* @param string $cat The category of the configuration value
|
||||||
|
* @param string $k The configuration key to set
|
||||||
|
* @param string $value The value to store
|
||||||
|
*
|
||||||
|
* @return mixed Stored $value or false
|
||||||
|
*/
|
||||||
|
public function set($uid, $cat, $k, $value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Deletes the given key from the users's configuration.
|
||||||
|
*
|
||||||
|
* Removes the configured value from the stored cache in $a->config[$uid]
|
||||||
|
* and removes it from the database.
|
||||||
|
*
|
||||||
|
* @param string $uid The user_id
|
||||||
|
* @param string $cat The category of the configuration value
|
||||||
|
* @param string $k The configuration key to delete
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function delete($uid, $cat, $k);
|
||||||
|
}
|
126
src/Core/Config/JITConfigAdapter.php
Normal file
126
src/Core/Config/JITConfigAdapter.php
Normal file
|
@ -0,0 +1,126 @@
|
||||||
|
<?php
|
||||||
|
namespace Friendica\Core\Config;
|
||||||
|
|
||||||
|
use dba;
|
||||||
|
use Friendica\BaseObject;
|
||||||
|
use Friendica\Database\DBM;
|
||||||
|
|
||||||
|
require_once 'include/dba.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JustInTime Configuration Adapter
|
||||||
|
*
|
||||||
|
* Default Config Adapter. Provides the best performance for pages loading few configuration variables.
|
||||||
|
*
|
||||||
|
* @author Hypolite Petovan <mrpetovan@gmail.com>
|
||||||
|
*/
|
||||||
|
class JITConfigAdapter extends BaseObject implements IConfigAdapter
|
||||||
|
{
|
||||||
|
private $cache;
|
||||||
|
private $in_db;
|
||||||
|
|
||||||
|
public function load($cat = "config")
|
||||||
|
{
|
||||||
|
// We don't preload "system" anymore.
|
||||||
|
// This reduces the number of database reads a lot.
|
||||||
|
if ($cat === 'system') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$configs = dba::select('config', ['v', 'k'], ['cat' => $cat]);
|
||||||
|
while ($config = dba::fetch($configs)) {
|
||||||
|
$k = $config['k'];
|
||||||
|
|
||||||
|
self::getApp()->setConfigValue($cat, $k, $config['v']);
|
||||||
|
|
||||||
|
if ($cat !== 'config') {
|
||||||
|
$this->cache[$cat][$k] = $config['v'];
|
||||||
|
$this->in_db[$cat][$k] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dba::close($configs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get($cat, $k, $default_value = null, $refresh = false)
|
||||||
|
{
|
||||||
|
$a = self::getApp();
|
||||||
|
|
||||||
|
if (!$refresh) {
|
||||||
|
// Do we have the cached value? Then return it
|
||||||
|
if (isset($this->cache[$cat][$k])) {
|
||||||
|
if ($this->cache[$cat][$k] === '!<unset>!') {
|
||||||
|
return $default_value;
|
||||||
|
} else {
|
||||||
|
return $this->cache[$cat][$k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$config = dba::selectFirst('config', ['v'], ['cat' => $cat, 'k' => $k]);
|
||||||
|
if (DBM::is_result($config)) {
|
||||||
|
// manage array value
|
||||||
|
$value = (preg_match("|^a:[0-9]+:{.*}$|s", $config['v']) ? unserialize($config['v']) : $config['v']);
|
||||||
|
|
||||||
|
// Assign the value from the database to the cache
|
||||||
|
$this->cache[$cat][$k] = $value;
|
||||||
|
$this->in_db[$cat][$k] = true;
|
||||||
|
return $value;
|
||||||
|
} elseif (isset($a->config[$cat][$k])) {
|
||||||
|
// Assign the value (mostly) from the .htconfig.php to the cache
|
||||||
|
$this->cache[$cat][$k] = $a->config[$cat][$k];
|
||||||
|
$this->in_db[$cat][$k] = false;
|
||||||
|
|
||||||
|
return $a->config[$cat][$k];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->cache[$cat][$k] = '!<unset>!';
|
||||||
|
$this->in_db[$cat][$k] = false;
|
||||||
|
|
||||||
|
return $default_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set($cat, $k, $value)
|
||||||
|
{
|
||||||
|
$a = self::getApp();
|
||||||
|
|
||||||
|
// We store our setting values in a string variable.
|
||||||
|
// So we have to do the conversion here so that the compare below works.
|
||||||
|
// The exception are array values.
|
||||||
|
$dbvalue = (!is_array($value) ? (string)$value : $value);
|
||||||
|
|
||||||
|
$stored = $this->get($cat, $k, null, true);
|
||||||
|
|
||||||
|
if (($stored === $dbvalue) && $this->in_db[$cat][$k]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
self::getApp()->setConfigValue($cat, $k, $value);
|
||||||
|
|
||||||
|
// Assign the just added value to the cache
|
||||||
|
$this->cache[$cat][$k] = $dbvalue;
|
||||||
|
|
||||||
|
// manage array value
|
||||||
|
$dbvalue = (is_array($value) ? serialize($value) : $dbvalue);
|
||||||
|
|
||||||
|
$result = dba::update('config', ['v' => $dbvalue], ['cat' => $cat, 'k' => $k], true);
|
||||||
|
|
||||||
|
if ($result) {
|
||||||
|
$this->in_db[$cat][$k] = true;
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete($cat, $k)
|
||||||
|
{
|
||||||
|
if (isset($this->cache[$cat][$k])) {
|
||||||
|
unset($this->cache[$cat][$k]);
|
||||||
|
unset($this->in_db[$cat][$k]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = dba::delete('config', ['cat' => $cat, 'k' => $k]);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
119
src/Core/Config/JITPConfigAdapter.php
Normal file
119
src/Core/Config/JITPConfigAdapter.php
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
<?php
|
||||||
|
namespace Friendica\Core\Config;
|
||||||
|
|
||||||
|
use dba;
|
||||||
|
use Friendica\BaseObject;
|
||||||
|
use Friendica\Database\DBM;
|
||||||
|
|
||||||
|
require_once 'include/dba.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JustInTime User Configuration Adapter
|
||||||
|
*
|
||||||
|
* Default PConfig Adapter. Provides the best performance for pages loading few configuration variables.
|
||||||
|
*
|
||||||
|
* @author Hypolite Petovan <mrpetovan@gmail.com>
|
||||||
|
*/
|
||||||
|
class JITPConfigAdapter extends BaseObject implements IPConfigAdapter
|
||||||
|
{
|
||||||
|
private $in_db;
|
||||||
|
|
||||||
|
public function load($uid, $cat)
|
||||||
|
{
|
||||||
|
$a = self::getApp();
|
||||||
|
|
||||||
|
$pconfigs = dba::select('pconfig', ['v', 'k'], ['cat' => $cat, 'uid' => $uid]);
|
||||||
|
if (DBM::is_result($pconfigs)) {
|
||||||
|
while ($pconfig = dba::fetch($pconfigs)) {
|
||||||
|
$k = $pconfig['k'];
|
||||||
|
|
||||||
|
self::getApp()->setPConfigValue($uid, $cat, $k, $pconfig['v']);
|
||||||
|
|
||||||
|
$this->in_db[$uid][$cat][$k] = true;
|
||||||
|
}
|
||||||
|
} else if ($cat != 'config') {
|
||||||
|
// Negative caching
|
||||||
|
$a->config[$uid][$cat] = "!<unset>!";
|
||||||
|
}
|
||||||
|
dba::close($pconfigs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get($uid, $cat, $k, $default_value = null, $refresh = false)
|
||||||
|
{
|
||||||
|
$a = self::getApp();
|
||||||
|
|
||||||
|
if (!$refresh) {
|
||||||
|
// Looking if the whole family isn't set
|
||||||
|
if (isset($a->config[$uid][$cat])) {
|
||||||
|
if ($a->config[$uid][$cat] === '!<unset>!') {
|
||||||
|
return $default_value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($a->config[$uid][$cat][$k])) {
|
||||||
|
if ($a->config[$uid][$cat][$k] === '!<unset>!') {
|
||||||
|
return $default_value;
|
||||||
|
}
|
||||||
|
return $a->config[$uid][$cat][$k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$pconfig = dba::selectFirst('pconfig', ['v'], ['uid' => $uid, 'cat' => $cat, 'k' => $k]);
|
||||||
|
if (DBM::is_result($pconfig)) {
|
||||||
|
$val = (preg_match("|^a:[0-9]+:{.*}$|s", $pconfig['v']) ? unserialize($pconfig['v']) : $pconfig['v']);
|
||||||
|
|
||||||
|
self::getApp()->setPConfigValue($uid, $cat, $k, $val);
|
||||||
|
|
||||||
|
$this->in_db[$uid][$cat][$k] = true;
|
||||||
|
|
||||||
|
return $val;
|
||||||
|
} else {
|
||||||
|
self::getApp()->setPConfigValue($uid, $cat, $k, '!<unset>!');
|
||||||
|
|
||||||
|
$this->in_db[$uid][$cat][$k] = false;
|
||||||
|
|
||||||
|
return $default_value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set($uid, $cat, $k, $value)
|
||||||
|
{
|
||||||
|
// We store our setting values in a string variable.
|
||||||
|
// So we have to do the conversion here so that the compare below works.
|
||||||
|
// The exception are array values.
|
||||||
|
$dbvalue = (!is_array($value) ? (string)$value : $value);
|
||||||
|
|
||||||
|
$stored = $this->get($uid, $cat, $k, null, true);
|
||||||
|
|
||||||
|
if (($stored === $dbvalue) && $this->in_db[$uid][$cat][$k]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
self::getApp()->setPConfigValue($uid, $cat, $k, $value);
|
||||||
|
|
||||||
|
// manage array value
|
||||||
|
$dbvalue = (is_array($value) ? serialize($value) : $dbvalue);
|
||||||
|
|
||||||
|
$result = dba::update('pconfig', ['v' => $dbvalue], ['uid' => $uid, 'cat' => $cat, 'k' => $k], true);
|
||||||
|
|
||||||
|
if ($result) {
|
||||||
|
$this->in_db[$uid][$cat][$k] = true;
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete($uid, $cat, $k)
|
||||||
|
{
|
||||||
|
self::getApp()->deletePConfigValue($uid, $cat, $k);
|
||||||
|
|
||||||
|
if (!empty($this->in_db[$uid][$cat][$k])) {
|
||||||
|
unset($this->in_db[$uid][$cat][$k]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = dba::delete('pconfig', ['uid' => $uid, 'cat' => $cat, 'k' => $k]);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
90
src/Core/Config/PreloadConfigAdapter.php
Normal file
90
src/Core/Config/PreloadConfigAdapter.php
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Friendica\Core\Config;
|
||||||
|
|
||||||
|
use dba;
|
||||||
|
use Exception;
|
||||||
|
use Friendica\App;
|
||||||
|
use Friendica\BaseObject;
|
||||||
|
use Friendica\Database\DBM;
|
||||||
|
|
||||||
|
require_once 'include/dba.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preload Configuration Adapter
|
||||||
|
*
|
||||||
|
* Minimizes the number of database queries to retrieve configuration values at the cost of memory.
|
||||||
|
*
|
||||||
|
* @author Hypolite Petovan <mrpetovan@gmail.com>
|
||||||
|
*/
|
||||||
|
class PreloadConfigAdapter extends BaseObject implements IConfigAdapter
|
||||||
|
{
|
||||||
|
private $config_loaded = false;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->load();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function load($family = 'config')
|
||||||
|
{
|
||||||
|
if ($this->config_loaded) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$configs = dba::select('config', ['cat', 'v', 'k']);
|
||||||
|
while ($config = dba::fetch($configs)) {
|
||||||
|
self::getApp()->setConfigValue($config['cat'], $config['k'], $config['v']);
|
||||||
|
}
|
||||||
|
dba::close($configs);
|
||||||
|
|
||||||
|
$this->config_loaded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get($cat, $k, $default_value = null, $refresh = false)
|
||||||
|
{
|
||||||
|
if ($refresh) {
|
||||||
|
$config = dba::selectFirst('config', ['v'], ['cat' => $cat, 'k' => $k]);
|
||||||
|
if (DBM::is_result($config)) {
|
||||||
|
self::getApp()->setConfigValue($cat, $k, $config['v']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$return = self::getApp()->getConfigValue($cat, $k, $default_value);
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set($cat, $k, $value)
|
||||||
|
{
|
||||||
|
// We store our setting values as strings.
|
||||||
|
// So we have to do the conversion here so that the compare below works.
|
||||||
|
// The exception are array values.
|
||||||
|
$compare_value = !is_array($value) ? (string)$value : $value;
|
||||||
|
|
||||||
|
if (self::getApp()->getConfigValue($cat, $k) === $compare_value) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
self::getApp()->setConfigValue($cat, $k, $value);
|
||||||
|
|
||||||
|
// manage array value
|
||||||
|
$dbvalue = is_array($value) ? serialize($value) : $value;
|
||||||
|
|
||||||
|
$result = dba::update('config', ['v' => $dbvalue], ['cat' => $cat, 'k' => $k], true);
|
||||||
|
if (!$result) {
|
||||||
|
throw new Exception('Unable to store config value in [' . $cat . '][' . $k . ']');
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete($cat, $k)
|
||||||
|
{
|
||||||
|
self::getApp()->deleteConfigValue($cat, $k);
|
||||||
|
|
||||||
|
$result = dba::delete('config', ['cat' => $cat, 'k' => $k]);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
92
src/Core/Config/PreloadPConfigAdapter.php
Normal file
92
src/Core/Config/PreloadPConfigAdapter.php
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Friendica\Core\Config;
|
||||||
|
|
||||||
|
use dba;
|
||||||
|
use Exception;
|
||||||
|
use Friendica\App;
|
||||||
|
use Friendica\BaseObject;
|
||||||
|
use Friendica\Database\DBM;
|
||||||
|
|
||||||
|
require_once 'include/dba.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preload User Configuration Adapter
|
||||||
|
*
|
||||||
|
* Minimizes the number of database queries to retrieve configuration values at the cost of memory.
|
||||||
|
*
|
||||||
|
* @author Hypolite Petovan <mrpetovan@gmail.com>
|
||||||
|
*/
|
||||||
|
class PreloadPConfigAdapter extends BaseObject implements IPConfigAdapter
|
||||||
|
{
|
||||||
|
private $config_loaded = false;
|
||||||
|
|
||||||
|
public function __construct($uid)
|
||||||
|
{
|
||||||
|
$this->load($uid, 'config');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function load($uid, $family)
|
||||||
|
{
|
||||||
|
if ($this->config_loaded) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pconfigs = dba::select('pconfig', ['cat', 'v', 'k'], ['uid' => $uid]);
|
||||||
|
while ($pconfig = dba::fetch($pconfigs)) {
|
||||||
|
self::getApp()->setPConfigValue($uid, $pconfig['cat'], $pconfig['k'], $pconfig['v']);
|
||||||
|
}
|
||||||
|
dba::close($pconfigs);
|
||||||
|
|
||||||
|
$this->config_loaded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get($uid, $cat, $k, $default_value = null, $refresh = false)
|
||||||
|
{
|
||||||
|
if ($refresh) {
|
||||||
|
$config = dba::selectFirst('pconfig', ['v'], ['uid' => $uid, 'cat' => $cat, 'k' => $k]);
|
||||||
|
if (DBM::is_result($config)) {
|
||||||
|
self::getApp()->setPConfigValue($uid, $cat, $k, $config['v']);
|
||||||
|
} else {
|
||||||
|
self::getApp()->deletePConfigValue($uid, $cat, $k);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$return = self::getApp()->getPConfigValue($uid, $cat, $k, $default_value);
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set($uid, $cat, $k, $value)
|
||||||
|
{
|
||||||
|
// We store our setting values as strings.
|
||||||
|
// So we have to do the conversion here so that the compare below works.
|
||||||
|
// The exception are array values.
|
||||||
|
$compare_value = !is_array($value) ? (string)$value : $value;
|
||||||
|
|
||||||
|
if (self::getApp()->getPConfigValue($uid, $cat, $k) === $compare_value) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
self::getApp()->setPConfigValue($uid, $cat, $k, $value);
|
||||||
|
|
||||||
|
// manage array value
|
||||||
|
$dbvalue = is_array($value) ? serialize($value) : $value;
|
||||||
|
|
||||||
|
$result = dba::update('pconfig', ['v' => $dbvalue], ['uid' => $uid, 'cat' => $cat, 'k' => $k], true);
|
||||||
|
if (!$result) {
|
||||||
|
throw new Exception('Unable to store config value in [' . $uid . '][' . $cat . '][' . $k . ']');
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete($uid, $cat, $k)
|
||||||
|
{
|
||||||
|
self::getApp()->deletePConfigValue($uid, $cat, $k);
|
||||||
|
|
||||||
|
$result = dba::delete('pconfig', ['uid' => $uid, 'cat' => $cat, 'k' => $k]);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
125
src/Core/Console.php
Normal file
125
src/Core/Console.php
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Friendica\Core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description of Console
|
||||||
|
*
|
||||||
|
* @author Hypolite Petovan <mrpetovan@gmail.com>
|
||||||
|
*/
|
||||||
|
class Console extends \Asika\SimpleConsole\Console
|
||||||
|
{
|
||||||
|
// Disables the default help handling
|
||||||
|
protected $helpOptions = [];
|
||||||
|
protected $customHelpOptions = ['h', 'help', '?'];
|
||||||
|
|
||||||
|
protected $subConsoles = [
|
||||||
|
'config' => __NAMESPACE__ . '\Console\Config',
|
||||||
|
'createdoxygen' => __NAMESPACE__ . '\Console\CreateDoxygen',
|
||||||
|
'docbloxerrorchecker' => __NAMESPACE__ . '\Console\DocBloxErrorChecker',
|
||||||
|
'dbstructure' => __NAMESPACE__ . '\Console\DatabaseStructure',
|
||||||
|
'extract' => __NAMESPACE__ . '\Console\Extract',
|
||||||
|
'globalcommunityblock' => __NAMESPACE__ . '\Console\GlobalCommunityBlock',
|
||||||
|
'globalcommunitysilence' => __NAMESPACE__ . '\Console\GlobalCommunitySilence',
|
||||||
|
'maintenance' => __NAMESPACE__ . '\Console\Maintenance',
|
||||||
|
'newpassword' => __NAMESPACE__ . '\Console\NewPassword',
|
||||||
|
'php2po' => __NAMESPACE__ . '\Console\PhpToPo',
|
||||||
|
'po2php' => __NAMESPACE__ . '\Console\PoToPhp',
|
||||||
|
'typo' => __NAMESPACE__ . '\Console\Typo',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected function getHelp()
|
||||||
|
{
|
||||||
|
$help = <<<HELP
|
||||||
|
Usage: bin/console [--version] [-h|--help|-?] <command> [<args>] [-v]
|
||||||
|
|
||||||
|
Commands:
|
||||||
|
config Edit site config
|
||||||
|
createdoxygen Generate Doxygen headers
|
||||||
|
dbstructure Do database updates
|
||||||
|
docbloxerrorchecker Check the file tree for DocBlox errors
|
||||||
|
extract Generate translation string file for the Friendica project (deprecated)
|
||||||
|
globalcommunityblock Block remote profile from interacting with this node
|
||||||
|
globalcommunitysilence Silence remote profile from global community page
|
||||||
|
help Show help about a command, e.g (bin/console help config)
|
||||||
|
maintenance Set maintenance mode for this node
|
||||||
|
newpassword Set a new password for a given user
|
||||||
|
php2po Generate a messages.po file from a strings.php file
|
||||||
|
po2php Generate a strings.php file from a messages.po file
|
||||||
|
typo Checks for parse errors in Friendica files
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h|--help|-? Show help information
|
||||||
|
-v Show more debug information.
|
||||||
|
HELP;
|
||||||
|
return $help;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function doExecute()
|
||||||
|
{
|
||||||
|
if ($this->getOption('v')) {
|
||||||
|
$this->out('Executable: ' . $this->executable);
|
||||||
|
$this->out('Arguments: ' . var_export($this->args, true));
|
||||||
|
$this->out('Options: ' . var_export($this->options, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
$showHelp = false;
|
||||||
|
$subHelp = false;
|
||||||
|
$command = null;
|
||||||
|
|
||||||
|
if ($this->getOption('version')) {
|
||||||
|
$this->out('Friendica Console version ' . FRIENDICA_VERSION);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
} elseif ((count($this->options) === 0 || $this->getOption($this->customHelpOptions) === true || $this->getOption($this->customHelpOptions) === 1) && count($this->args) === 0
|
||||||
|
) {
|
||||||
|
$showHelp = true;
|
||||||
|
} elseif (count($this->args) >= 2 && $this->getArgument(0) == 'help') {
|
||||||
|
$command = $this->getArgument(1);
|
||||||
|
$subHelp = true;
|
||||||
|
array_shift($this->args);
|
||||||
|
array_shift($this->args);
|
||||||
|
} elseif (count($this->args) >= 1) {
|
||||||
|
$command = $this->getArgument(0);
|
||||||
|
array_shift($this->args);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_null($command)) {
|
||||||
|
$this->out($this->getHelp());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$console = $this->getSubConsole($command);
|
||||||
|
|
||||||
|
if ($subHelp) {
|
||||||
|
$console->setOption($this->customHelpOptions, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $console->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getSubConsole($command)
|
||||||
|
{
|
||||||
|
if ($this->getOption('v')) {
|
||||||
|
$this->out('Command: ' . $command);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($this->subConsoles[$command])) {
|
||||||
|
throw new \Asika\SimpleConsole\CommandArgsException('Command ' . $command . ' doesn\'t exist');
|
||||||
|
}
|
||||||
|
|
||||||
|
$subargs = $this->args;
|
||||||
|
array_unshift($subargs, $this->executable);
|
||||||
|
|
||||||
|
$className = $this->subConsoles[$command];
|
||||||
|
|
||||||
|
$subconsole = new $className($subargs);
|
||||||
|
|
||||||
|
foreach ($this->options as $name => $value) {
|
||||||
|
$subconsole->setOption($name, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $subconsole;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
137
src/Core/Console/Config.php
Normal file
137
src/Core/Console/Config.php
Normal file
|
@ -0,0 +1,137 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Friendica\Core\Console;
|
||||||
|
|
||||||
|
use Asika\SimpleConsole\CommandArgsException;
|
||||||
|
use dba;
|
||||||
|
use Friendica\Core;
|
||||||
|
|
||||||
|
require_once 'include/dba.php';
|
||||||
|
require_once 'include/text.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief tool to access the system config from the CLI
|
||||||
|
*
|
||||||
|
* With this script you can access the system configuration of your node from
|
||||||
|
* the CLI. You can do both, reading current values stored in the database and
|
||||||
|
* set new values to config variables.
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
* If you specify no parameters at the CLI, the script will list all config
|
||||||
|
* variables defined.
|
||||||
|
*
|
||||||
|
* If you specify one parameter, the script will list all config variables
|
||||||
|
* defined in this section of the configuration (e.g. "system").
|
||||||
|
*
|
||||||
|
* If you specify two parameters, the script will show you the current value
|
||||||
|
* of the named configuration setting. (e.g. "system loglevel")
|
||||||
|
*
|
||||||
|
* If you specify three parameters, the named configuration setting will be
|
||||||
|
* set to the value of the last parameter. (e.g. "system loglevel 0" will
|
||||||
|
* disable logging)
|
||||||
|
*
|
||||||
|
* @author Tobias Diekershoff
|
||||||
|
* @author Hypolite Petovan <mrpetovan@gmail.com>
|
||||||
|
*/
|
||||||
|
class Config extends \Asika\SimpleConsole\Console
|
||||||
|
{
|
||||||
|
protected $helpOptions = ['h', 'help', '?'];
|
||||||
|
|
||||||
|
protected function getHelp()
|
||||||
|
{
|
||||||
|
$help = <<<HELP
|
||||||
|
console config - Manage site configuration
|
||||||
|
Synopsis
|
||||||
|
bin/console config [-h|--help|-?] [-v]
|
||||||
|
bin/console config <category> [-h|--help|-?] [-v]
|
||||||
|
bin/console config <category> <key> [-h|--help|-?] [-v]
|
||||||
|
bin/console config <category> <key> <value> [-h|--help|-?] [-v]
|
||||||
|
|
||||||
|
Description
|
||||||
|
bin/console config
|
||||||
|
Lists all config values
|
||||||
|
|
||||||
|
bin/console config <category>
|
||||||
|
Lists all config values in the provided category
|
||||||
|
|
||||||
|
bin/console config <category> <key>
|
||||||
|
Shows the value of the provided key in the category
|
||||||
|
|
||||||
|
bin/console config <category> <key> <value>
|
||||||
|
Sets the value of the provided key in the category
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
Setting config entries which are manually set in .htconfig.php may result in
|
||||||
|
conflict between database settings and the manual startup settings.
|
||||||
|
|
||||||
|
Options
|
||||||
|
-h|--help|-? Show help information
|
||||||
|
-v Show more debug information.
|
||||||
|
HELP;
|
||||||
|
return $help;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function doExecute()
|
||||||
|
{
|
||||||
|
$a = get_app();
|
||||||
|
|
||||||
|
if ($this->getOption('v')) {
|
||||||
|
$this->out('Executable: ' . $this->executable);
|
||||||
|
$this->out('Class: ' . __CLASS__);
|
||||||
|
$this->out('Arguments: ' . var_export($this->args, true));
|
||||||
|
$this->out('Options: ' . var_export($this->options, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($this->args) > 3) {
|
||||||
|
throw new CommandArgsException('Too many arguments');
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once '.htconfig.php';
|
||||||
|
$result = dba::connect($db_host, $db_user, $db_pass, $db_data);
|
||||||
|
unset($db_host, $db_user, $db_pass, $db_data);
|
||||||
|
|
||||||
|
if (!$result) {
|
||||||
|
throw new \RuntimeException('Unable to connect to database');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($this->args) == 3) {
|
||||||
|
Core\Config::set($this->getArgument(0), $this->getArgument(1), $this->getArgument(2));
|
||||||
|
$this->out("config[{$this->getArgument(0)}][{$this->getArgument(1)}] = " . Core\Config::get($this->getArgument(0),
|
||||||
|
$this->getArgument(1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($this->args) == 2) {
|
||||||
|
$this->out("config[{$this->getArgument(0)}][{$this->getArgument(1)}] = " . Core\Config::get($this->getArgument(0),
|
||||||
|
$this->getArgument(1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($this->args) == 1) {
|
||||||
|
Core\Config::load($this->getArgument(0));
|
||||||
|
|
||||||
|
$a = get_app();
|
||||||
|
if (!is_null($a->config[$this->getArgument(0)])) {
|
||||||
|
foreach ($a->config[$this->getArgument(0)] as $k => $x) {
|
||||||
|
$this->out("config[{$this->getArgument(0)}][{$k}] = " . $x);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->out('Config section ' . $this->getArgument(0) . ' returned nothing');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($this->args) == 0) {
|
||||||
|
$configs = dba::select('config');
|
||||||
|
foreach ($configs as $config) {
|
||||||
|
$this->out("config[{$config['cat']}][{$config['k']}] = " . $config['v']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue