Merge branch 'develop' of github.com:friendica/friendica into rewrites/coding-convention-split2-4-2
Fixed some stuff: - converted some files from DOS to Uni* (CRLF -> LF) - removed trailing white-spaces Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
commit
7a9456d5ac
|
@ -226,10 +226,10 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "pear-pear.php.net/PEAR",
|
"name": "pear-pear.php.net/PEAR",
|
||||||
"version": "1.10.3",
|
"version": "1.10.4",
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"url": "https://pear.php.net/get/PEAR-1.10.3.tgz",
|
"url": "https://pear.php.net/get/PEAR-1.10.4.tgz",
|
||||||
"reference": null,
|
"reference": null,
|
||||||
"shasum": null
|
"shasum": null
|
||||||
},
|
},
|
||||||
|
@ -247,7 +247,7 @@
|
||||||
"pear-pear.php.net/pear_frontend_web": "<=0.4.0.0"
|
"pear-pear.php.net/pear_frontend_web": "<=0.4.0.0"
|
||||||
},
|
},
|
||||||
"replace": {
|
"replace": {
|
||||||
"pear-pear/pear": "== 1.10.3.0"
|
"pear-pear/pear": "== 1.10.4.0"
|
||||||
},
|
},
|
||||||
"type": "pear-library",
|
"type": "pear-library",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
|
47
database.sql
47
database.sql
|
@ -1,6 +1,6 @@
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
-- Friendica 3.5.2-dev (Asparagus)
|
-- Friendica 3.5.2-dev (Asparagus)
|
||||||
-- DB_UPDATE_VERSION 1219
|
-- DB_UPDATE_VERSION 1221
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -174,13 +174,13 @@ CREATE TABLE IF NOT EXISTS `contact` (
|
||||||
`fetch_further_information` tinyint(1) NOT NULL DEFAULT 0,
|
`fetch_further_information` tinyint(1) NOT NULL DEFAULT 0,
|
||||||
`ffi_keyword_blacklist` text,
|
`ffi_keyword_blacklist` text,
|
||||||
PRIMARY KEY(`id`),
|
PRIMARY KEY(`id`),
|
||||||
INDEX `uid_name` (`uid`,`name`),
|
INDEX `uid_name` (`uid`,`name`(190)),
|
||||||
INDEX `self_uid` (`self`,`uid`),
|
INDEX `self_uid` (`self`,`uid`),
|
||||||
INDEX `alias_uid` (`alias`(32),`uid`),
|
INDEX `alias_uid` (`alias`(32),`uid`),
|
||||||
INDEX `pending_uid` (`pending`,`uid`),
|
INDEX `pending_uid` (`pending`,`uid`),
|
||||||
INDEX `blocked_uid` (`blocked`,`uid`),
|
INDEX `blocked_uid` (`blocked`,`uid`),
|
||||||
INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
|
INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`(4),`poll`(64),`archive`),
|
||||||
INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
|
INDEX `uid_network_batch` (`uid`,`network`(4),`batch`(64)),
|
||||||
INDEX `addr_uid` (`addr`(32),`uid`),
|
INDEX `addr_uid` (`addr`(32),`uid`),
|
||||||
INDEX `nurl_uid` (`nurl`(32),`uid`),
|
INDEX `nurl_uid` (`nurl`(32),`uid`),
|
||||||
INDEX `nick_uid` (`nick`(32),`uid`),
|
INDEX `nick_uid` (`nick`(32),`uid`),
|
||||||
|
@ -204,6 +204,21 @@ CREATE TABLE IF NOT EXISTS `conv` (
|
||||||
INDEX `uid` (`uid`)
|
INDEX `uid` (`uid`)
|
||||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- TABLE conversation
|
||||||
|
--
|
||||||
|
CREATE TABLE IF NOT EXISTS `conversation` (
|
||||||
|
`item-uri` varbinary(255) NOT NULL,
|
||||||
|
`reply-to-uri` varbinary(255) NOT NULL DEFAULT '',
|
||||||
|
`conversation-uri` varbinary(255) NOT NULL DEFAULT '',
|
||||||
|
`conversation-href` varbinary(255) NOT NULL DEFAULT '',
|
||||||
|
`protocol` tinyint(1) unsigned NOT NULL DEFAULT 0,
|
||||||
|
`source` mediumtext,
|
||||||
|
`received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
|
||||||
|
PRIMARY KEY(`item-uri`),
|
||||||
|
INDEX `conversation-uri` (`conversation-uri`)
|
||||||
|
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- TABLE event
|
-- TABLE event
|
||||||
--
|
--
|
||||||
|
@ -344,7 +359,7 @@ CREATE TABLE IF NOT EXISTS `gcontact` (
|
||||||
INDEX `name` (`name`(64)),
|
INDEX `name` (`name`(64)),
|
||||||
INDEX `nick` (`nick`(32)),
|
INDEX `nick` (`nick`(32)),
|
||||||
INDEX `addr` (`addr`(64)),
|
INDEX `addr` (`addr`(64)),
|
||||||
INDEX `hide_network_updated` (`hide`,`network`,`updated`),
|
INDEX `hide_network_updated` (`hide`,`network`(4),`updated`),
|
||||||
INDEX `updated` (`updated`)
|
INDEX `updated` (`updated`)
|
||||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||||
|
|
||||||
|
@ -523,22 +538,22 @@ CREATE TABLE IF NOT EXISTS `item` (
|
||||||
INDEX `uid_contactid_id` (`uid`,`contact-id`,`id`),
|
INDEX `uid_contactid_id` (`uid`,`contact-id`,`id`),
|
||||||
INDEX `uid_created` (`uid`,`created`),
|
INDEX `uid_created` (`uid`,`created`),
|
||||||
INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
|
INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
|
||||||
INDEX `uid_network_received` (`uid`,`network`,`received`),
|
INDEX `uid_network_received` (`uid`,`network`(4),`received`),
|
||||||
INDEX `uid_network_commented` (`uid`,`network`,`commented`),
|
INDEX `uid_network_commented` (`uid`,`network`(4),`commented`),
|
||||||
INDEX `uid_thrparent` (`uid`,`thr-parent`),
|
INDEX `uid_thrparent` (`uid`,`thr-parent`(190)),
|
||||||
INDEX `uid_parenturi` (`uid`,`parent-uri`),
|
INDEX `uid_parenturi` (`uid`,`parent-uri`(190)),
|
||||||
INDEX `uid_contactid_created` (`uid`,`contact-id`,`created`),
|
INDEX `uid_contactid_created` (`uid`,`contact-id`,`created`),
|
||||||
INDEX `authorid_created` (`author-id`,`created`),
|
INDEX `authorid_created` (`author-id`,`created`),
|
||||||
INDEX `uid_uri` (`uid`,`uri`),
|
INDEX `uid_uri` (`uid`,`uri`(190)),
|
||||||
INDEX `resource-id` (`resource-id`),
|
INDEX `resource-id` (`resource-id`),
|
||||||
INDEX `contactid_allowcid_allowpid_denycid_denygid` (`contact-id`,`allow_cid`(10),`allow_gid`(10),`deny_cid`(10),`deny_gid`(10)),
|
INDEX `contactid_allowcid_allowpid_denycid_denygid` (`contact-id`,`allow_cid`(10),`allow_gid`(10),`deny_cid`(10),`deny_gid`(10)),
|
||||||
INDEX `uid_type_changed` (`uid`,`type`,`changed`),
|
INDEX `uid_type_changed` (`uid`,`type`(190),`changed`),
|
||||||
INDEX `contactid_verb` (`contact-id`,`verb`),
|
INDEX `contactid_verb` (`contact-id`,`verb`(190)),
|
||||||
INDEX `deleted_changed` (`deleted`,`changed`),
|
INDEX `deleted_changed` (`deleted`,`changed`),
|
||||||
INDEX `uid_wall_changed` (`uid`,`wall`,`changed`),
|
INDEX `uid_wall_changed` (`uid`,`wall`,`changed`),
|
||||||
INDEX `uid_eventid` (`uid`,`event-id`),
|
INDEX `uid_eventid` (`uid`,`event-id`),
|
||||||
INDEX `uid_authorlink` (`uid`,`author-link`),
|
INDEX `uid_authorlink` (`uid`,`author-link`(190)),
|
||||||
INDEX `uid_ownerlink` (`uid`,`owner-link`)
|
INDEX `uid_ownerlink` (`uid`,`owner-link`(190))
|
||||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||||
|
|
||||||
--
|
--
|
||||||
|
@ -652,7 +667,7 @@ CREATE TABLE IF NOT EXISTS `notify` (
|
||||||
INDEX `hash_uid` (`hash`,`uid`),
|
INDEX `hash_uid` (`hash`,`uid`),
|
||||||
INDEX `seen_uid_date` (`seen`,`uid`,`date`),
|
INDEX `seen_uid_date` (`seen`,`uid`,`date`),
|
||||||
INDEX `uid_date` (`uid`,`date`),
|
INDEX `uid_date` (`uid`,`date`),
|
||||||
INDEX `uid_type_link` (`uid`,`type`,`link`)
|
INDEX `uid_type_link` (`uid`,`type`,`link`(190))
|
||||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||||
|
|
||||||
--
|
--
|
||||||
|
@ -963,7 +978,7 @@ CREATE TABLE IF NOT EXISTS `term` (
|
||||||
`aid` int(10) unsigned NOT NULL DEFAULT 0,
|
`aid` int(10) unsigned NOT NULL DEFAULT 0,
|
||||||
`uid` int(10) unsigned NOT NULL DEFAULT 0,
|
`uid` int(10) unsigned NOT NULL DEFAULT 0,
|
||||||
PRIMARY KEY(`tid`),
|
PRIMARY KEY(`tid`),
|
||||||
INDEX `oid_otype_type_term` (`oid`,`otype`,`type`,`term`),
|
INDEX `oid_otype_type_term` (`oid`,`otype`,`type`,`term`(32)),
|
||||||
INDEX `uid_otype_type_term_global_created` (`uid`,`otype`,`type`,`term`(32),`global`,`created`),
|
INDEX `uid_otype_type_term_global_created` (`uid`,`otype`,`type`,`term`(32),`global`,`created`),
|
||||||
INDEX `uid_otype_type_url` (`uid`,`otype`,`type`,`url`(64)),
|
INDEX `uid_otype_type_url` (`uid`,`otype`,`type`,`url`(64)),
|
||||||
INDEX `guid` (`guid`(64))
|
INDEX `guid` (`guid`(64))
|
||||||
|
|
|
@ -113,3 +113,8 @@ 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] util/composer.phar [mode]
|
||||||
````
|
````
|
||||||
|
|
||||||
|
## Related
|
||||||
|
|
||||||
|
* [Class autoloading](help/autoloader)
|
||||||
|
* [How To Move Classes to `src`](help/Developer-How-To-Move-Classes-to-src)
|
||||||
|
|
|
@ -0,0 +1,108 @@
|
||||||
|
How To Move Classes to `src`
|
||||||
|
==============
|
||||||
|
|
||||||
|
* [Home](help)
|
||||||
|
* [Developer Intro](help/Developers-Intro)
|
||||||
|
|
||||||
|
Friendica uses [Composer](help/Composer) to manage autoloading.
|
||||||
|
This means that all the PHP class files moved to the `src` folder will be [automatically included](help/autoloader) when the class it defines is first used in the flow.
|
||||||
|
This is an improvement over the current `require` usage since files will be included on an actual usage basis instead of the presence of a `require` call.
|
||||||
|
|
||||||
|
However, there are a significant number of items to check when moving a class file from the `include` folder to the `src` folder, and this page is there to list them.
|
||||||
|
|
||||||
|
## Decide the namespace
|
||||||
|
|
||||||
|
This isn't the most technical decision of them all, but it has long lasting consequences as it will be the name that will be used to refer to this class from now on.
|
||||||
|
There is [a shared Ethercalc sheet](https://ethercalc.org/friendica_classes) to suggest namespace/class names that lists all the already moved class files for inspiration.
|
||||||
|
|
||||||
|
A few pointers though:
|
||||||
|
* `Friendica` is the base namespace for all classes in the `src` folder
|
||||||
|
* Namespaces match the directory structure, with `Friendica` namespace being the base `src` directory. The `Config` class set in the `Friendica\Core` namespace is expected to be found at `src/Core/Config.php`.
|
||||||
|
* Namespaces can help group classes with a similar purpose or relevant to a particular feature
|
||||||
|
|
||||||
|
When you're done deciding the namespace, it's time to use it.
|
||||||
|
Let's say we choose `Friendica\Core` for the `Config` class.
|
||||||
|
|
||||||
|
## Use the namespace
|
||||||
|
|
||||||
|
To declare the namespace, the file `src/Core/Config.php` must start with the following statement:
|
||||||
|
|
||||||
|
````php
|
||||||
|
namespace Friendica\Core;
|
||||||
|
````
|
||||||
|
|
||||||
|
From now on, the `Config` class can be referred to as `Friendica\Core\Config`, however it isn't very practical, especially when the class was previously used as `Config`.
|
||||||
|
Thankfully, PHP provides namespace shortcuts through `use`.
|
||||||
|
|
||||||
|
This language construct just provides a different naming scheme for a namespace or a class, but doesn't trigger the autoload mechanism on its own.
|
||||||
|
Here are the different ways you can use `use`:
|
||||||
|
|
||||||
|
````php
|
||||||
|
// No use
|
||||||
|
$config = new Friendica\Core\Config();
|
||||||
|
````
|
||||||
|
````php
|
||||||
|
// Namespace shortcut
|
||||||
|
use Friendica\Core;
|
||||||
|
|
||||||
|
$config = new Core\Config();
|
||||||
|
````
|
||||||
|
````php
|
||||||
|
// Class name shortcut
|
||||||
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
|
$config = new Config();
|
||||||
|
````
|
||||||
|
````php
|
||||||
|
// Aliasing
|
||||||
|
use Friendica\Core\Config as Cfg;
|
||||||
|
|
||||||
|
$config = new Cfg();
|
||||||
|
````
|
||||||
|
|
||||||
|
Whatever the style chosen, a repository-wide search has to be done to find all the class name usage and either use the fully-qualified class name (including the namespace) or add a `use` statement at the start of each relevant file.
|
||||||
|
|
||||||
|
## Escape non-namespace classes
|
||||||
|
|
||||||
|
The class file you just moved is now in the `Friendica` namespace, but it probably isn't the case for all the classes referenced in this file.
|
||||||
|
Since we added a `namespace Friendica\Core;` to the file, all the class names still declared in `include` will be implicitly understood as `Friendica\Core\ClassName`, which is rarely what we expect.
|
||||||
|
|
||||||
|
To avoid `Class Friendica\Core\ClassName not found` errors, all the `include`-declared class names have to be prepended with a `\`, it tells the autoloader not to look for the class in the namespace but in the global space where non-namespaced classes are set.
|
||||||
|
If there are only a handful of references to a single non-namespaced class, just prepending `\` is enough. However, if there are many instance, we can use `use` again.
|
||||||
|
|
||||||
|
````php
|
||||||
|
namespace Friendica\Core;
|
||||||
|
...
|
||||||
|
if (\dbm::is_result($r)) {
|
||||||
|
...
|
||||||
|
}
|
||||||
|
````
|
||||||
|
````php
|
||||||
|
namespace Friendica\Core;
|
||||||
|
|
||||||
|
use \dbm;
|
||||||
|
|
||||||
|
if (dbm::is_result($r)) {
|
||||||
|
...
|
||||||
|
}
|
||||||
|
````
|
||||||
|
|
||||||
|
## Remove any useless `require`
|
||||||
|
|
||||||
|
Now that you successfully moved your class to the autoloaded `src` folder, there's no need to include this file anywhere in the app ever again.
|
||||||
|
Please remove all the `require_once` mentions of the former file, as they will provoke a Fatal Error even if the class isn't used.
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
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.
|
||||||
|
|
||||||
|
Check the class file for any magic constant `__FILE__` or `__DIR__`, as their value changed since you moved the class in the file tree.
|
||||||
|
Most of the time it's used for debugging purposes but there can be instances where it's used to create cache folders for example.
|
||||||
|
|
||||||
|
## Related
|
||||||
|
|
||||||
|
* [Class autoloading](help/autoloader)
|
||||||
|
* [Using Composer](help/Composer)
|
|
@ -52,7 +52,9 @@ Friendica uses [Composer](https://getcomposer.org) to manage dependencies librar
|
||||||
|
|
||||||
It's a command-line tool that downloads required libraries into the `vendor` folder and makes any namespaced class in `src` available through the whole application through `boot.php`.
|
It's a command-line tool that downloads required libraries into the `vendor` folder and makes any namespaced class in `src` available through the whole application through `boot.php`.
|
||||||
|
|
||||||
|
* [Class autoloading](help/autoloader)
|
||||||
* [Using Composer](help/Composer)
|
* [Using Composer](help/Composer)
|
||||||
|
* [How To Move Classes to `src`](help/Developer-How-To-Move-Classes-to-src)
|
||||||
|
|
||||||
###Coding standards
|
###Coding standards
|
||||||
|
|
||||||
|
|
34
doc/Home.md
34
doc/Home.md
|
@ -36,21 +36,25 @@ Friendica Documentation and Resources
|
||||||
|
|
||||||
**Developer Manual**
|
**Developer Manual**
|
||||||
|
|
||||||
* [Where to get started?](help/Developers-Intro)
|
* [Get started](help/Developers-Intro)
|
||||||
* [Help on Github](help/Github)
|
* Set up development environment
|
||||||
* [Help on Vagrant](help/Vagrant)
|
* [Help on Github](help/Github)
|
||||||
* [How to translate Friendica](help/translations)
|
* [Help on Vagrant](help/Vagrant)
|
||||||
* [Bugs and Issues](help/Bugs-and-Issues)
|
* [Bugs and Issues](help/Bugs-and-Issues)
|
||||||
* [Plugin Development](help/Plugins)
|
* Code structure
|
||||||
* [Theme Development](help/themes)
|
* [Plugin Development](help/Plugins)
|
||||||
* [Smarty 3 Templates](help/smarty3-templates)
|
* [Theme Development](help/themes)
|
||||||
* [Protocol Documentation](help/Protocol)
|
* [Smarty 3 Templates](help/smarty3-templates)
|
||||||
* [Database schema documantation](help/database)
|
* How To
|
||||||
* [Class Autoloading](help/autoloader)
|
* [Translate Friendica](help/translations)
|
||||||
* [Using Composer](help/Composer)
|
* [Use Composer](help/Composer)
|
||||||
* [Code - Reference(Doxygen generated - sets cookies)](doc/html/)
|
* [Move classes to `src`](help/Developer-How-To-Move-Classes-to-src)
|
||||||
* [Twitter/GNU Social API Functions](help/api)
|
* Reference
|
||||||
|
* [Twitter/GNU Social API Functions](help/api)
|
||||||
|
* [Code (Doxygen generated - sets cookies)](doc/html/)
|
||||||
|
* [Protocol Documentation](help/Protocol)
|
||||||
|
* [Database schema documantation](help/database)
|
||||||
|
* [Class Autoloading](help/autoloader)
|
||||||
|
|
||||||
**External Resources**
|
**External Resources**
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ Requirements
|
||||||
* Apache with mod-rewrite enabled and "Options All" so you can use a local .htaccess file
|
* Apache with mod-rewrite enabled and "Options All" so you can use a local .htaccess file
|
||||||
* PHP 5.4+.
|
* PHP 5.4+.
|
||||||
* PHP *command line* access with register_argc_argv set to true in the php.ini file
|
* PHP *command line* access with register_argc_argv set to true in the php.ini file
|
||||||
* curl, gd, mysql, hash and openssl extensions
|
* Curl, GD, PDO, MySQLi, hash and OpenSSL extensions
|
||||||
* some form of email server or email gateway such that PHP mail() works
|
* some form of email server or email gateway such that PHP mail() works
|
||||||
* Mysql 5.5.3+ or an equivalant alternative for MySQL (MariaDB, Percona Server etc.)
|
* Mysql 5.5.3+ or an equivalant alternative for MySQL (MariaDB, Percona Server etc.)
|
||||||
* the ability to schedule jobs with cron (Linux/Mac) or Scheduled Tasks (Windows) (Note: other options are presented in Section 7 of this document.)
|
* the ability to schedule jobs with cron (Linux/Mac) or Scheduled Tasks (Windows) (Note: other options are presented in Section 7 of this document.)
|
||||||
|
|
|
@ -242,6 +242,12 @@ The receiving end might be off-line, there might be a high system load and so on
|
||||||
Don't panic!
|
Don't panic!
|
||||||
Friendica will not queue messages for all time but will sort out *dead* nodes automatically after a while and remove messages from the queue then.
|
Friendica will not queue messages for all time but will sort out *dead* nodes automatically after a while and remove messages from the queue then.
|
||||||
|
|
||||||
|
## Server Blocklist
|
||||||
|
|
||||||
|
This page allows to block all communications (inbound and outbound) with a specific domain name.
|
||||||
|
Each blocked domain entry requires a reason that will be displayed on the [friendica](/friendica) page.
|
||||||
|
Matching is exact, blocking a domain doesn't block subdomains.
|
||||||
|
|
||||||
## Federation Statistics
|
## Federation Statistics
|
||||||
|
|
||||||
The federation statistics page gives you a short summery of the nodes/servers/pods of the decentralized social network federation your node knows.
|
The federation statistics page gives you a short summery of the nodes/servers/pods of the decentralized social network federation your node knows.
|
||||||
|
|
123
doc/api.md
123
doc/api.md
|
@ -172,6 +172,11 @@ On error:
|
||||||
HTTP 400 BadRequest
|
HTTP 400 BadRequest
|
||||||
* on friendica_verbose=true: different JSON returns {"result":"error","message":"xyz"}
|
* on friendica_verbose=true: different JSON returns {"result":"error","message":"xyz"}
|
||||||
|
|
||||||
|
---
|
||||||
|
### externalprofile/show (*)
|
||||||
|
#### Parameters
|
||||||
|
* profileurl: profile url
|
||||||
|
|
||||||
---
|
---
|
||||||
### favorites (*; AUTH)
|
### favorites (*; AUTH)
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
@ -460,6 +465,28 @@ Friendica doesn't allow showing followers of other users.
|
||||||
Friendica doesn't allow showing friends of other users.
|
Friendica doesn't allow showing friends of other users.
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
### account/update_profile_image (POST; AUTH)
|
||||||
|
#### Parameters
|
||||||
|
* image: image data as base64 (Twitter has a limit of 700kb, Friendica allows more)
|
||||||
|
* profile_id (optional): id of the profile for which the image should be used, default is changing the default profile
|
||||||
|
|
||||||
|
uploads a new profile image (scales 4-6) to database, changes default or specified profile to the new photo
|
||||||
|
|
||||||
|
#### Return values
|
||||||
|
|
||||||
|
On success:
|
||||||
|
* JSON return: returns the updated user details (see account/verify_credentials)
|
||||||
|
|
||||||
|
On error:
|
||||||
|
* 403 FORBIDDEN: if not authenticated
|
||||||
|
* 400 BADREQUEST: "no media data submitted", "profile_id not available"
|
||||||
|
* 500 INTERNALSERVERERROR: "image size exceeds PHP config settings, file was rejected by server",
|
||||||
|
"image size exceeds Friendica Config setting (uploaded size: x)",
|
||||||
|
"unable to process image data",
|
||||||
|
"image upload failed"
|
||||||
|
|
||||||
|
|
||||||
## Implemented API calls (not compatible with other APIs)
|
## Implemented API calls (not compatible with other APIs)
|
||||||
|
|
||||||
|
|
||||||
|
@ -719,6 +746,100 @@ xml
|
||||||
</photos>
|
</photos>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
### friendica/photoalbum/delete (POST,DELETE; AUTH)
|
||||||
|
#### Parameters
|
||||||
|
* album: name of the album to be deleted
|
||||||
|
|
||||||
|
deletes all images with the specified album name, is not reversible -> ensure that client is asking user for being sure to do this
|
||||||
|
|
||||||
|
#### Return values
|
||||||
|
|
||||||
|
On success:
|
||||||
|
* JSON return {"result":"deleted","message":"album 'xyz' with all containing photos has been deleted."}
|
||||||
|
|
||||||
|
On error:
|
||||||
|
* 403 FORBIDDEN: if not authenticated
|
||||||
|
* 400 BADREQUEST: "no albumname specified", "album not available"
|
||||||
|
* 500 INTERNALSERVERERROR: "problem with deleting item occured", "unknown error - deleting from database failed"
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
### friendica/photoalbum/update (POST,PUT; AUTH)
|
||||||
|
#### Parameters
|
||||||
|
* album: name of the album to be updated
|
||||||
|
* album_new: new name of the album
|
||||||
|
|
||||||
|
changes the album name to album_new for all photos in album
|
||||||
|
|
||||||
|
#### Return values
|
||||||
|
|
||||||
|
On success:
|
||||||
|
* JSON return {"result":"updated","message":"album 'abc' with all containing photos has been renamed to 'xyz'."}
|
||||||
|
|
||||||
|
On error:
|
||||||
|
* 403 FORBIDDEN: if not authenticated
|
||||||
|
* 400 BADREQUEST: "no albumname specified", "no new albumname specified", "album not available"
|
||||||
|
* 500 INTERNALSERVERERROR: "unknown error - updating in database failed"
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
### friendica/photo/create (POST; AUTH)
|
||||||
|
### friendica/photo/update (POST; AUTH)
|
||||||
|
#### Parameters
|
||||||
|
* photo_id (optional): if specified the photo with this id will be updated
|
||||||
|
* media (optional): image data as base64, only optional if photo_id is specified (new upload must have media)
|
||||||
|
* desc (optional): description for the photo, updated when photo_id is specified
|
||||||
|
* album: name of the album to be deleted (always necessary)
|
||||||
|
* album_new (optional): can be used to change the album of a single photo if photo_id is specified
|
||||||
|
* allow_cid/allow_gid/deny_cid/deny_gid (optional): on create: empty string or omitting = public photo, specify in format '```<x><y><z>```' for private photo;
|
||||||
|
on update: keys need to be present with empty values for setting a private photo now to public
|
||||||
|
|
||||||
|
both calls point to one function for creating AND updating photos.
|
||||||
|
Saves data for the scales 0-2 to database (see above for scale description).
|
||||||
|
Call adds non-visible entries to items table to enable authenticated contacts to comment/like the photo.
|
||||||
|
Client should pay attention to the fact that updated access rights are not transferred to the contacts. i.e. public photos remain publicly visible if they have been commented/liked before setting visibility back to a limited group.
|
||||||
|
Currently it is best way to inform user that updating rights is not the best way, offer a solution to add photo as a new photo with the new rights.
|
||||||
|
|
||||||
|
#### Return values
|
||||||
|
|
||||||
|
On success:
|
||||||
|
* new photo uploaded: JSON return with photo data (see friendica/photo)
|
||||||
|
* photo updated - changed photo data: JSON return with photo data (see friendica/photo)
|
||||||
|
* photo updated - changed info: JSON return {"result":"updated","message":"Image id 'xyz' has been updated."}
|
||||||
|
* photo updated - nothing changed: JSON return {"result":"cancelled","message":"Nothing to update for image id 'xyz'."}
|
||||||
|
|
||||||
|
On error:
|
||||||
|
* 403 FORBIDDEN: if not authenticated
|
||||||
|
* 400 BADREQUEST: "no albumname specified", "no media data submitted", "photo not available", "acl data invalid"
|
||||||
|
* 500 INTERNALSERVERERROR: "image size exceeds PHP config settings, file was rejected by server",
|
||||||
|
"image size exceeds Friendica Config setting (uploaded size: x)",
|
||||||
|
"unable to process image data",
|
||||||
|
"image upload failed",
|
||||||
|
"unknown error - uploading photo failed, see Friendica log for more information",
|
||||||
|
"unknown error - update photo entry in database failed",
|
||||||
|
"unknown error - this error on uploading or updating a photo should never happen"
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
### friendica/photo/delete (DELETE; AUTH)
|
||||||
|
#### Parameters
|
||||||
|
* photo_id: id of the photo to be deleted
|
||||||
|
|
||||||
|
deletes a single image with the specified id, is not reversible -> ensure that client is asking user for being sure to do this
|
||||||
|
Sets item table entries for this photo to deleted = 1
|
||||||
|
|
||||||
|
#### Return values
|
||||||
|
|
||||||
|
On success:
|
||||||
|
* JSON return {"result":"deleted","message":"photo with id 'xyz' has been deleted from server."}
|
||||||
|
|
||||||
|
On error:
|
||||||
|
* 403 FORBIDDEN: if not authenticated
|
||||||
|
* 400 BADREQUEST: "no photo_id specified", "photo not available"
|
||||||
|
* 500 INTERNALSERVERERROR: "unknown error on deleting photo", "problem with deleting items occurred"
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
### friendica/direct_messages_setseen (GET; AUTH)
|
### friendica/direct_messages_setseen (GET; AUTH)
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
@ -789,7 +910,6 @@ The following API calls are implemented in GNU Social but not in Friendica: (inc
|
||||||
* friendships/exists
|
* friendships/exists
|
||||||
* friendships/show
|
* friendships/show
|
||||||
* account/update_profile_background_image
|
* account/update_profile_background_image
|
||||||
* account/update_profile_image
|
|
||||||
* blocks/create
|
* blocks/create
|
||||||
* blocks/destroy
|
* blocks/destroy
|
||||||
|
|
||||||
|
@ -812,7 +932,6 @@ The following API calls from the Twitter API aren't implemented neither in Frien
|
||||||
* account/update_delivery_device
|
* account/update_delivery_device
|
||||||
* account/update_profile
|
* account/update_profile
|
||||||
* account/update_profile_background_image
|
* account/update_profile_background_image
|
||||||
* account/update_profile_image
|
|
||||||
* blocks/list
|
* blocks/list
|
||||||
* blocks/ids
|
* blocks/ids
|
||||||
* users/lookup
|
* users/lookup
|
||||||
|
|
|
@ -24,14 +24,14 @@ For more info about PHP autoloading, please refer to the [official PHP documenta
|
||||||
Let's say you have a PHP file in `src/` that define a very useful class:
|
Let's say you have a PHP file in `src/` that define a very useful class:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
// src/ItemsManager.php
|
// src/ItemsManager.php
|
||||||
<?php
|
<?php
|
||||||
namespace \Friendica;
|
namespace Friendica;
|
||||||
|
|
||||||
class ItemsManager {
|
class ItemsManager {
|
||||||
public function getAll() { ... }
|
public function getAll() { ... }
|
||||||
public function getByID($id) { ... }
|
public function getByID($id) { ... }
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
The class `ItemsManager` has been declared in the `Friendica` namespace.
|
The class `ItemsManager` has been declared in the `Friendica` namespace.
|
||||||
|
@ -43,16 +43,16 @@ In order for the Composer autoloader to work, it must first be included. In Frie
|
||||||
The code will be something like:
|
The code will be something like:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
// mod/network.php
|
// mod/network.php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function network_content(App $a) {
|
function network_content(App $a) {
|
||||||
$itemsmanager = new \Friendica\ItemsManager();
|
$itemsmanager = new Friendica\ItemsManager();
|
||||||
$items = $itemsmanager->getAll();
|
$items = $itemsmanager->getAll();
|
||||||
|
|
||||||
// pass $items to template
|
// pass $items to template
|
||||||
// return result
|
// return result
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
That's a quite simple example, but look: no `require()`!
|
That's a quite simple example, but look: no `require()`!
|
||||||
|
@ -61,65 +61,65 @@ If you need to use a class, you can simply use it and you don't need to do anyth
|
||||||
Going further: now we have a bunch of `*Manager` classes that cause some code duplication, let's define a `BaseManager` class, where we move all common code between all managers:
|
Going further: now we have a bunch of `*Manager` classes that cause some code duplication, let's define a `BaseManager` class, where we move all common code between all managers:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
// src/BaseManager.php
|
// src/BaseManager.php
|
||||||
<?php
|
<?php
|
||||||
namespace \Friendica;
|
namespace Friendica;
|
||||||
|
|
||||||
class BaseManager {
|
class BaseManager {
|
||||||
public function thatFunctionEveryManagerUses() { ... }
|
public function thatFunctionEveryManagerUses() { ... }
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
and then let's change the ItemsManager class to use this code
|
and then let's change the ItemsManager class to use this code
|
||||||
|
|
||||||
```php
|
```php
|
||||||
// src/ItemsManager.php
|
// src/ItemsManager.php
|
||||||
<?php
|
<?php
|
||||||
namespace \Friendica;
|
namespace Friendica;
|
||||||
|
|
||||||
class ItemsManager extends BaseManager {
|
class ItemsManager extends BaseManager {
|
||||||
public function getAll() { ... }
|
public function getAll() { ... }
|
||||||
public function getByID($id) { ... }
|
public function getByID($id) { ... }
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Even though we didn't explicitly include the `src/BaseManager.php` file, the autoloader will when this class is first defined, because it is referenced as a parent class.
|
Even though we didn't explicitly include the `src/BaseManager.php` file, the autoloader will when this class is first defined, because it is referenced as a parent class.
|
||||||
It works with the "BaseManager" example here and it works when we need to call static methods:
|
It works with the "BaseManager" example here and it works when we need to call static methods:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
// src/Dfrn.php
|
// src/Dfrn.php
|
||||||
<?php
|
<?php
|
||||||
namespace \Friendica;
|
namespace Friendica;
|
||||||
|
|
||||||
class Dfrn {
|
class Dfrn {
|
||||||
public static function mail($item, $owner) { ... }
|
public static function mail($item, $owner) { ... }
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
```php
|
```php
|
||||||
// mod/mail.php
|
// mod/mail.php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
mail_post($a){
|
mail_post($a){
|
||||||
...
|
...
|
||||||
\Friendica\dfrn::mail($item, $owner);
|
Friendica\dfrn::mail($item, $owner);
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
If your code is in same namespace as the class you need, you don't need to prepend it:
|
If your code is in same namespace as the class you need, you don't need to prepend it:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
// include/delivery.php
|
// include/delivery.php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace \Friendica;
|
namespace Friendica;
|
||||||
|
|
||||||
// this is the same content of current include/delivery.php,
|
// this is the same content of current include/delivery.php,
|
||||||
// but has been declared to be in "Friendica" namespace
|
// but has been declared to be in "Friendica" namespace
|
||||||
|
|
||||||
[...]
|
[...]
|
||||||
switch($contact['network']) {
|
switch($contact['network']) {
|
||||||
case NETWORK_DFRN:
|
case NETWORK_DFRN:
|
||||||
if ($mail) {
|
if ($mail) {
|
||||||
$item['body'] = ...
|
$item['body'] = ...
|
||||||
|
@ -129,64 +129,69 @@ If your code is in same namespace as the class you need, you don't need to prepe
|
||||||
q("DELETE FROM `fsuggest` WHERE `id` = %d LIMIT 1", intval($item['id']));
|
q("DELETE FROM `fsuggest` WHERE `id` = %d LIMIT 1", intval($item['id']));
|
||||||
} elseif ($relocate)
|
} elseif ($relocate)
|
||||||
$atom = Dfrn::relocate($owner, $uid);
|
$atom = Dfrn::relocate($owner, $uid);
|
||||||
[...]
|
[...]
|
||||||
```
|
```
|
||||||
|
|
||||||
This is the current code of `include/delivery.php`, and since the code is declared to be in the "Friendica" namespace, you don't need to write it when you need to use the "Dfrn" class.
|
This is the current code of `include/delivery.php`, and since the code is declared to be in the "Friendica" namespace, you don't need to write it when you need to use the "Dfrn" class.
|
||||||
But if you want to use classes from another library, you need to use the full namespace, e.g.
|
But if you want to use classes from another library, you need to use the full namespace, e.g.
|
||||||
|
|
||||||
```php
|
```php
|
||||||
// src/Diaspora.php
|
// src/Diaspora.php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace \Friendica;
|
namespace Friendica;
|
||||||
|
|
||||||
class Diaspora {
|
class Diaspora {
|
||||||
public function md2bbcode() {
|
public function md2bbcode() {
|
||||||
$html = \Michelf\MarkdownExtra::defaultTransform($text);
|
$html = \Michelf\MarkdownExtra::defaultTransform($text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
if you use that class in many places of the code and you don't want to write the full path to the class every time, you can use the "use" PHP keyword
|
if you use that class in many places of the code and you don't want to write the full path to the class every time, you can use the "use" PHP keyword
|
||||||
|
|
||||||
```php
|
```php
|
||||||
// src/Diaspora.php
|
// src/Diaspora.php
|
||||||
<?php
|
<?php
|
||||||
namespace \Friendica;
|
namespace Friendica;
|
||||||
|
|
||||||
use \Michelf\MarkdownExtra;
|
use \Michelf\MarkdownExtra;
|
||||||
|
|
||||||
class Diaspora {
|
class Diaspora {
|
||||||
public function md2bbcode() {
|
public function md2bbcode() {
|
||||||
$html = MarkdownExtra::defaultTransform($text);
|
$html = MarkdownExtra::defaultTransform($text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that namespaces are like paths in filesystem, separated by "\", with the first "\" being the global scope.
|
Note that namespaces are like paths in filesystem, separated by "\", with the first "\" being the global scope.
|
||||||
You can go deeper if you want to, like:
|
You can go deeper if you want to, like:
|
||||||
|
|
||||||
```
|
```
|
||||||
// src/Network/Dfrn.php
|
// src/Network/Dfrn.php
|
||||||
<?php
|
<?php
|
||||||
namespace \Friendica\Network;
|
namespace Friendica\Network;
|
||||||
|
|
||||||
class Dfrn {
|
class Dfrn {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Please note that the location of the file defining the class must be placed in the appropriate sub-folders of `src` if the namespace isn't plain `\Friendica`.
|
Please note that the location of the file defining the class must be placed in the appropriate sub-folders of `src` if the namespace isn't plain `Friendica`.
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
```
|
```
|
||||||
// src/Dba/Mysql
|
// src/Dba/Mysql
|
||||||
<?php
|
<?php
|
||||||
namespace \Friendica\Dba;
|
namespace Friendica\Dba;
|
||||||
|
|
||||||
class Mysql {
|
class Mysql {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
So you can think of namespaces as folders in a Unix file system, with global scope as the root ("\").
|
So you can think of namespaces as folders in a Unix file system, with global scope as the root ("\").
|
||||||
|
|
||||||
|
## Related
|
||||||
|
|
||||||
|
* [Using Composer](help/Composer)
|
||||||
|
* [How To Move Classes to `src`](help/Developer-How-To-Move-Classes-to-src)
|
|
@ -14,6 +14,7 @@ Database Tables
|
||||||
| [config](help/database/db_config) | main configuration storage |
|
| [config](help/database/db_config) | main configuration storage |
|
||||||
| [contact](help/database/db_contact) | contact table |
|
| [contact](help/database/db_contact) | contact table |
|
||||||
| [conv](help/database/db_conv) | private messages |
|
| [conv](help/database/db_conv) | private messages |
|
||||||
|
| [conversation](help/database/db_conversation) | Raw data and structure information for messages |
|
||||||
| [event](help/database/db_event) | Events |
|
| [event](help/database/db_event) | Events |
|
||||||
| [fcontact](help/database/db_fcontact) | friend suggestion stuff |
|
| [fcontact](help/database/db_fcontact) | friend suggestion stuff |
|
||||||
| [ffinder](help/database/db_ffinder) | friend suggestion stuff |
|
| [ffinder](help/database/db_ffinder) | friend suggestion stuff |
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
Table conversation
|
||||||
|
==================
|
||||||
|
|
||||||
|
| Field | Description | Type | Null | Key | Default | Extra |
|
||||||
|
|-------------------| ---------------------------------- |---------------------|------|-----|---------------------|----------------|
|
||||||
|
| item-uri | URI of the item | varbinary(255) | NO | PRI | NULL | |
|
||||||
|
| reply-to-uri | URI to which this item is a reply | varbinary(255) | NO | | | |
|
||||||
|
| conversation-uri | GNU Social conversation URI | varbinary(255) | NO | | | |
|
||||||
|
| conversation-href | GNU Social conversation link | varbinary(255) | NO | | | |
|
||||||
|
| protocol | The protocol of the item | tinyint(1) unsigned | NO | | 0 | |
|
||||||
|
| source | Original source | mediumtext | NO | | | |
|
||||||
|
| received | Receiving date | datetime | NO | | 0001-01-01 | |
|
||||||
|
|
||||||
|
Return to [database documentation](help/database)
|
|
@ -24,7 +24,7 @@ Wir planen, diese Einschränkung in einer zukünftigen Version zu beheben.
|
||||||
- Apache mit einer aktiverten mod-rewrite-Funktion und dem Eintrag "Options All", so dass du die lokale .htaccess-Datei nutzen kannst
|
- Apache mit einer aktiverten mod-rewrite-Funktion und dem Eintrag "Options All", so dass du die lokale .htaccess-Datei nutzen kannst
|
||||||
- PHP 5.2+. Je neuer, desto besser. Du benötigst 5.3 für die Authentifizierung untereinander. In einer Windows-Umgebung arbeitet die Version 5.2+ möglicherweise nicht, da die Funktion dns_get_record() erst ab Version 5.3 verfügbar ist.
|
- PHP 5.2+. Je neuer, desto besser. Du benötigst 5.3 für die Authentifizierung untereinander. In einer Windows-Umgebung arbeitet die Version 5.2+ möglicherweise nicht, da die Funktion dns_get_record() erst ab Version 5.3 verfügbar ist.
|
||||||
- PHP *Kommandozeilen*-Zugang mit register_argc_argv auf "true" gesetzt in der php.ini-Datei
|
- PHP *Kommandozeilen*-Zugang mit register_argc_argv auf "true" gesetzt in der php.ini-Datei
|
||||||
- curl, gd, mysql und openssl-Erweiterung
|
- Curl, GD, PDO, MySQLi und OpenSSL-Erweiterung
|
||||||
- etwas in der Art eines Email-Servers oder eines Gateways wie PHP mail()
|
- etwas in der Art eines Email-Servers oder eines Gateways wie PHP mail()
|
||||||
- Mysql 5.x
|
- Mysql 5.x
|
||||||
- die Möglichkeit, wiederkehrende Aufgaben mit cron (Linux/Mac) oder "Scheduled Tasks" einzustellen (Windows) [Beachte: andere Optionen sind in Abschnitt 7 dieser Dokumentation zu finden]
|
- die Möglichkeit, wiederkehrende Aufgaben mit cron (Linux/Mac) oder "Scheduled Tasks" einzustellen (Windows) [Beachte: andere Optionen sind in Abschnitt 7 dieser Dokumentation zu finden]
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
* [Zur Startseite der Hilfe](help)
|
* [Zur Startseite der Hilfe](help)
|
||||||
|
|
||||||
Wenn du der Administrator einer Friendica Instanz bist, hast du Zugriff auf das so genannte **Admin Panel** in dem du die Friendica Instanz konfigurieren kannst,
|
Wenn du der Administrator einer Friendica-Instanz bist, hast du Zugriff auf das so genannte **Admin Panel** in dem du die Friendica-Instanz konfigurieren kannst,
|
||||||
|
|
||||||
Auf der Startseite des Admin Panels werden die Informationen zu der Instanz zusammengefasst.
|
Auf der Startseite des Admin Panels werden die Informationen zu der Instanz zusammengefasst.
|
||||||
Die erste Zahl gibt die Anzahl von Nachrichten an, die nicht zugestellt werden konnten.
|
Die erste Zahl gibt die Anzahl von Nachrichten an, die nicht zugestellt werden konnten.
|
||||||
|
@ -22,7 +22,7 @@ Die Unterabschnitte des Admin Panels kannst du in der Seitenleiste auswählen.
|
||||||
|
|
||||||
## Seite
|
## Seite
|
||||||
|
|
||||||
In diesem Bereich des Admin Panels findest du die Hauptkonfiguration deiner Friendica Instanz.
|
In diesem Bereich des Admin Panels findest du die Hauptkonfiguration deiner Friendica-Instanz.
|
||||||
Er ist in mehrere Unterabschnitte aufgeteilt, wobei die Grundeinstellungen oben auf der Seite zu finden sind.
|
Er ist in mehrere Unterabschnitte aufgeteilt, wobei die Grundeinstellungen oben auf der Seite zu finden sind.
|
||||||
|
|
||||||
Da die meisten Konfigurationsoptionen einen Hilfstext im Admin Panel haben, kann und will dieser Artikel nicht alle Einstellungen abdecken.
|
Da die meisten Konfigurationsoptionen einen Hilfstext im Admin Panel haben, kann und will dieser Artikel nicht alle Einstellungen abdecken.
|
||||||
|
@ -130,7 +130,7 @@ Dieses Feature kann z.B. dafür genutzt werden Blogbeiträge zu spiegeln.
|
||||||
In der Grundeinstellung ist es nicht aktiviert, da es zusätzliche Last auf dem Server verursachen kann.
|
In der Grundeinstellung ist es nicht aktiviert, da es zusätzliche Last auf dem Server verursachen kann.
|
||||||
Außerdem könnte es durch Nutzer als Spam Verteiler missbraucht werden.
|
Außerdem könnte es durch Nutzer als Spam Verteiler missbraucht werden.
|
||||||
|
|
||||||
Als Administrator der Friendica Instanz kannst du diese Einstellungen ansonsten nur direkt in der Datenbank vornehmen.
|
Als Administrator der Friendica-Instanz kannst du diese Einstellungen ansonsten nur direkt in der Datenbank vornehmen.
|
||||||
Bevor du das tust solltest du sicherstellen, dass du ein Backup der Datenbank hast und genau weißt was die Änderungen an der Datenbank bewirken, die du vornehmen willst.
|
Bevor du das tust solltest du sicherstellen, dass du ein Backup der Datenbank hast und genau weißt was die Änderungen an der Datenbank bewirken, die du vornehmen willst.
|
||||||
|
|
||||||
### Erweitert
|
### Erweitert
|
||||||
|
@ -183,7 +183,7 @@ Dadurch werden dann die Aufgaben aktiviert, die der cron Job sonst aktivieren w
|
||||||
|
|
||||||
## Nutzer
|
## Nutzer
|
||||||
|
|
||||||
In diesem Abschnitt des Admin Panels kannst du die Nutzer deiner Friendica Instanz moderieren.
|
In diesem Abschnitt des Admin Panels kannst du die Nutzer deiner Friendica-Instanz moderieren.
|
||||||
|
|
||||||
Solltest du für **Registrierungsmethode** die Einstellung "Bedarf Zustimmung" gewählt haben, werden hier zu Beginn der Seite neue Registrationen aufgelistet.
|
Solltest du für **Registrierungsmethode** die Einstellung "Bedarf Zustimmung" gewählt haben, werden hier zu Beginn der Seite neue Registrationen aufgelistet.
|
||||||
Als Administrator kannst du hier die Registration akzeptieren oder ablehnen.
|
Als Administrator kannst du hier die Registration akzeptieren oder ablehnen.
|
||||||
|
@ -202,12 +202,12 @@ Sie müssen in das `/addon` Verzeichnis kopiert werden.
|
||||||
Auf der Seite wird eine Liste der verfügbaren Erweiterungen angezeigt.
|
Auf der Seite wird eine Liste der verfügbaren Erweiterungen angezeigt.
|
||||||
Neben den Namen der Erweiterungen wird ein Indikator angezeigt, der anzeigt ob das Addon gerade aktiviert ist oder nicht.
|
Neben den Namen der Erweiterungen wird ein Indikator angezeigt, der anzeigt ob das Addon gerade aktiviert ist oder nicht.
|
||||||
|
|
||||||
Wenn du die Erweiterungen aktualisiert die du auf deiner Friendica Instanz nutzt könnte es sein, dass sie neu geladen werden müssen, damit die Änderungen aktiviert werden.
|
Wenn du die Erweiterungen aktualisiert die du auf deiner Friendica-Instanz nutzt könnte es sein, dass sie neu geladen werden müssen, damit die Änderungen aktiviert werden.
|
||||||
Um diesen Prozess zu vereinfachen gibt es am Anfang der Seite einen Button um alle aktiven Plugins neu zu laden.
|
Um diesen Prozess zu vereinfachen gibt es am Anfang der Seite einen Button um alle aktiven Plugins neu zu laden.
|
||||||
|
|
||||||
## Themen
|
## Themen
|
||||||
|
|
||||||
Der Bereich zur Kontrolle der auf der Friendica Instanz verfügbaren Themen funktioniert analog zum Plugins Bereich.
|
Der Bereich zur Kontrolle der auf der Friendica-Instanz verfügbaren Themen funktioniert analog zum Plugins Bereich.
|
||||||
Jedes Theme hat eine extra Seite auf der der aktuelle Status, ein Bildschirmfoto des Themes, zusätzliche Informationen und eventuelle Einstellungen des Themes zu finden sind.
|
Jedes Theme hat eine extra Seite auf der der aktuelle Status, ein Bildschirmfoto des Themes, zusätzliche Informationen und eventuelle Einstellungen des Themes zu finden sind.
|
||||||
Genau wie Erweiterungen können Themes in der Übersichtsliste oder der Theme-Seite aktiviert bzw. deaktiviert werden.
|
Genau wie Erweiterungen können Themes in der Übersichtsliste oder der Theme-Seite aktiviert bzw. deaktiviert werden.
|
||||||
Um ein Standardtheme für die Instanz zu wählen, benutze bitte die *Seiten* Bereich des Admin Panels.
|
Um ein Standardtheme für die Instanz zu wählen, benutze bitte die *Seiten* Bereich des Admin Panels.
|
||||||
|
@ -238,6 +238,12 @@ Aber keine Panik!
|
||||||
Friendica wird die Beiträge nicht für alle Zeiten in der Warteschlange behalten.
|
Friendica wird die Beiträge nicht für alle Zeiten in der Warteschlange behalten.
|
||||||
Nach einiger Zeit werden Knoten als inaktiv identifiziert und Nachrichten an Nutzer dieser Knoten aus der Warteschlange gelöscht.
|
Nach einiger Zeit werden Knoten als inaktiv identifiziert und Nachrichten an Nutzer dieser Knoten aus der Warteschlange gelöscht.
|
||||||
|
|
||||||
|
## Server Blockliste
|
||||||
|
|
||||||
|
Auf dieser Seite des Admin Panels können Administratoren einer Friendica-Instanz die komplette Kommunikation (eingehend und ausgehend) mit bestimmten Domains unterbinden.
|
||||||
|
Für jede dieser Blockierungen muss ein Grund angegeben werden, welcher auf der Informationsseite [friendica](/friendica) angezeigt wird.
|
||||||
|
Der Abgleich der Domainnamen ist exakt, Subdomains werden nicht automatisch ebenfalls blockiert.
|
||||||
|
|
||||||
## Federation Statistik
|
## Federation Statistik
|
||||||
|
|
||||||
Deine Instanz ist ein Teil eines Netzwerks von Servern dezentraler sozialer Netzwerke, der sogenannten **Federation**.
|
Deine Instanz ist ein Teil eines Netzwerks von Servern dezentraler sozialer Netzwerke, der sogenannten **Federation**.
|
||||||
|
@ -258,7 +264,7 @@ Wenn du das dennoch tun musste und die Standardeinstellungen des Apache Servers
|
||||||
Solltest du einen anderen Webserver verwenden, solltest du sicherstellen, dass der Zugrif zu Dateien mit diesen Endungen nicht möglich ist.
|
Solltest du einen anderen Webserver verwenden, solltest du sicherstellen, dass der Zugrif zu Dateien mit diesen Endungen nicht möglich ist.
|
||||||
|
|
||||||
Es gibt fünf Level der Ausführlichkeit mit denen Friendica arbeitet: Normal, Trace, Debug, Data und All.
|
Es gibt fünf Level der Ausführlichkeit mit denen Friendica arbeitet: Normal, Trace, Debug, Data und All.
|
||||||
Normalerweise solltest du für den Betrieb deiner Friendica Instanz keine Logs benötigen.
|
Normalerweise solltest du für den Betrieb deiner Friendica-Instanz keine Logs benötigen.
|
||||||
Wenn du versuchst einem Problem auf den Grund zu gehen, solltest du das "DEBUG" Level wählen.
|
Wenn du versuchst einem Problem auf den Grund zu gehen, solltest du das "DEBUG" Level wählen.
|
||||||
Mit dem "All" Level schreibt Friendica alles in die Logdatei.
|
Mit dem "All" Level schreibt Friendica alles in die Logdatei.
|
||||||
Die Datenmenge der geloggten Daten kann relativ schnell anwachsen, deshalb empfehlen wir das Anlegen von Protokollen nur zu aktivieren wenn es unbedingt nötig ist.
|
Die Datenmenge der geloggten Daten kann relativ schnell anwachsen, deshalb empfehlen wir das Anlegen von Protokollen nur zu aktivieren wenn es unbedingt nötig ist.
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
use Friendica\Network\Probe;
|
||||||
|
|
||||||
// Included here for completeness, but this is a very dangerous operation.
|
// Included here for completeness, but this is a very dangerous operation.
|
||||||
// It is the caller's responsibility to confirm the requestor's intent and
|
// It is the caller's responsibility to confirm the requestor's intent and
|
||||||
// authorisation to do this.
|
// authorisation to do this.
|
||||||
|
@ -89,11 +92,11 @@ function terminate_friendship($user,$self,$contact) {
|
||||||
/// @TODO Get rid of this, include/datetime.php should care about it by itself
|
/// @TODO Get rid of this, include/datetime.php should care about it by itself
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
require_once('include/datetime.php');
|
require_once 'include/datetime.php';
|
||||||
|
|
||||||
if ($contact['network'] === NETWORK_OSTATUS) {
|
if ($contact['network'] === NETWORK_OSTATUS) {
|
||||||
|
|
||||||
require_once('include/ostatus.php');
|
require_once 'include/ostatus.php';
|
||||||
|
|
||||||
// create an unfollow slap
|
// create an unfollow slap
|
||||||
$item = array();
|
$item = array();
|
||||||
|
@ -102,14 +105,14 @@ function terminate_friendship($user,$self,$contact) {
|
||||||
$slap = ostatus::salmon($item, $user);
|
$slap = ostatus::salmon($item, $user);
|
||||||
|
|
||||||
if ((x($contact,'notify')) && (strlen($contact['notify']))) {
|
if ((x($contact,'notify')) && (strlen($contact['notify']))) {
|
||||||
require_once('include/salmon.php');
|
require_once 'include/salmon.php';
|
||||||
slapper($user,$contact['notify'],$slap);
|
slapper($user,$contact['notify'],$slap);
|
||||||
}
|
}
|
||||||
} elseif ($contact['network'] === NETWORK_DIASPORA) {
|
} elseif ($contact['network'] === NETWORK_DIASPORA) {
|
||||||
require_once('include/diaspora.php');
|
require_once 'include/diaspora.php';
|
||||||
Diaspora::send_unshare($user,$contact);
|
Diaspora::send_unshare($user,$contact);
|
||||||
} elseif ($contact['network'] === NETWORK_DFRN) {
|
} elseif ($contact['network'] === NETWORK_DFRN) {
|
||||||
require_once('include/dfrn.php');
|
require_once 'include/dfrn.php';
|
||||||
dfrn::deliver($user,$contact,'placeholder', 1);
|
dfrn::deliver($user,$contact,'placeholder', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,7 +364,6 @@ function get_contact_details_by_addr($addr, $uid = -1) {
|
||||||
dbesc($addr));
|
dbesc($addr));
|
||||||
|
|
||||||
if (!dbm::is_result($r)) {
|
if (!dbm::is_result($r)) {
|
||||||
require_once('include/Probe.php');
|
|
||||||
$data = Probe::uri($addr);
|
$data = Probe::uri($addr);
|
||||||
|
|
||||||
$profile = get_contact_details_by_url($data['url'], $uid);
|
$profile = get_contact_details_by_url($data['url'], $uid);
|
||||||
|
@ -587,7 +589,6 @@ function get_contact($url, $uid = 0, $no_update = false) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once('include/Probe.php');
|
|
||||||
$data = Probe::uri($url);
|
$data = Probe::uri($url);
|
||||||
|
|
||||||
// Last try in gcontact for unsupported networks
|
// Last try in gcontact for unsupported networks
|
||||||
|
@ -704,7 +705,7 @@ function get_contact($url, $uid = 0, $no_update = false) {
|
||||||
*/
|
*/
|
||||||
function posts_from_gcontact(App $a, $gcontact_id) {
|
function posts_from_gcontact(App $a, $gcontact_id) {
|
||||||
|
|
||||||
require_once('include/conversation.php');
|
require_once 'include/conversation.php';
|
||||||
|
|
||||||
// There are no posts with "uid = 0" with connector networks
|
// There are no posts with "uid = 0" with connector networks
|
||||||
// This speeds up the query a lot
|
// This speeds up the query a lot
|
||||||
|
@ -743,7 +744,7 @@ function posts_from_gcontact(App $a, $gcontact_id) {
|
||||||
*/
|
*/
|
||||||
function posts_from_contact_url(App $a, $contact_url) {
|
function posts_from_contact_url(App $a, $contact_url) {
|
||||||
|
|
||||||
require_once('include/conversation.php');
|
require_once 'include/conversation.php';
|
||||||
|
|
||||||
// There are no posts with "uid = 0" with connector networks
|
// There are no posts with "uid = 0" with connector networks
|
||||||
// This speeds up the query a lot
|
// This speeds up the query a lot
|
||||||
|
@ -852,4 +853,3 @@ function account_type($contact) {
|
||||||
|
|
||||||
return $account_type;
|
return $account_type;
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -81,4 +81,3 @@ class Emailer {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file include/ForumManager.php
|
* @file include/ForumManager.php
|
||||||
* @brief ForumManager class with its methods related to forum functionality *
|
* @brief ForumManager class with its methods related to forum functionality *
|
||||||
|
|
|
@ -4,9 +4,10 @@
|
||||||
* @brief Methods for read and write notifications from/to database
|
* @brief Methods for read and write notifications from/to database
|
||||||
* or for formatting notifications
|
* or for formatting notifications
|
||||||
*/
|
*/
|
||||||
require_once('include/html2plain.php');
|
require_once 'include/html2plain.php';
|
||||||
require_once("include/datetime.php");
|
require_once 'include/probe.php';
|
||||||
require_once("include/bbcode.php");
|
require_once 'include/datetime.php';
|
||||||
|
require_once 'include/bbcode.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Methods for read and write notifications from/to database
|
* @brief Methods for read and write notifications from/to database
|
||||||
|
@ -144,7 +145,6 @@ class NotificationsManager {
|
||||||
/**
|
/**
|
||||||
* @brief List of pages for the Notifications TabBar
|
* @brief List of pages for the Notifications TabBar
|
||||||
*
|
*
|
||||||
* @param app $a The
|
|
||||||
* @return array with with notifications TabBar data
|
* @return array with with notifications TabBar data
|
||||||
*/
|
*/
|
||||||
public function getTabs() {
|
public function getTabs() {
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
* @brief This file contains the Photo class for image processing
|
* @brief This file contains the Photo class for image processing
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
|
||||||
require_once("include/photos.php");
|
require_once("include/photos.php");
|
||||||
|
|
||||||
class Photo {
|
class Photo {
|
||||||
|
@ -68,9 +70,11 @@ class Photo {
|
||||||
$this->image->destroy();
|
$this->image->destroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (is_resource($this->image)) {
|
||||||
imagedestroy($this->image);
|
imagedestroy($this->image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function is_imagick() {
|
public function is_imagick() {
|
||||||
return $this->imagick;
|
return $this->imagick;
|
||||||
|
@ -324,6 +328,7 @@ class Photo {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if script dies at this point check memory_limit setting in php.ini
|
||||||
$this->image = imagerotate($this->image,$degrees,0);
|
$this->image = imagerotate($this->image,$degrees,0);
|
||||||
$this->width = imagesx($this->image);
|
$this->width = imagesx($this->image);
|
||||||
$this->height = imagesy($this->image);
|
$this->height = imagesy($this->image);
|
||||||
|
@ -620,7 +625,7 @@ class Photo {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function store($uid, $cid, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '') {
|
public function store($uid, $cid, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '', $desc = '') {
|
||||||
|
|
||||||
$r = q("SELECT `guid` FROM `photo` WHERE `resource-id` = '%s' AND `guid` != '' LIMIT 1",
|
$r = q("SELECT `guid` FROM `photo` WHERE `resource-id` = '%s' AND `guid` != '' LIMIT 1",
|
||||||
dbesc($rid)
|
dbesc($rid)
|
||||||
|
@ -657,7 +662,8 @@ class Photo {
|
||||||
`allow_cid` = '%s',
|
`allow_cid` = '%s',
|
||||||
`allow_gid` = '%s',
|
`allow_gid` = '%s',
|
||||||
`deny_cid` = '%s',
|
`deny_cid` = '%s',
|
||||||
`deny_gid` = '%s'
|
`deny_gid` = '%s',
|
||||||
|
`desc` = '%s'
|
||||||
WHERE `id` = %d",
|
WHERE `id` = %d",
|
||||||
|
|
||||||
intval($uid),
|
intval($uid),
|
||||||
|
@ -679,12 +685,13 @@ class Photo {
|
||||||
dbesc($allow_gid),
|
dbesc($allow_gid),
|
||||||
dbesc($deny_cid),
|
dbesc($deny_cid),
|
||||||
dbesc($deny_gid),
|
dbesc($deny_gid),
|
||||||
|
dbesc($desc),
|
||||||
intval($x[0]['id'])
|
intval($x[0]['id'])
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$r = q("INSERT INTO `photo`
|
$r = q("INSERT INTO `photo`
|
||||||
(`uid`, `contact-id`, `guid`, `resource-id`, `created`, `edited`, `filename`, type, `album`, `height`, `width`, `datasize`, `data`, `scale`, `profile`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`)
|
(`uid`, `contact-id`, `guid`, `resource-id`, `created`, `edited`, `filename`, type, `album`, `height`, `width`, `datasize`, `data`, `scale`, `profile`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `desc`)
|
||||||
VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s', %d, %d, '%s', '%s', '%s', '%s')",
|
VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s', %d, %d, '%s', '%s', '%s', '%s', '%s')",
|
||||||
intval($uid),
|
intval($uid),
|
||||||
intval($cid),
|
intval($cid),
|
||||||
dbesc($guid),
|
dbesc($guid),
|
||||||
|
@ -703,7 +710,8 @@ class Photo {
|
||||||
dbesc($allow_cid),
|
dbesc($allow_cid),
|
||||||
dbesc($allow_gid),
|
dbesc($allow_gid),
|
||||||
dbesc($deny_cid),
|
dbesc($deny_cid),
|
||||||
dbesc($deny_gid)
|
dbesc($deny_gid),
|
||||||
|
dbesc($desc)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
* @brief This file contains the Smilies class which contains functions to handle smiles
|
* @brief This file contains the Smilies class which contains functions to handle smiles
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class contains functions to handle smiles
|
* This class contains functions to handle smiles
|
||||||
*/
|
*/
|
||||||
|
@ -64,41 +66,41 @@ class Smilies {
|
||||||
);
|
);
|
||||||
|
|
||||||
$icons = array(
|
$icons = array(
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-heart.gif" alt="<3" title="<3" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-heart.gif" alt="<3" title="<3" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-brokenheart.gif" alt="</3" title="</3" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-brokenheart.gif" alt="</3" title="</3" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-brokenheart.gif" alt="<\\3" title="<\\3" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-brokenheart.gif" alt="<\\3" title="<\\3" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-smile.gif" alt=":-)" title=":-)" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-smile.gif" alt=":-)" title=":-)" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-wink.gif" alt=";-)" title=";-)" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-wink.gif" alt=";-)" title=";-)" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-frown.gif" alt=":-(" title=":-(" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-frown.gif" alt=":-(" title=":-(" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-tongue-out.gif" alt=":-P" title=":-P" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-tongue-out.gif" alt=":-P" title=":-P" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-tongue-out.gif" alt=":-p" title=":-P" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-tongue-out.gif" alt=":-p" title=":-P" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-kiss.gif" alt=":-\" title=":-\" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-kiss.gif" alt=":-\" title=":-\" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-kiss.gif" alt=":-\" title=":-\" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-kiss.gif" alt=":-\" title=":-\" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-kiss.gif" alt=":-x" title=":-x" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-kiss.gif" alt=":-x" title=":-x" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-kiss.gif" alt=":-X" title=":-X" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-kiss.gif" alt=":-X" title=":-X" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-laughing.gif" alt=":-D" title=":-D" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-laughing.gif" alt=":-D" title=":-D" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-surprised.gif" alt="8-|" title="8-|" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-surprised.gif" alt="8-|" title="8-|" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-surprised.gif" alt="8-O" title="8-O" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-surprised.gif" alt="8-O" title="8-O" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-surprised.gif" alt=":-O" title="8-O" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-surprised.gif" alt=":-O" title="8-O" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-thumbsup.gif" alt="\\o/" title="\\o/" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-thumbsup.gif" alt="\\o/" title="\\o/" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-Oo.gif" alt="o.O" title="o.O" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-Oo.gif" alt="o.O" title="o.O" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-Oo.gif" alt="O.o" title="O.o" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-Oo.gif" alt="O.o" title="O.o" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-Oo.gif" alt="o_O" title="o_O" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-Oo.gif" alt="o_O" title="o_O" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-Oo.gif" alt="O_o" title="O_o" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-Oo.gif" alt="O_o" title="O_o" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-cry.gif" alt=":\'(" title=":\'("/>',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-cry.gif" alt=":\'(" title=":\'("/>',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-foot-in-mouth.gif" alt=":-!" title=":-!" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-foot-in-mouth.gif" alt=":-!" title=":-!" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-undecided.gif" alt=":-/" title=":-/" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-undecided.gif" alt=":-/" title=":-/" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-embarassed.gif" alt=":-[" title=":-[" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-embarassed.gif" alt=":-[" title=":-[" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-cool.gif" alt="8-)" title="8-)" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-cool.gif" alt="8-)" title="8-)" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/beer_mug.gif" alt=":beer" title=":beer" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/beer_mug.gif" alt=":beer" title=":beer" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/beer_mug.gif" alt=":homebrew" title=":homebrew" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/beer_mug.gif" alt=":homebrew" title=":homebrew" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/coffee.gif" alt=":coffee" title=":coffee" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/coffee.gif" alt=":coffee" title=":coffee" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-facepalm.gif" alt=":facepalm" title=":facepalm" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-facepalm.gif" alt=":facepalm" title=":facepalm" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/like.gif" alt=":like" title=":like" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/like.gif" alt=":like" title=":like" />',
|
||||||
'<img class="smiley" src="' . app::get_baseurl() . '/images/dislike.gif" alt=":dislike" title=":dislike" />',
|
'<img class="smiley" src="' . App::get_baseurl() . '/images/dislike.gif" alt=":dislike" title=":dislike" />',
|
||||||
'<a href="http://friendica.com">~friendica <img class="smiley" src="' . app::get_baseurl() . '/images/friendica-16.png" alt="~friendica" title="~friendica" /></a>',
|
'<a href="http://friendica.com">~friendica <img class="smiley" src="' . App::get_baseurl() . '/images/friendica-16.png" alt="~friendica" title="~friendica" /></a>',
|
||||||
'<a href="http://redmatrix.me/">red<img class="smiley" src="' . app::get_baseurl() . '/images/rm-16.png" alt="red#" title="red#" />matrix</a>',
|
'<a href="http://redmatrix.me/">red<img class="smiley" src="' . App::get_baseurl() . '/images/rm-16.png" alt="red#" title="red#" />matrix</a>',
|
||||||
'<a href="http://redmatrix.me/">red<img class="smiley" src="' . app::get_baseurl() . '/images/rm-16.png" alt="red#matrix" title="red#matrix" />matrix</a>'
|
'<a href="http://redmatrix.me/">red<img class="smiley" src="' . App::get_baseurl() . '/images/rm-16.png" alt="red#matrix" title="red#matrix" />matrix</a>'
|
||||||
);
|
);
|
||||||
|
|
||||||
$params = array('texts' => $texts, 'icons' => $icons);
|
$params = array('texts' => $texts, 'icons' => $icons);
|
||||||
|
@ -174,7 +176,7 @@ class Smilies {
|
||||||
return $x[0];
|
return $x[0];
|
||||||
$t = '';
|
$t = '';
|
||||||
for($cnt = 0; $cnt < strlen($x[1]); $cnt ++)
|
for($cnt = 0; $cnt < strlen($x[1]); $cnt ++)
|
||||||
$t .= '<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-heart.gif" alt="<3" />';
|
$t .= '<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-heart.gif" alt="<3" />';
|
||||||
$r = str_replace($x[0],$t,$x[0]);
|
$r = str_replace($x[0],$t,$x[0]);
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
* @file include/acl_selectors.php
|
* @file include/acl_selectors.php
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
|
||||||
require_once "include/contact_selectors.php";
|
require_once "include/contact_selectors.php";
|
||||||
require_once "include/contact_widgets.php";
|
require_once "include/contact_widgets.php";
|
||||||
require_once "include/DirSearch.php";
|
require_once "include/DirSearch.php";
|
||||||
|
@ -543,7 +545,7 @@ function acl_lookup(App $a, $out_type = 'json') {
|
||||||
|
|
||||||
if ($type == '') {
|
if ($type == '') {
|
||||||
|
|
||||||
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact`
|
$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` != ''
|
WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
|
||||||
AND NOT (`network` IN ('%s', '%s'))
|
AND NOT (`network` IN ('%s', '%s'))
|
||||||
$sql_extra2
|
$sql_extra2
|
||||||
|
@ -552,7 +554,7 @@ function acl_lookup(App $a, $out_type = 'json') {
|
||||||
dbesc(NETWORK_OSTATUS), dbesc(NETWORK_STATUSNET)
|
dbesc(NETWORK_OSTATUS), dbesc(NETWORK_STATUSNET)
|
||||||
);
|
);
|
||||||
} elseif ($type == 'c') {
|
} elseif ($type == 'c') {
|
||||||
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact`
|
$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` != ''
|
WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
|
||||||
AND NOT (`network` IN ('%s'))
|
AND NOT (`network` IN ('%s'))
|
||||||
$sql_extra2
|
$sql_extra2
|
||||||
|
@ -562,7 +564,7 @@ function acl_lookup(App $a, $out_type = 'json') {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
elseif ($type == 'm') {
|
elseif ($type == 'm') {
|
||||||
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag` FROM `contact`
|
$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`
|
WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive`
|
||||||
AND `network` IN ('%s','%s','%s')
|
AND `network` IN ('%s','%s','%s')
|
||||||
$sql_extra2
|
$sql_extra2
|
||||||
|
@ -573,7 +575,7 @@ function acl_lookup(App $a, $out_type = 'json') {
|
||||||
dbesc(NETWORK_DIASPORA)
|
dbesc(NETWORK_DIASPORA)
|
||||||
);
|
);
|
||||||
} elseif ($type == 'a') {
|
} elseif ($type == 'a') {
|
||||||
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact`
|
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv` FROM `contact`
|
||||||
WHERE `uid` = %d AND `pending` = 0
|
WHERE `uid` = %d AND `pending` = 0
|
||||||
$sql_extra2
|
$sql_extra2
|
||||||
ORDER BY `name` ASC ",
|
ORDER BY `name` ASC ",
|
||||||
|
@ -617,6 +619,7 @@ function acl_lookup(App $a, $out_type = 'json') {
|
||||||
'network' => $g['network'],
|
'network' => $g['network'],
|
||||||
'link' => $g['url'],
|
'link' => $g['url'],
|
||||||
'nick' => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']),
|
'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),
|
'forum' => ((x($g, 'forum') || x($g, 'prv')) ? 1 : 0),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -661,6 +664,7 @@ function acl_lookup(App $a, $out_type = 'json') {
|
||||||
'network' => $contact['network'],
|
'network' => $contact['network'],
|
||||||
'link' => $contact['url'],
|
'link' => $contact['url'],
|
||||||
'nick' => htmlentities($contact['nick'] ? : $contact['addr']),
|
'nick' => htmlentities($contact['nick'] ? : $contact['addr']),
|
||||||
|
'addr' => htmlentities(($contact['addr']) ? $contact['addr'] : $contact['url']),
|
||||||
'forum' => $contact['forum']
|
'forum' => $contact['forum']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
740
include/api.php
740
include/api.php
|
@ -6,7 +6,8 @@
|
||||||
* @todo Automatically detect if incoming data is HTML or BBCode
|
* @todo Automatically detect if incoming data is HTML or BBCode
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\App;
|
||||||
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
require_once 'include/HTTPExceptions.php';
|
require_once 'include/HTTPExceptions.php';
|
||||||
require_once 'include/bbcode.php';
|
require_once 'include/bbcode.php';
|
||||||
|
@ -525,6 +526,15 @@ $called_api = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_null($user) && x($_GET, 'profileurl')) {
|
||||||
|
$user = dbesc(normalise_link($_GET['profileurl']));
|
||||||
|
$nick = $user;
|
||||||
|
$extra_query = "AND `contact`.`nurl` = '%s' ";
|
||||||
|
if (api_user() !== false) {
|
||||||
|
$extra_query .= "AND `contact`.`uid`=".intval(api_user());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (is_null($user) AND ($a->argc > (count($called_api) - 1)) AND (count($called_api) > 0)) {
|
if (is_null($user) AND ($a->argc > (count($called_api) - 1)) AND (count($called_api) > 0)) {
|
||||||
$argid = count($called_api);
|
$argid = count($called_api);
|
||||||
list($user, $null) = explode(".", $a->argv[$argid]);
|
list($user, $null) = explode(".", $a->argv[$argid]);
|
||||||
|
@ -1400,6 +1410,7 @@ $called_api = null;
|
||||||
|
|
||||||
/// @TODO move to top of file or somewhere better
|
/// @TODO move to top of file or somewhere better
|
||||||
api_register_func('api/users/show','api_users_show');
|
api_register_func('api/users/show','api_users_show');
|
||||||
|
api_register_func('api/externalprofile/show','api_users_show');
|
||||||
|
|
||||||
function api_users_search($type) {
|
function api_users_search($type) {
|
||||||
|
|
||||||
|
@ -3276,14 +3287,117 @@ $called_api = null;
|
||||||
api_register_func('api/oauth/request_token', 'api_oauth_request_token', false);
|
api_register_func('api/oauth/request_token', 'api_oauth_request_token', false);
|
||||||
api_register_func('api/oauth/access_token', 'api_oauth_access_token', false);
|
api_register_func('api/oauth/access_token', 'api_oauth_access_token', false);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief delete a complete photoalbum with all containing photos from database through api
|
||||||
|
*
|
||||||
|
* @param string $type Known types are 'atom', 'rss', 'xml' and 'json'
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function api_fr_photoalbum_delete($type) {
|
||||||
|
if (api_user() === false) {
|
||||||
|
throw new ForbiddenException();
|
||||||
|
}
|
||||||
|
// input params
|
||||||
|
$album = (x($_REQUEST,'album') ? $_REQUEST['album'] : "");
|
||||||
|
|
||||||
|
// we do not allow calls without album string
|
||||||
|
if ($album == "") {
|
||||||
|
throw new BadRequestException("no albumname specified");
|
||||||
|
}
|
||||||
|
// check if album is existing
|
||||||
|
$r = q("SELECT DISTINCT `resource-id` FROM `photo` WHERE `uid` = %d AND `album` = '%s'",
|
||||||
|
intval(api_user()),
|
||||||
|
dbesc($album));
|
||||||
|
if (!dbm::is_result($r))
|
||||||
|
throw new BadRequestException("album not available");
|
||||||
|
|
||||||
|
// function for setting the items to "deleted = 1" which ensures that comments, likes etc. are not shown anymore
|
||||||
|
// to the user and the contacts of the users (drop_items() performs the federation of the deletion to other networks
|
||||||
|
foreach ($r as $rr) {
|
||||||
|
$photo_item = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `resource-id` = '%s' AND `type` = 'photo'",
|
||||||
|
intval(local_user()),
|
||||||
|
dbesc($rr['resource-id'])
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!dbm::is_result($photo_item)) {
|
||||||
|
throw new InternalServerErrorException("problem with deleting items occured");
|
||||||
|
}
|
||||||
|
drop_item($photo_item[0]['id'],false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// now let's delete all photos from the album
|
||||||
|
$result = q("DELETE FROM `photo` WHERE `uid` = %d AND `album` = '%s'",
|
||||||
|
intval(api_user()),
|
||||||
|
dbesc($album));
|
||||||
|
|
||||||
|
// return success of deletion or error message
|
||||||
|
if ($result) {
|
||||||
|
$answer = array('result' => 'deleted', 'message' => 'album `' . $album . '` with all containing photos has been deleted.');
|
||||||
|
return api_format_data("photoalbum_delete", $type, array('$result' => $answer));
|
||||||
|
} else {
|
||||||
|
throw new InternalServerErrorException("unknown error - deleting from database failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief update the name of the album for all photos of an album
|
||||||
|
*
|
||||||
|
* @param string $type Known types are 'atom', 'rss', 'xml' and 'json'
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function api_fr_photoalbum_update($type) {
|
||||||
|
if (api_user() === false) {
|
||||||
|
throw new ForbiddenException();
|
||||||
|
}
|
||||||
|
// input params
|
||||||
|
$album = (x($_REQUEST,'album') ? $_REQUEST['album'] : "");
|
||||||
|
$album_new = (x($_REQUEST,'album_new') ? $_REQUEST['album_new'] : "");
|
||||||
|
|
||||||
|
// we do not allow calls without album string
|
||||||
|
if ($album == "") {
|
||||||
|
throw new BadRequestException("no albumname specified");
|
||||||
|
}
|
||||||
|
if ($album_new == "") {
|
||||||
|
throw new BadRequestException("no new albumname specified");
|
||||||
|
}
|
||||||
|
// check if album is existing
|
||||||
|
$r = q("SELECT `id` FROM `photo` WHERE `uid` = %d AND `album` = '%s'",
|
||||||
|
intval(api_user()),
|
||||||
|
dbesc($album));
|
||||||
|
if (!dbm::is_result($r)) {
|
||||||
|
throw new BadRequestException("album not available");
|
||||||
|
}
|
||||||
|
// now let's update all photos to the albumname
|
||||||
|
$result = q("UPDATE `photo` SET `album` = '%s' WHERE `uid` = %d AND `album` = '%s'",
|
||||||
|
dbesc($album_new),
|
||||||
|
intval(api_user()),
|
||||||
|
dbesc($album));
|
||||||
|
|
||||||
|
// return success of updating or error message
|
||||||
|
if ($result) {
|
||||||
|
$answer = array('result' => 'updated', 'message' => 'album `' . $album . '` with all containing photos has been renamed to `' . $album_new . '`.');
|
||||||
|
return api_format_data("photoalbum_update", $type, array('$result' => $answer));
|
||||||
|
} else {
|
||||||
|
throw new InternalServerErrorException("unknown error - updating in database failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief list all photos of the authenticated user
|
||||||
|
*
|
||||||
|
* @param string $type Known types are 'atom', 'rss', 'xml' and 'json'
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function api_fr_photos_list($type) {
|
function api_fr_photos_list($type) {
|
||||||
if (api_user() === false) {
|
if (api_user() === false) {
|
||||||
throw new ForbiddenException();
|
throw new ForbiddenException();
|
||||||
}
|
}
|
||||||
|
$r = q("SELECT `resource-id`, MAX(scale) AS `scale`, `album`, `filename`, `type`, MAX(`created`) AS `created`,
|
||||||
$r = q("SELECT `resource-id`, MAX(`scale`) AS `scale`, `album`, `filename`, `type`
|
MAX(`edited`) AS `edited`, MAX(`desc`) AS `desc` FROM `photo`
|
||||||
FROM `photo`
|
WHERE `uid` = %d AND `album` != 'Contact Photos' GROUP BY `resource-id`",
|
||||||
WHERE `uid` = %d AND `album` != 'Contact Photos' GROUP BY `resource-id`, `album`, `filename`, `type`",
|
|
||||||
intval(local_user())
|
intval(local_user())
|
||||||
);
|
);
|
||||||
$typetoext = array(
|
$typetoext = array(
|
||||||
|
@ -3291,7 +3405,7 @@ $called_api = null;
|
||||||
'image/png' => 'png',
|
'image/png' => 'png',
|
||||||
'image/gif' => 'gif'
|
'image/gif' => 'gif'
|
||||||
);
|
);
|
||||||
$data = array('photo' => array());
|
$data = array('photo'=>array());
|
||||||
if (dbm::is_result($r)) {
|
if (dbm::is_result($r)) {
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
$photo = array();
|
$photo = array();
|
||||||
|
@ -3300,6 +3414,9 @@ $called_api = null;
|
||||||
$photo['filename'] = $rr['filename'];
|
$photo['filename'] = $rr['filename'];
|
||||||
$photo['type'] = $rr['type'];
|
$photo['type'] = $rr['type'];
|
||||||
$thumb = App::get_baseurl() . "/photo/" . $rr['resource-id'] . "-" . $rr['scale'] . "." . $typetoext[$rr['type']];
|
$thumb = App::get_baseurl() . "/photo/" . $rr['resource-id'] . "-" . $rr['scale'] . "." . $typetoext[$rr['type']];
|
||||||
|
$photo['created'] = $rr['created'];
|
||||||
|
$photo['edited'] = $rr['edited'];
|
||||||
|
$photo['desc'] = $rr['desc'];
|
||||||
|
|
||||||
if ($type == "xml") {
|
if ($type == "xml") {
|
||||||
$data['photo'][] = array("@attributes" => $photo, "1" => $thumb);
|
$data['photo'][] = array("@attributes" => $photo, "1" => $thumb);
|
||||||
|
@ -3312,26 +3429,563 @@ $called_api = null;
|
||||||
return api_format_data("photos", $type, $data);
|
return api_format_data("photos", $type, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief upload a new photo or change an existing photo
|
||||||
|
*
|
||||||
|
* @param string $type Known types are 'atom', 'rss', 'xml' and 'json'
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function api_fr_photo_create_update($type) {
|
||||||
|
if (api_user() === false) {
|
||||||
|
throw new ForbiddenException();
|
||||||
|
}
|
||||||
|
// input params
|
||||||
|
$photo_id = (x($_REQUEST, 'photo_id') ? $_REQUEST['photo_id'] : null);
|
||||||
|
$desc = (x($_REQUEST, 'desc') ? $_REQUEST['desc'] : (array_key_exists('desc', $_REQUEST) ? "" : null)); // extra check necessary to distinguish between 'not provided' and 'empty string'
|
||||||
|
$album = (x($_REQUEST,'album') ? $_REQUEST['album'] : null);
|
||||||
|
$album_new = (x($_REQUEST,'album_new') ? $_REQUEST['album_new'] : null);
|
||||||
|
$allow_cid = (x($_REQUEST, 'allow_cid') ? $_REQUEST['allow_cid'] : (array_key_exists('allow_cid', $_REQUEST) ? " " : null));
|
||||||
|
$deny_cid = (x($_REQUEST, 'deny_cid') ? $_REQUEST['deny_cid'] : (array_key_exists('deny_cid', $_REQUEST) ? " " : null));
|
||||||
|
$allow_gid = (x($_REQUEST, 'allow_gid') ? $_REQUEST['allow_gid'] : (array_key_exists('allow_gid', $_REQUEST) ? " " : null));
|
||||||
|
$deny_gid = (x($_REQUEST, 'deny_gid') ? $_REQUEST['deny_gid'] : (array_key_exists('deny_gid', $_REQUEST) ? " " : null));
|
||||||
|
$visibility = (x($_REQUEST, 'visibility') ? (($_REQUEST['visibility'] == "true" || $_REQUEST['visibility'] == 1) ? true : false) : false);
|
||||||
|
|
||||||
|
// do several checks on input parameters
|
||||||
|
// we do not allow calls without album string
|
||||||
|
if ($album == null) {
|
||||||
|
throw new BadRequestException("no albumname specified");
|
||||||
|
}
|
||||||
|
// if photo_id == null --> we are uploading a new photo
|
||||||
|
if ($photo_id == null) {
|
||||||
|
$mode = "create";
|
||||||
|
|
||||||
|
// error if no media posted in create-mode
|
||||||
|
if (!x($_FILES,'media')) {
|
||||||
|
// Output error
|
||||||
|
throw new BadRequestException("no media data submitted");
|
||||||
|
}
|
||||||
|
|
||||||
|
// album_new will be ignored in create-mode
|
||||||
|
$album_new = "";
|
||||||
|
} else {
|
||||||
|
$mode = "update";
|
||||||
|
|
||||||
|
// check if photo is existing in database
|
||||||
|
$r = q("SELECT `id` FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' AND `album` = '%s'",
|
||||||
|
intval(api_user()),
|
||||||
|
dbesc($photo_id),
|
||||||
|
dbesc($album));
|
||||||
|
if (!dbm::is_result($r)) {
|
||||||
|
throw new BadRequestException("photo not available");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// checks on acl strings provided by clients
|
||||||
|
$acl_input_error = false;
|
||||||
|
$acl_input_error |= check_acl_input($allow_cid);
|
||||||
|
$acl_input_error |= check_acl_input($deny_cid);
|
||||||
|
$acl_input_error |= check_acl_input($allow_gid);
|
||||||
|
$acl_input_error |= check_acl_input($deny_gid);
|
||||||
|
if ($acl_input_error) {
|
||||||
|
throw new BadRequestException("acl data invalid");
|
||||||
|
}
|
||||||
|
// now let's upload the new media in create-mode
|
||||||
|
if ($mode == "create") {
|
||||||
|
$media = $_FILES['media'];
|
||||||
|
$data = save_media_to_database("photo", $media, $type, $album, trim($allow_cid), trim($deny_cid), trim($allow_gid), trim($deny_gid), $desc, $visibility);
|
||||||
|
|
||||||
|
// return success of updating or error message
|
||||||
|
if (!is_null($data)) {
|
||||||
|
return api_format_data("photo_create", $type, $data);
|
||||||
|
} else {
|
||||||
|
throw new InternalServerErrorException("unknown error - uploading photo failed, see Friendica log for more information");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// now let's do the changes in update-mode
|
||||||
|
if ($mode == "update") {
|
||||||
|
$sql_extra = "";
|
||||||
|
|
||||||
|
if (!is_null($desc)) {
|
||||||
|
$sql_extra .= (($sql_extra != "") ? " ," : "") . "`desc` = '$desc'";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_null($album_new)) {
|
||||||
|
$sql_extra .= (($sql_extra != "") ? " ," : "") . "`album` = '$album_new'";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_null($allow_cid)) {
|
||||||
|
$allow_cid = trim($allow_cid);
|
||||||
|
$sql_extra .= (($sql_extra != "") ? " ," : "") . "`allow_cid` = '$allow_cid'";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_null($deny_cid)) {
|
||||||
|
$deny_cid = trim($deny_cid);
|
||||||
|
$sql_extra .= (($sql_extra != "") ? " ," : "") . "`deny_cid` = '$deny_cid'";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_null($allow_gid)) {
|
||||||
|
$allow_gid = trim($allow_gid);
|
||||||
|
$sql_extra .= (($sql_extra != "") ? " ," : "") . "`allow_gid` = '$allow_gid'";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_null($deny_gid)) {
|
||||||
|
$deny_gid = trim($deny_gid);
|
||||||
|
$sql_extra .= (($sql_extra != "") ? " ," : "") . "`deny_gid` = '$deny_gid'";
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = false;
|
||||||
|
if ($sql_extra != "") {
|
||||||
|
$nothingtodo = false;
|
||||||
|
$result = q("UPDATE `photo` SET %s, `edited`='%s' WHERE `uid` = %d AND `resource-id` = '%s' AND `album` = '%s'",
|
||||||
|
$sql_extra,
|
||||||
|
datetime_convert(), // update edited timestamp
|
||||||
|
intval(api_user()),
|
||||||
|
dbesc($photo_id),
|
||||||
|
dbesc($album));
|
||||||
|
} else {
|
||||||
|
$nothingtodo = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x($_FILES,'media')) {
|
||||||
|
$nothingtodo = false;
|
||||||
|
$media = $_FILES['media'];
|
||||||
|
$data = save_media_to_database("photo", $media, $type, $album, $allow_cid, $deny_cid, $allow_gid, $deny_gid, $desc, 0, $visibility, $photo_id);
|
||||||
|
if (!is_null($data)) {
|
||||||
|
return api_format_data("photo_update", $type, $data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// return success of updating or error message
|
||||||
|
if ($result) {
|
||||||
|
$answer = array('result' => 'updated', 'message' => 'Image id `' . $photo_id . '` has been updated.');
|
||||||
|
return api_format_data("photo_update", $type, array('$result' => $answer));
|
||||||
|
} else {
|
||||||
|
if ($nothingtodo) {
|
||||||
|
$answer = array('result' => 'cancelled', 'message' => 'Nothing to update for image id `' . $photo_id . '`.');
|
||||||
|
return api_format_data("photo_update", $type, array('$result' => $answer));
|
||||||
|
}
|
||||||
|
throw new InternalServerErrorException("unknown error - update photo entry in database failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new InternalServerErrorException("unknown error - this error on uploading or updating a photo should never happen");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief delete a single photo from the database through api
|
||||||
|
*
|
||||||
|
* @param string $type Known types are 'atom', 'rss', 'xml' and 'json'
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function api_fr_photo_delete($type) {
|
||||||
|
if (api_user() === false) {
|
||||||
|
throw new ForbiddenException();
|
||||||
|
}
|
||||||
|
// input params
|
||||||
|
$photo_id = (x($_REQUEST, 'photo_id') ? $_REQUEST['photo_id'] : null);
|
||||||
|
|
||||||
|
// do several checks on input parameters
|
||||||
|
// we do not allow calls without photo id
|
||||||
|
if ($photo_id == null) {
|
||||||
|
throw new BadRequestException("no photo_id specified");
|
||||||
|
}
|
||||||
|
// check if photo is existing in database
|
||||||
|
$r = q("SELECT `id` FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'",
|
||||||
|
intval(api_user()),
|
||||||
|
dbesc($photo_id)
|
||||||
|
);
|
||||||
|
if (!dbm::is_result($r)) {
|
||||||
|
throw new BadRequestException("photo not available");
|
||||||
|
}
|
||||||
|
// now we can perform on the deletion of the photo
|
||||||
|
$result = q("DELETE FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'",
|
||||||
|
intval(api_user()),
|
||||||
|
dbesc($photo_id));
|
||||||
|
|
||||||
|
// return success of deletion or error message
|
||||||
|
if ($result) {
|
||||||
|
// retrieve the id of the parent element (the photo element)
|
||||||
|
$photo_item = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `resource-id` = '%s' AND `type` = 'photo'",
|
||||||
|
intval(local_user()),
|
||||||
|
dbesc($photo_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!dbm::is_result($photo_item)) {
|
||||||
|
throw new InternalServerErrorException("problem with deleting items occured");
|
||||||
|
}
|
||||||
|
// function for setting the items to "deleted = 1" which ensures that comments, likes etc. are not shown anymore
|
||||||
|
// to the user and the contacts of the users (drop_items() do all the necessary magic to avoid orphans in database and federate deletion)
|
||||||
|
drop_item($photo_item[0]['id'], false);
|
||||||
|
|
||||||
|
$answer = array('result' => 'deleted', 'message' => 'photo with id `' . $photo_id . '` has been deleted from server.');
|
||||||
|
return api_format_data("photo_delete", $type, array('$result' => $answer));
|
||||||
|
} else {
|
||||||
|
throw new InternalServerErrorException("unknown error on deleting photo from database table");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief returns the details of a specified photo id, if scale is given, returns the photo data in base 64
|
||||||
|
*
|
||||||
|
* @param string $type Known types are 'atom', 'rss', 'xml' and 'json'
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function api_fr_photo_detail($type) {
|
function api_fr_photo_detail($type) {
|
||||||
if (api_user() === false) {
|
if (api_user() === false) {
|
||||||
throw new ForbiddenException();
|
throw new ForbiddenException();
|
||||||
} elseif (!x($_REQUEST, 'photo_id')) {
|
}
|
||||||
|
if (!x($_REQUEST, 'photo_id')) {
|
||||||
throw new BadRequestException("No photo id.");
|
throw new BadRequestException("No photo id.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$scale = (x($_REQUEST, 'scale') ? intval($_REQUEST['scale']) : false);
|
$scale = (x($_REQUEST, 'scale') ? intval($_REQUEST['scale']) : false);
|
||||||
$scale_sql = ($scale === false ? "" : sprintf("AND `scale`=%d",intval($scale)));
|
$photo_id = $_REQUEST['photo_id'];
|
||||||
$data_sql = ($scale === false ? "" : "ANY_VALUE(`data`) AS data`,");
|
|
||||||
|
|
||||||
$r = q("SELECT %s ANY_VALUE(`resource-id`) AS `resource-id`, ANY_VALUE(`created`) AS `created`,
|
// prepare json/xml output with data from database for the requested photo
|
||||||
ANY_VALUE(`edited`) AS `edited`, ANY_VALUE(`title`) AS `title`, ANY_VALUE(`desc`) AS `desc`,
|
$data = prepare_photo_data($type, $scale, $photo_id);
|
||||||
ANY_VALUE(`album`) AS `album`, ANY_VALUE(`filename`) AS `filename`, ANY_VALUE(`type`) AS `type`,
|
|
||||||
ANY_VALUE(`height`) AS `height`, ANY_VALUE(`width`) AS `width`, ANY_VALUE(`datasize`) AS `datasize`,
|
return api_format_data("photo_detail", $type, $data);
|
||||||
ANY_VALUE(`profile`) AS `profile`, min(`scale`) as minscale, max(`scale`) as maxscale
|
}
|
||||||
FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' %s",
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief updates the profile image for the user (either a specified profile or the default profile)
|
||||||
|
*
|
||||||
|
* @param string $type Known types are 'atom', 'rss', 'xml' and 'json'
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function api_account_update_profile_image($type) {
|
||||||
|
if (api_user() === false) {
|
||||||
|
throw new ForbiddenException();
|
||||||
|
}
|
||||||
|
// input params
|
||||||
|
$profileid = (x($_REQUEST, 'profile_id') ? $_REQUEST['profile_id'] : 0);
|
||||||
|
|
||||||
|
// error if image data is missing
|
||||||
|
if (!x($_FILES, 'image')) {
|
||||||
|
throw new BadRequestException("no media data submitted");
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if specified profile id is valid
|
||||||
|
if ($profileid != 0) {
|
||||||
|
$r = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `id` = %d",
|
||||||
|
intval(api_user()),
|
||||||
|
intval($profileid));
|
||||||
|
// error message if specified profile id is not in database
|
||||||
|
if (!dbm::is_result($r)) {
|
||||||
|
throw new BadRequestException("profile_id not available");
|
||||||
|
}
|
||||||
|
$is_default_profile = $r['profile'];
|
||||||
|
} else {
|
||||||
|
$is_default_profile = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get mediadata from image or media (Twitter call api/account/update_profile_image provides image)
|
||||||
|
$media = null;
|
||||||
|
if (x($_FILES, 'image')) {
|
||||||
|
$media = $_FILES['image'];
|
||||||
|
} elseif (x($_FILES, 'media')) {
|
||||||
|
$media = $_FILES['media'];
|
||||||
|
}
|
||||||
|
// save new profile image
|
||||||
|
$data = save_media_to_database("profileimage", $media, $type, t('Profile Photos'), "", "", "", "", "", $is_default_profile);
|
||||||
|
|
||||||
|
// get filetype
|
||||||
|
if (is_array($media['type'])) {
|
||||||
|
$filetype = $media['type'][0];
|
||||||
|
} else {
|
||||||
|
$filetype = $media['type'];
|
||||||
|
}
|
||||||
|
if ($filetype == "image/jpeg") {
|
||||||
|
$fileext = "jpg";
|
||||||
|
} elseif ($filetype == "image/png") {
|
||||||
|
$fileext = "png";
|
||||||
|
}
|
||||||
|
// change specified profile or all profiles to the new resource-id
|
||||||
|
if ($is_default_profile) {
|
||||||
|
$r = q("UPDATE `photo` SET `profile` = 0 WHERE `profile` = 1 AND `resource-id` != '%s' AND `uid` = %d",
|
||||||
|
dbesc($data['photo']['id']),
|
||||||
|
intval(local_user())
|
||||||
|
);
|
||||||
|
|
||||||
|
$r = q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `self` AND `uid` = %d",
|
||||||
|
dbesc(App::get_baseurl() . '/photo/' . $data['photo']['id'] . '-4.' . $fileext),
|
||||||
|
dbesc(App::get_baseurl() . '/photo/' . $data['photo']['id'] . '-5.' . $fileext),
|
||||||
|
dbesc(App::get_baseurl() . '/photo/' . $data['photo']['id'] . '-6.' . $fileext),
|
||||||
|
intval(local_user())
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$r = q("UPDATE `profile` SET `photo` = '%s', `thumb` = '%s' WHERE `id` = %d AND `uid` = %d",
|
||||||
|
dbesc(App::get_baseurl() . '/photo/' . $data['photo']['id'] . '-4.' . $filetype),
|
||||||
|
dbesc(App::get_baseurl() . '/photo/' . $data['photo']['id'] . '-5.' . $filetype),
|
||||||
|
intval($_REQUEST['profile']),
|
||||||
|
intval(local_user())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// we'll set the updated profile-photo timestamp even if it isn't the default profile,
|
||||||
|
// so that browsers will do a cache update unconditionally
|
||||||
|
|
||||||
|
$r = q("UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d",
|
||||||
|
dbesc(datetime_convert()),
|
||||||
|
intval(local_user())
|
||||||
|
);
|
||||||
|
|
||||||
|
// Update global directory in background
|
||||||
|
//$user = api_get_user(get_app());
|
||||||
|
$url = App::get_baseurl() . '/profile/' . get_app()->user['nickname'];
|
||||||
|
if ($url && strlen(get_config('system', 'directory'))) {
|
||||||
|
proc_run(PRIORITY_LOW, "include/directory.php", $url);
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once 'include/profile_update.php';
|
||||||
|
profile_change();
|
||||||
|
|
||||||
|
// output for client
|
||||||
|
if ($data) {
|
||||||
|
return api_account_verify_credentials($type);
|
||||||
|
} else {
|
||||||
|
// SaveMediaToDatabase failed for some reason
|
||||||
|
throw new InternalServerErrorException("image upload failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// place api-register for photoalbum calls before 'api/friendica/photo', otherwise this function is never reached
|
||||||
|
api_register_func('api/friendica/photoalbum/delete', 'api_fr_photoalbum_delete', true, API_METHOD_DELETE);
|
||||||
|
api_register_func('api/friendica/photoalbum/update', 'api_fr_photoalbum_update', true, API_METHOD_POST);
|
||||||
|
api_register_func('api/friendica/photos/list', 'api_fr_photos_list', true);
|
||||||
|
api_register_func('api/friendica/photo/create', 'api_fr_photo_create_update', true, API_METHOD_POST);
|
||||||
|
api_register_func('api/friendica/photo/update', 'api_fr_photo_create_update', true, API_METHOD_POST);
|
||||||
|
api_register_func('api/friendica/photo/delete', 'api_fr_photo_delete', true, API_METHOD_DELETE);
|
||||||
|
api_register_func('api/friendica/photo', 'api_fr_photo_detail', true);
|
||||||
|
api_register_func('api/account/update_profile_image', 'api_account_update_profile_image', true, API_METHOD_POST);
|
||||||
|
|
||||||
|
|
||||||
|
function check_acl_input($acl_string) {
|
||||||
|
if ($acl_string == null || $acl_string == " ") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$contact_not_found = false;
|
||||||
|
|
||||||
|
// split <x><y><z> into array of cid's
|
||||||
|
preg_match_all("/<[A-Za-z0-9]+>/", $acl_string, $array);
|
||||||
|
|
||||||
|
// check for each cid if it is available on server
|
||||||
|
$cid_array = $array[0];
|
||||||
|
foreach ($cid_array as $cid) {
|
||||||
|
$cid = str_replace("<", "", $cid);
|
||||||
|
$cid = str_replace(">", "", $cid);
|
||||||
|
$contact = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d",
|
||||||
|
intval($cid),
|
||||||
|
intval(api_user()));
|
||||||
|
$contact_not_found |= !dbm::is_result($contact);
|
||||||
|
}
|
||||||
|
return $contact_not_found;
|
||||||
|
}
|
||||||
|
|
||||||
|
function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $deny_cid, $allow_gid, $deny_gid, $desc, $profile = 0, $visibility = false, $photo_id = null) {
|
||||||
|
$visitor = 0;
|
||||||
|
$src = "";
|
||||||
|
$filetype = "";
|
||||||
|
$filename = "";
|
||||||
|
$filesize = 0;
|
||||||
|
|
||||||
|
if (is_array($media)) {
|
||||||
|
if (is_array($media['tmp_name'])) {
|
||||||
|
$src = $media['tmp_name'][0];
|
||||||
|
} else {
|
||||||
|
$src = $media['tmp_name'];
|
||||||
|
}
|
||||||
|
if (is_array($media['name'])) {
|
||||||
|
$filename = basename($media['name'][0]);
|
||||||
|
} else {
|
||||||
|
$filename = basename($media['name']);
|
||||||
|
}
|
||||||
|
if (is_array($media['size'])) {
|
||||||
|
$filesize = intval($media['size'][0]);
|
||||||
|
} else {
|
||||||
|
$filesize = intval($media['size']);
|
||||||
|
}
|
||||||
|
if (is_array($media['type'])) {
|
||||||
|
$filetype = $media['type'][0];
|
||||||
|
} else {
|
||||||
|
$filetype = $media['type'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($filetype == "") {
|
||||||
|
$filetype=guess_image_type($filename);
|
||||||
|
}
|
||||||
|
$imagedata = getimagesize($src);
|
||||||
|
if ($imagedata) {
|
||||||
|
$filetype = $imagedata['mime'];
|
||||||
|
}
|
||||||
|
logger("File upload src: " . $src . " - filename: " . $filename .
|
||||||
|
" - size: " . $filesize . " - type: " . $filetype, LOGGER_DEBUG);
|
||||||
|
|
||||||
|
// check if there was a php upload error
|
||||||
|
if ($filesize == 0 && $media['error'] == 1) {
|
||||||
|
throw new InternalServerErrorException("image size exceeds PHP config settings, file was rejected by server");
|
||||||
|
}
|
||||||
|
// check against max upload size within Friendica instance
|
||||||
|
$maximagesize = get_config('system', 'maximagesize');
|
||||||
|
if (($maximagesize) && ($filesize > $maximagesize)) {
|
||||||
|
$formattedBytes = formatBytes($maximagesize);
|
||||||
|
throw new InternalServerErrorException("image size exceeds Friendica config setting (uploaded size: $formattedBytes)");
|
||||||
|
}
|
||||||
|
|
||||||
|
// create Photo instance with the data of the image
|
||||||
|
$imagedata = @file_get_contents($src);
|
||||||
|
$ph = new Photo($imagedata, $filetype);
|
||||||
|
if (! $ph->is_valid()) {
|
||||||
|
throw new InternalServerErrorException("unable to process image data");
|
||||||
|
}
|
||||||
|
|
||||||
|
// check orientation of image
|
||||||
|
$ph->orient($src);
|
||||||
|
@unlink($src);
|
||||||
|
|
||||||
|
// check max length of images on server
|
||||||
|
$max_length = get_config('system', 'max_image_length');
|
||||||
|
if (! $max_length) {
|
||||||
|
$max_length = MAX_IMAGE_LENGTH;
|
||||||
|
}
|
||||||
|
if ($max_length > 0) {
|
||||||
|
$ph->scaleImage($max_length);
|
||||||
|
logger("File upload: Scaling picture to new size " . $max_length, LOGGER_DEBUG);
|
||||||
|
}
|
||||||
|
$width = $ph->getWidth();
|
||||||
|
$height = $ph->getHeight();
|
||||||
|
|
||||||
|
// create a new resource-id if not already provided
|
||||||
|
$hash = ($photo_id == null) ? photo_new_resource() : $photo_id;
|
||||||
|
|
||||||
|
if ($mediatype == "photo") {
|
||||||
|
// upload normal image (scales 0, 1, 2)
|
||||||
|
logger("photo upload: starting new photo upload", LOGGER_DEBUG);
|
||||||
|
|
||||||
|
$r =$ph->store(local_user(), $visitor, $hash, $filename, $album, 0, 0, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
|
||||||
|
if (! $r) {
|
||||||
|
logger("photo upload: image upload with scale 0 (original size) failed");
|
||||||
|
}
|
||||||
|
if($width > 640 || $height > 640) {
|
||||||
|
$ph->scaleImage(640);
|
||||||
|
$r = $ph->store(local_user(),$visitor, $hash, $filename, $album, 1, 0, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
|
||||||
|
if (! $r) {
|
||||||
|
logger("photo upload: image upload with scale 1 (640x640) failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($width > 320 || $height > 320) {
|
||||||
|
$ph->scaleImage(320);
|
||||||
|
$r = $ph->store(local_user(), $visitor, $hash, $filename, $album, 2, 0, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
|
||||||
|
if (! $r) {
|
||||||
|
logger("photo upload: image upload with scale 2 (320x320) failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger("photo upload: new photo upload ended", LOGGER_DEBUG);
|
||||||
|
} elseif ($mediatype == "profileimage") {
|
||||||
|
// upload profile image (scales 4, 5, 6)
|
||||||
|
logger("photo upload: starting new profile image upload", LOGGER_DEBUG);
|
||||||
|
|
||||||
|
if ($width > 175 || $height > 175) {
|
||||||
|
$ph->scaleImage(175);
|
||||||
|
$r = $ph->store(local_user(),$visitor, $hash, $filename, $album, 4, $profile, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
|
||||||
|
if (! $r) {
|
||||||
|
logger("photo upload: profile image upload with scale 4 (175x175) failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($width > 80 || $height > 80) {
|
||||||
|
$ph->scaleImage(80);
|
||||||
|
$r = $ph->store(local_user(),$visitor, $hash, $filename, $album, 5, $profile, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
|
||||||
|
if (! $r) {
|
||||||
|
logger("photo upload: profile image upload with scale 5 (80x80) failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($width > 48 || $height > 48) {
|
||||||
|
$ph->scaleImage(48);
|
||||||
|
$r = $ph->store(local_user(), $visitor, $hash, $filename, $album, 6, $profile, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
|
||||||
|
if (! $r) {
|
||||||
|
logger("photo upload: profile image upload with scale 6 (48x48) failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$ph->__destruct();
|
||||||
|
logger("photo upload: new profile image upload ended", LOGGER_DEBUG);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($r) {
|
||||||
|
// create entry in 'item'-table on new uploads to enable users to comment/like/dislike the photo
|
||||||
|
if ($photo_id == null && $mediatype == "photo") {
|
||||||
|
post_photo_item($hash, $allow_cid, $deny_cid, $allow_gid, $deny_gid, $filetype, $visibility);
|
||||||
|
}
|
||||||
|
// on success return image data in json/xml format (like /api/friendica/photo does when no scale is given)
|
||||||
|
return prepare_photo_data($type, false, $hash);
|
||||||
|
} else {
|
||||||
|
throw new InternalServerErrorException("image upload failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function post_photo_item($hash, $allow_cid, $deny_cid, $allow_gid, $deny_gid, $filetype, $visibility = false) {
|
||||||
|
// get data about the api authenticated user
|
||||||
|
$uri = item_new_uri(get_app()->get_hostname(), intval(api_user()));
|
||||||
|
$owner_record = q("SELECT * FROM `contact` WHERE `uid`= %d AND `self` LIMIT 1", intval(api_user()));
|
||||||
|
|
||||||
|
$arr = array();
|
||||||
|
$arr['guid'] = get_guid(32);
|
||||||
|
$arr['uid'] = intval(api_user());
|
||||||
|
$arr['uri'] = $uri;
|
||||||
|
$arr['parent-uri'] = $uri;
|
||||||
|
$arr['type'] = 'photo';
|
||||||
|
$arr['wall'] = 1;
|
||||||
|
$arr['resource-id'] = $hash;
|
||||||
|
$arr['contact-id'] = $owner_record[0]['id'];
|
||||||
|
$arr['owner-name'] = $owner_record[0]['name'];
|
||||||
|
$arr['owner-link'] = $owner_record[0]['url'];
|
||||||
|
$arr['owner-avatar'] = $owner_record[0]['thumb'];
|
||||||
|
$arr['author-name'] = $owner_record[0]['name'];
|
||||||
|
$arr['author-link'] = $owner_record[0]['url'];
|
||||||
|
$arr['author-avatar'] = $owner_record[0]['thumb'];
|
||||||
|
$arr['title'] = "";
|
||||||
|
$arr['allow_cid'] = $allow_cid;
|
||||||
|
$arr['allow_gid'] = $allow_gid;
|
||||||
|
$arr['deny_cid'] = $deny_cid;
|
||||||
|
$arr['deny_gid'] = $deny_gid;
|
||||||
|
$arr['last-child'] = 1;
|
||||||
|
$arr['visible'] = $visibility;
|
||||||
|
$arr['origin'] = 1;
|
||||||
|
|
||||||
|
$typetoext = array(
|
||||||
|
'image/jpeg' => 'jpg',
|
||||||
|
'image/png' => 'png',
|
||||||
|
'image/gif' => 'gif'
|
||||||
|
);
|
||||||
|
|
||||||
|
// adds link to the thumbnail scale photo
|
||||||
|
$arr['body'] = '[url=' . App::get_baseurl() . '/photos/' . $owner_record[0]['name'] . '/image/' . $hash . ']'
|
||||||
|
. '[img]' . App::get_baseurl() . '/photo/' . $hash . '-' . "2" . '.'. $typetoext[$filetype] . '[/img]'
|
||||||
|
. '[/url]';
|
||||||
|
|
||||||
|
// do the magic for storing the item in the database and trigger the federation to other contacts
|
||||||
|
item_store($arr);
|
||||||
|
}
|
||||||
|
|
||||||
|
function prepare_photo_data($type, $scale, $photo_id) {
|
||||||
|
$scale_sql = ($scale === false ? "" : sprintf("and scale=%d", intval($scale)));
|
||||||
|
$data_sql = ($scale === false ? "" : "data, ");
|
||||||
|
|
||||||
|
// added allow_cid, allow_gid, deny_cid, deny_gid to output as string like stored in database
|
||||||
|
// clients needs to convert this in their way for further processing
|
||||||
|
$r = q("SELECT %s `resource-id`, `created`, `edited`, `title`, `desc`, `album`, `filename`,
|
||||||
|
`type`, `height`, `width`, `datasize`, `profile`, `allow_cid`, `deny_cid`, `allow_gid`, `deny_gid`,
|
||||||
|
MIN(`scale`) AS `minscale`, MAX(`scale`) AS `maxscale`
|
||||||
|
FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' %s GROUP BY `resource-id`",
|
||||||
$data_sql,
|
$data_sql,
|
||||||
intval(local_user()),
|
intval(local_user()),
|
||||||
dbesc($_REQUEST['photo_id']),
|
dbesc($photo_id),
|
||||||
$scale_sql
|
$scale_sql
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -3341,6 +3995,7 @@ $called_api = null;
|
||||||
'image/gif' => 'gif'
|
'image/gif' => 'gif'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// prepare output data for photo
|
||||||
if (dbm::is_result($r)) {
|
if (dbm::is_result($r)) {
|
||||||
$data = array('photo' => $r[0]);
|
$data = array('photo' => $r[0]);
|
||||||
$data['photo']['id'] = $data['photo']['resource-id'];
|
$data['photo']['id'] = $data['photo']['resource-id'];
|
||||||
|
@ -3358,8 +4013,11 @@ $called_api = null;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$data['photo']['link'] = array();
|
$data['photo']['link'] = array();
|
||||||
|
// when we have profile images we could have only scales from 4 to 6, but index of array always needs to start with 0
|
||||||
|
$i = 0;
|
||||||
for ($k = intval($data['photo']['minscale']); $k <= intval($data['photo']['maxscale']); $k++) {
|
for ($k = intval($data['photo']['minscale']); $k <= intval($data['photo']['maxscale']); $k++) {
|
||||||
$data['photo']['link'][$k] = App::get_baseurl() . "/photo/" . $data['photo']['resource-id'] . "-" . $k . "." . $typetoext[$data['photo']['type']];
|
$data['photo']['link'][$i] = App::get_baseurl() . "/photo/" . $data['photo']['resource-id'] . "-" . $k . "." . $typetoext[$data['photo']['type']];
|
||||||
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($data['photo']['resource-id']);
|
unset($data['photo']['resource-id']);
|
||||||
|
@ -3370,12 +4028,53 @@ $called_api = null;
|
||||||
throw new NotFoundException();
|
throw new NotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
return api_format_data("photo_detail", $type, $data);
|
// retrieve item element for getting activities (like, dislike etc.) related to photo
|
||||||
|
$item = q("SELECT * FROM `item` WHERE `uid` = %d AND `resource-id` = '%s' AND `type` = 'photo'",
|
||||||
|
intval(local_user()),
|
||||||
|
dbesc($photo_id)
|
||||||
|
);
|
||||||
|
$data['photo']['friendica_activities'] = api_format_items_activities($item[0], $type);
|
||||||
|
|
||||||
|
// retrieve comments on photo
|
||||||
|
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
|
||||||
|
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
|
||||||
|
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
|
||||||
|
`contact`.`id` AS `cid`
|
||||||
|
FROM `item`
|
||||||
|
STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid`
|
||||||
|
AND (NOT `contact`.`blocked` OR `contact`.`pending`)
|
||||||
|
WHERE `item`.`parent` = %d AND `item`.`visible`
|
||||||
|
AND NOT `item`.`moderated` AND NOT `item`.`deleted`
|
||||||
|
AND `item`.`uid` = %d AND (`item`.`verb`='%s' OR `type`='photo')",
|
||||||
|
intval($item[0]['parent']),
|
||||||
|
intval(api_user()),
|
||||||
|
dbesc(ACTIVITY_POST)
|
||||||
|
);
|
||||||
|
|
||||||
|
// prepare output of comments
|
||||||
|
$commentData = api_format_items($r, api_get_user(get_app()), false, $type);
|
||||||
|
$comments = array();
|
||||||
|
if ($type == "xml") {
|
||||||
|
$k = 0;
|
||||||
|
foreach ($commentData as $comment) {
|
||||||
|
$comments[$k++ . ":comment"] = $comment;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
foreach ($commentData as $comment) {
|
||||||
|
$comments[] = $comment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$data['photo']['friendica_comments'] = $comments;
|
||||||
|
|
||||||
api_register_func('api/friendica/photos/list', 'api_fr_photos_list', true);
|
// include info if rights on photo and rights on item are mismatching
|
||||||
api_register_func('api/friendica/photo', 'api_fr_photo_detail', true);
|
$rights_mismatch = $data['photo']['allow_cid'] != $item[0]['allow_cid'] ||
|
||||||
|
$data['photo']['deny_cid'] != $item[0]['deny_cid'] ||
|
||||||
|
$data['photo']['allow_gid'] != $item[0]['allow_gid'] ||
|
||||||
|
$data['photo']['deny_cid'] != $item[0]['deny_cid'];
|
||||||
|
$data['photo']['rights_mismatch'] = $rights_mismatch;
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4299,7 +4998,6 @@ friendships/exists
|
||||||
friendships/show
|
friendships/show
|
||||||
account/update_location
|
account/update_location
|
||||||
account/update_profile_background_image
|
account/update_profile_background_image
|
||||||
account/update_profile_image
|
|
||||||
blocks/create
|
blocks/create
|
||||||
blocks/destroy
|
blocks/destroy
|
||||||
friendica/profile/update
|
friendica/profile/update
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\App;
|
||||||
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
require_once('include/security.php');
|
require_once('include/security.php');
|
||||||
require_once('include/datetime.php');
|
require_once('include/datetime.php');
|
||||||
|
|
|
@ -32,6 +32,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
|
||||||
if (sizeof($_SERVER["argv"]) == 0)
|
if (sizeof($_SERVER["argv"]) == 0)
|
||||||
die();
|
die();
|
||||||
|
|
||||||
|
@ -47,8 +49,9 @@ require_once("boot.php");
|
||||||
|
|
||||||
global $a, $db;
|
global $a, $db;
|
||||||
|
|
||||||
if (is_null($a))
|
if (is_null($a)) {
|
||||||
$a = new App;
|
$a = new App(dirname(__DIR__));
|
||||||
|
}
|
||||||
|
|
||||||
if (is_null($db)) {
|
if (is_null($db)) {
|
||||||
@include(".htconfig.php");
|
@include(".htconfig.php");
|
||||||
|
@ -332,4 +335,3 @@ class exAuth {
|
||||||
fclose($this->rLogFile);
|
fclose($this->rLogFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
use Friendica\Network\Probe;
|
||||||
|
|
||||||
use League\HTMLToMarkdown\HtmlConverter;
|
use League\HTMLToMarkdown\HtmlConverter;
|
||||||
|
|
||||||
require_once "include/oembed.php";
|
require_once 'include/oembed.php';
|
||||||
require_once "include/event.php";
|
require_once 'include/event.php';
|
||||||
require_once "library/markdown.php";
|
require_once 'library/markdown.php';
|
||||||
require_once "include/html2bbcode.php";
|
require_once 'include/html2bbcode.php';
|
||||||
require_once "include/bbcode.php";
|
require_once 'include/bbcode.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Callback function to replace a Diaspora style mention in a mention for Friendica
|
* @brief Callback function to replace a Diaspora style mention in a mention for Friendica
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
use \Friendica\Core\Config;
|
|
||||||
|
use Friendica\App;
|
||||||
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
require_once 'include/oembed.php';
|
require_once 'include/oembed.php';
|
||||||
require_once 'include/event.php';
|
require_once 'include/event.php';
|
||||||
|
@ -53,18 +55,7 @@ function bb_attachment($Text, $simplehtml = false, $tryoembed = true) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($simplehtml == 7) {
|
if ($simplehtml == 7) {
|
||||||
$title2 = $data["title"];
|
$text = style_url_for_mastodon($data["url"]);
|
||||||
|
|
||||||
$test1 = trim(html_entity_decode($data["text"],ENT_QUOTES,'UTF-8'));
|
|
||||||
$test2 = trim(html_entity_decode($data["title"],ENT_QUOTES,'UTF-8'));
|
|
||||||
|
|
||||||
// If the link description is similar to the text above then don't add the link description
|
|
||||||
if (($data["title"] != "") AND ((strpos($test1,$test2) !== false) OR
|
|
||||||
(similar_text($test1,$test2) / strlen($data["title"])) > 0.9)) {
|
|
||||||
$title2 = $data["url"];
|
|
||||||
}
|
|
||||||
$text = sprintf('<a href="%s" title="%s" class="attachment" rel="nofollow external">%s</a><br />',
|
|
||||||
$data["url"], $data["title"], $title2);
|
|
||||||
} elseif (($simplehtml != 4) AND ($simplehtml != 0)) {
|
} elseif (($simplehtml != 4) AND ($simplehtml != 0)) {
|
||||||
$text = sprintf('<a href="%s" target="_blank">%s</a><br>', $data["url"], $data["title"]);
|
$text = sprintf('<a href="%s" target="_blank">%s</a><br>', $data["url"], $data["title"]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -168,6 +159,54 @@ function cleancss($input) {
|
||||||
return $cleaned;
|
return $cleaned;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Converts [url] BBCodes in a format that looks fine on Mastodon. (callback function)
|
||||||
|
* @param array $match Array with the matching values
|
||||||
|
* @return string reformatted link including HTML codes
|
||||||
|
*/
|
||||||
|
function bb_style_url($match) {
|
||||||
|
$url = $match[1];
|
||||||
|
|
||||||
|
if (isset($match[2]) AND ($match[1] != $match[2])) {
|
||||||
|
return $match[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
$parts = parse_url($url);
|
||||||
|
if (!isset($parts['scheme'])) {
|
||||||
|
return $match[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return style_url_for_mastodon($url);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Converts [url] BBCodes in a format that looks fine on Mastodon and GNU Social.
|
||||||
|
* @param string $url URL that is about to be reformatted
|
||||||
|
* @return string reformatted link including HTML codes
|
||||||
|
*/
|
||||||
|
function style_url_for_mastodon($url) {
|
||||||
|
$styled_url = $url;
|
||||||
|
|
||||||
|
$parts = parse_url($url);
|
||||||
|
$scheme = $parts['scheme'].'://';
|
||||||
|
$styled_url = str_replace($scheme, '', $styled_url);
|
||||||
|
|
||||||
|
$html = '<a href="%s" class="attachment" rel="nofollow noopener" target="_blank">'.
|
||||||
|
'<span class="invisible">%s</span>';
|
||||||
|
|
||||||
|
if (strlen($styled_url) > 30) {
|
||||||
|
$html .= '<span class="ellipsis">%s</span>'.
|
||||||
|
'<span class="invisible">%s</span></a>';
|
||||||
|
|
||||||
|
$ellipsis = substr($styled_url, 0, 30);
|
||||||
|
$rest = substr($styled_url, 30);
|
||||||
|
return sprintf($html, $url, $scheme, $ellipsis, $rest);
|
||||||
|
} else {
|
||||||
|
$html .= '%s</a>';
|
||||||
|
return sprintf($html, $url, $scheme, $styled_url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function stripcode_br_cb($s) {
|
function stripcode_br_cb($s) {
|
||||||
return '[code]' . str_replace('<br />', '', $s[1]) . '[/code]';
|
return '[code]' . str_replace('<br />', '', $s[1]) . '[/code]';
|
||||||
}
|
}
|
||||||
|
@ -940,7 +979,14 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
|
||||||
// if the HTML is used to generate plain text, then don't do this search, but replace all URL of that kind to text
|
// if the HTML is used to generate plain text, then don't do this search, but replace all URL of that kind to text
|
||||||
// if ($simplehtml != 7) {
|
// if ($simplehtml != 7) {
|
||||||
if (!$forplaintext) {
|
if (!$forplaintext) {
|
||||||
|
if ($simplehtml != 7) {
|
||||||
$Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1<a href="$2" target="_blank">$2</a>', $Text);
|
$Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1<a href="$2" target="_blank">$2</a>', $Text);
|
||||||
|
} else {
|
||||||
|
$Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url]$2[/url]', $Text);
|
||||||
|
|
||||||
|
$Text = preg_replace_callback("/\[url\]([$URLSearchString]*)\[\/url\]/ism", 'bb_style_url', $Text);
|
||||||
|
$Text = preg_replace_callback("/\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[\/url\]/ism", 'bb_style_url', $Text);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$Text = preg_replace("(\[url\]([$URLSearchString]*)\[\/url\])ism", " $1 ", $Text);
|
$Text = preg_replace("(\[url\]([$URLSearchString]*)\[\/url\])ism", " $1 ", $Text);
|
||||||
$Text = preg_replace_callback("&\[url=([^\[\]]*)\]\[img\](.*)\[\/img\]\[\/url\]&Usi", 'bb_RemovePictureLinks', $Text);
|
$Text = preg_replace_callback("&\[url=([^\[\]]*)\]\[img\](.*)\[\/img\]\[\/url\]&Usi", 'bb_RemovePictureLinks', $Text);
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
* @brief Class for storing data for a short time
|
* @brief Class for storing data for a short time
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use \Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
|
|
||||||
class Cache {
|
class Cache {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php /** @file */
|
<?php /** @file */
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\App;
|
||||||
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
require_once('boot.php');
|
require_once('boot.php');
|
||||||
|
|
||||||
|
@ -11,7 +12,7 @@ function cli_startup() {
|
||||||
global $a, $db;
|
global $a, $db;
|
||||||
|
|
||||||
if (is_null($a)) {
|
if (is_null($a)) {
|
||||||
$a = new App;
|
$a = new App(dirname(__DIR__));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($db)) {
|
if (is_null($db)) {
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
* configurations need to be fixed as of 10/08/2011.
|
* configurations need to be fixed as of 10/08/2011.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use \Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief (Deprecated) Loads all configuration values of family into a cached storage.
|
* @brief (Deprecated) Loads all configuration values of family into a cached storage.
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
|
||||||
function follow_widget($value = "") {
|
function follow_widget($value = "") {
|
||||||
|
|
||||||
return replace_macros(get_markup_template('follow.tpl'), array(
|
return replace_macros(get_markup_template('follow.tpl'), array(
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
|
||||||
require_once "include/bbcode.php";
|
require_once "include/bbcode.php";
|
||||||
require_once "include/acl_selectors.php";
|
require_once "include/acl_selectors.php";
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note: the code in 'item_extract_images' and 'item_redir_and_replace_images'
|
* Note: the code in 'item_extract_images' and 'item_redir_and_replace_images'
|
||||||
* is identical to the code in mod/message.php for 'item_extract_images' and
|
* is identical to the code in mod/message.php for 'item_extract_images' and
|
||||||
|
|
|
@ -17,4 +17,3 @@ function create_shadowentry_run($argv, $argc) {
|
||||||
|
|
||||||
add_shadow_entry($message_id);
|
add_shadow_entry($message_id);
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
use \Friendica\Core\Config;
|
|
||||||
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
function cron_run(&$argv, &$argc){
|
function cron_run(&$argv, &$argc){
|
||||||
global $a;
|
global $a;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
function cronhooks_run(&$argv, &$argc) {
|
function cronhooks_run(&$argv, &$argc) {
|
||||||
global $a;
|
global $a;
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
<?php
|
<?php
|
||||||
use \Friendica\Core\Config;
|
|
||||||
|
use Friendica\App;
|
||||||
|
use Friendica\Core\Config;
|
||||||
|
use Friendica\Network\Probe;
|
||||||
|
|
||||||
function cronjobs_run(&$argv, &$argc){
|
function cronjobs_run(&$argv, &$argc){
|
||||||
global $a;
|
global $a;
|
||||||
|
|
||||||
require_once('include/datetime.php');
|
require_once 'include/datetime.php';
|
||||||
require_once('include/ostatus.php');
|
require_once 'include/ostatus.php';
|
||||||
require_once('include/post_update.php');
|
require_once 'include/post_update.php';
|
||||||
require_once('mod/nodeinfo.php');
|
require_once 'mod/nodeinfo.php';
|
||||||
require_once('include/photos.php');
|
require_once 'include/photos.php';
|
||||||
require_once('include/user.php');
|
require_once 'include/user.php';
|
||||||
require_once('include/socgraph.php');
|
require_once 'include/socgraph.php';
|
||||||
require_once('include/Probe.php');
|
|
||||||
|
|
||||||
// No parameter set? So return
|
// No parameter set? So return
|
||||||
if ($argc <= 1) {
|
if ($argc <= 1) {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* @brief Some functions for date and time related tasks.
|
* @brief Some functions for date and time related tasks.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Two-level sort for timezones.
|
* @brief Two-level sort for timezones.
|
||||||
|
|
738
include/dba.php
738
include/dba.php
|
@ -10,6 +10,7 @@ require_once('include/datetime.php');
|
||||||
* When logging, all binary info is converted to text and html entities are escaped so that
|
* When logging, all binary info is converted to text and html entities are escaped so that
|
||||||
* the debugging stream is safe to view within both terminals and web pages.
|
* the debugging stream is safe to view within both terminals and web pages.
|
||||||
*
|
*
|
||||||
|
* This class is for the low level database stuff that does driver specific things.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class dba {
|
class dba {
|
||||||
|
@ -21,12 +22,23 @@ class dba {
|
||||||
public $connected = false;
|
public $connected = false;
|
||||||
public $error = false;
|
public $error = false;
|
||||||
private $_server_info = '';
|
private $_server_info = '';
|
||||||
|
private static $dbo;
|
||||||
|
private static $relation = array();
|
||||||
|
|
||||||
function __construct($server, $user, $pass, $db, $install = false) {
|
function __construct($serveraddr, $user, $pass, $db, $install = false) {
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
$stamp1 = microtime(true);
|
$stamp1 = microtime(true);
|
||||||
|
|
||||||
|
$serveraddr = trim($serveraddr);
|
||||||
|
|
||||||
|
$serverdata = explode(':', $serveraddr);
|
||||||
|
$server = $serverdata[0];
|
||||||
|
|
||||||
|
if (count($serverdata) > 1) {
|
||||||
|
$port = trim($serverdata[1]);
|
||||||
|
}
|
||||||
|
|
||||||
$server = trim($server);
|
$server = trim($server);
|
||||||
$user = trim($user);
|
$user = trim($user);
|
||||||
$pass = trim($pass);
|
$pass = trim($pass);
|
||||||
|
@ -52,6 +64,11 @@ class dba {
|
||||||
if (class_exists('\PDO') && in_array('mysql', PDO::getAvailableDrivers())) {
|
if (class_exists('\PDO') && in_array('mysql', PDO::getAvailableDrivers())) {
|
||||||
$this->driver = 'pdo';
|
$this->driver = 'pdo';
|
||||||
$connect = "mysql:host=".$server.";dbname=".$db;
|
$connect = "mysql:host=".$server.";dbname=".$db;
|
||||||
|
|
||||||
|
if (isset($port)) {
|
||||||
|
$connect .= ";port=".$port;
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($a->config["system"]["db_charset"])) {
|
if (isset($a->config["system"]["db_charset"])) {
|
||||||
$connect .= ";charset=".$a->config["system"]["db_charset"];
|
$connect .= ";charset=".$a->config["system"]["db_charset"];
|
||||||
}
|
}
|
||||||
|
@ -61,7 +78,7 @@ class dba {
|
||||||
}
|
}
|
||||||
} elseif (class_exists('mysqli')) {
|
} elseif (class_exists('mysqli')) {
|
||||||
$this->driver = 'mysqli';
|
$this->driver = 'mysqli';
|
||||||
$this->db = @new mysqli($server,$user,$pass,$db);
|
$this->db = @new mysqli($server, $user, $pass, $db, $port);
|
||||||
if (!mysqli_connect_errno()) {
|
if (!mysqli_connect_errno()) {
|
||||||
$this->connected = true;
|
$this->connected = true;
|
||||||
|
|
||||||
|
@ -71,8 +88,8 @@ class dba {
|
||||||
}
|
}
|
||||||
} elseif (function_exists('mysql_connect')) {
|
} elseif (function_exists('mysql_connect')) {
|
||||||
$this->driver = 'mysql';
|
$this->driver = 'mysql';
|
||||||
$this->db = mysql_connect($server,$user,$pass);
|
$this->db = mysql_connect($serveraddr, $user, $pass);
|
||||||
if ($this->db && mysql_select_db($db,$this->db)) {
|
if ($this->db && mysql_select_db($db, $this->db)) {
|
||||||
$this->connected = true;
|
$this->connected = true;
|
||||||
|
|
||||||
if (isset($a->config["system"]["db_charset"])) {
|
if (isset($a->config["system"]["db_charset"])) {
|
||||||
|
@ -93,6 +110,8 @@ class dba {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$a->save_timestamp($stamp1, "network");
|
$a->save_timestamp($stamp1, "network");
|
||||||
|
|
||||||
|
self::$dbo = $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,30 +150,6 @@ class dba {
|
||||||
return $r[0]['db'];
|
return $r[0]['db'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Returns the number of rows
|
|
||||||
*
|
|
||||||
* @return integer
|
|
||||||
*/
|
|
||||||
public function num_rows() {
|
|
||||||
if (!$this->result) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ($this->driver) {
|
|
||||||
case 'pdo':
|
|
||||||
$rows = $this->result->rowCount();
|
|
||||||
break;
|
|
||||||
case 'mysqli':
|
|
||||||
$rows = $this->result->num_rows;
|
|
||||||
break;
|
|
||||||
case 'mysql':
|
|
||||||
$rows = mysql_num_rows($this->result);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return $rows;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Analyze a database query and log this if some conditions are met.
|
* @brief Analyze a database query and log this if some conditions are met.
|
||||||
*
|
*
|
||||||
|
@ -249,7 +244,7 @@ class dba {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$stamp2 = microtime(true);
|
$stamp2 = microtime(true);
|
||||||
$duration = (float)($stamp2-$stamp1);
|
$duration = (float)($stamp2 - $stamp1);
|
||||||
|
|
||||||
$a->save_timestamp($stamp1, "database");
|
$a->save_timestamp($stamp1, "database");
|
||||||
|
|
||||||
|
@ -379,41 +374,6 @@ class dba {
|
||||||
return($r);
|
return($r);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function qfetch() {
|
|
||||||
$x = false;
|
|
||||||
|
|
||||||
if ($this->result) {
|
|
||||||
switch ($this->driver) {
|
|
||||||
case 'pdo':
|
|
||||||
$x = $this->result->fetch(PDO::FETCH_ASSOC);
|
|
||||||
break;
|
|
||||||
case 'mysqli':
|
|
||||||
$x = $this->result->fetch_array(MYSQLI_ASSOC);
|
|
||||||
break;
|
|
||||||
case 'mysql':
|
|
||||||
$x = mysql_fetch_array($this->result, MYSQL_ASSOC);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return($x);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function qclose() {
|
|
||||||
if ($this->result) {
|
|
||||||
switch ($this->driver) {
|
|
||||||
case 'pdo':
|
|
||||||
$this->result->closeCursor();
|
|
||||||
break;
|
|
||||||
case 'mysqli':
|
|
||||||
$this->result->free_result();
|
|
||||||
break;
|
|
||||||
case 'mysql':
|
|
||||||
mysql_free_result($this->result);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function dbg($dbg) {
|
public function dbg($dbg) {
|
||||||
$this->debug = $dbg;
|
$this->debug = $dbg;
|
||||||
}
|
}
|
||||||
|
@ -497,6 +457,656 @@ class dba {
|
||||||
}
|
}
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Replaces the ? placeholders with the parameters in the $args array
|
||||||
|
*
|
||||||
|
* @param string $sql SQL query
|
||||||
|
* @param array $args The parameters that are to replace the ? placeholders
|
||||||
|
* @return string The replaced SQL query
|
||||||
|
*/
|
||||||
|
static private function replace_parameters($sql, $args) {
|
||||||
|
$offset = 0;
|
||||||
|
foreach ($args AS $param => $value) {
|
||||||
|
if (is_int($args[$param]) OR is_float($args[$param])) {
|
||||||
|
$replace = intval($args[$param]);
|
||||||
|
} else {
|
||||||
|
$replace = "'".self::$dbo->escape($args[$param])."'";
|
||||||
|
}
|
||||||
|
|
||||||
|
$pos = strpos($sql, '?', $offset);
|
||||||
|
if ($pos !== false) {
|
||||||
|
$sql = substr_replace($sql, $replace, $pos, 1);
|
||||||
|
}
|
||||||
|
$offset = $pos + strlen($replace);
|
||||||
|
}
|
||||||
|
return $sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Executes a prepared statement that returns data
|
||||||
|
* @usage Example: $r = p("SELECT * FROM `item` WHERE `guid` = ?", $guid);
|
||||||
|
* @param string $sql SQL statement
|
||||||
|
* @return object statement object
|
||||||
|
*/
|
||||||
|
static public function p($sql) {
|
||||||
|
$a = get_app();
|
||||||
|
|
||||||
|
$stamp1 = microtime(true);
|
||||||
|
|
||||||
|
$args = func_get_args();
|
||||||
|
unset($args[0]);
|
||||||
|
|
||||||
|
// When the second function parameter is an array then use this as the parameter array
|
||||||
|
if ((count($args) > 0) AND (is_array($args[1]))) {
|
||||||
|
$params = $args[1];
|
||||||
|
} else {
|
||||||
|
$params = $args;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Renumber the array keys to be sure that they fit
|
||||||
|
$i = 0;
|
||||||
|
$args = array();
|
||||||
|
foreach ($params AS $param) {
|
||||||
|
$args[++$i] = $param;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!self::$dbo OR !self::$dbo->connected) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (substr_count($sql, '?') != count($args)) {
|
||||||
|
// Question: Should we continue or stop the query here?
|
||||||
|
logger('Parameter mismatch. Query "'.$sql.'" - Parameters '.print_r($args, true), LOGGER_DEBUG);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = self::$dbo->any_value_fallback($sql);
|
||||||
|
|
||||||
|
if (x($a->config,'system') && x($a->config['system'], 'db_callstack')) {
|
||||||
|
$sql = "/*".$a->callstack()." */ ".$sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
self::$dbo->error = '';
|
||||||
|
self::$dbo->errorno = 0;
|
||||||
|
|
||||||
|
switch (self::$dbo->driver) {
|
||||||
|
case 'pdo':
|
||||||
|
if (!$stmt = self::$dbo->db->prepare($sql)) {
|
||||||
|
$errorInfo = self::$dbo->db->errorInfo();
|
||||||
|
self::$dbo->error = $errorInfo[2];
|
||||||
|
self::$dbo->errorno = $errorInfo[1];
|
||||||
|
$retval = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($args AS $param => $value) {
|
||||||
|
$stmt->bindParam($param, $args[$param]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$stmt->execute()) {
|
||||||
|
$errorInfo = $stmt->errorInfo();
|
||||||
|
self::$dbo->error = $errorInfo[2];
|
||||||
|
self::$dbo->errorno = $errorInfo[1];
|
||||||
|
$retval = false;
|
||||||
|
} else {
|
||||||
|
$retval = $stmt;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'mysqli':
|
||||||
|
$stmt = self::$dbo->db->stmt_init();
|
||||||
|
|
||||||
|
if (!$stmt->prepare($sql)) {
|
||||||
|
self::$dbo->error = $stmt->error;
|
||||||
|
self::$dbo->errorno = $stmt->errno;
|
||||||
|
$retval = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$params = '';
|
||||||
|
$values = array();
|
||||||
|
foreach ($args AS $param => $value) {
|
||||||
|
if (is_int($args[$param])) {
|
||||||
|
$params .= 'i';
|
||||||
|
} elseif (is_float($args[$param])) {
|
||||||
|
$params .= 'd';
|
||||||
|
} elseif (is_string($args[$param])) {
|
||||||
|
$params .= 's';
|
||||||
|
} else {
|
||||||
|
$params .= 'b';
|
||||||
|
}
|
||||||
|
$values[] = &$args[$param];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($values) > 0) {
|
||||||
|
array_unshift($values, $params);
|
||||||
|
call_user_func_array(array($stmt, 'bind_param'), $values);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$stmt->execute()) {
|
||||||
|
self::$dbo->error = self::$dbo->db->error;
|
||||||
|
self::$dbo->errorno = self::$dbo->db->errno;
|
||||||
|
$retval = false;
|
||||||
|
} else {
|
||||||
|
$stmt->store_result();
|
||||||
|
$retval = $stmt;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'mysql':
|
||||||
|
// For the old "mysql" functions we cannot use prepared statements
|
||||||
|
$retval = mysql_query(self::replace_parameters($sql, $args), self::$dbo->db);
|
||||||
|
if (mysql_errno(self::$dbo->db)) {
|
||||||
|
self::$dbo->error = mysql_error(self::$dbo->db);
|
||||||
|
self::$dbo->errorno = mysql_errno(self::$dbo->db);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self::$dbo->errorno != 0) {
|
||||||
|
logger('DB Error '.self::$dbo->errorno.': '.self::$dbo->error."\n".self::replace_parameters($sql, $args));
|
||||||
|
}
|
||||||
|
|
||||||
|
$a->save_timestamp($stamp1, 'database');
|
||||||
|
|
||||||
|
if (x($a->config,'system') && x($a->config['system'], 'db_log')) {
|
||||||
|
|
||||||
|
$stamp2 = microtime(true);
|
||||||
|
$duration = (float)($stamp2 - $stamp1);
|
||||||
|
|
||||||
|
if (($duration > $a->config["system"]["db_loglimit"])) {
|
||||||
|
$duration = round($duration, 3);
|
||||||
|
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||||
|
|
||||||
|
@file_put_contents($a->config["system"]["db_log"], datetime_convert()."\t".$duration."\t".
|
||||||
|
basename($backtrace[1]["file"])."\t".
|
||||||
|
$backtrace[1]["line"]."\t".$backtrace[2]["function"]."\t".
|
||||||
|
substr(self::replace_parameters($sql, $args), 0, 2000)."\n", FILE_APPEND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Executes a prepared statement like UPDATE or INSERT that doesn't return data
|
||||||
|
*
|
||||||
|
* @param string $sql SQL statement
|
||||||
|
* @return boolean Was the query successfull? False is returned only if an error occurred
|
||||||
|
*/
|
||||||
|
static public function e($sql) {
|
||||||
|
$a = get_app();
|
||||||
|
|
||||||
|
$stamp = microtime(true);
|
||||||
|
|
||||||
|
$args = func_get_args();
|
||||||
|
|
||||||
|
$stmt = call_user_func_array('self::p', $args);
|
||||||
|
|
||||||
|
if (is_bool($stmt)) {
|
||||||
|
$retval = $stmt;
|
||||||
|
} elseif (is_object($stmt)) {
|
||||||
|
$retval = true;
|
||||||
|
} else {
|
||||||
|
$retval = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
self::close($stmt);
|
||||||
|
|
||||||
|
$a->save_timestamp($stamp, "database_write");
|
||||||
|
|
||||||
|
return $retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if data exists
|
||||||
|
*
|
||||||
|
* @param string $sql SQL statement
|
||||||
|
* @return boolean Are there rows for that query?
|
||||||
|
*/
|
||||||
|
static public function exists($sql) {
|
||||||
|
$args = func_get_args();
|
||||||
|
|
||||||
|
$stmt = call_user_func_array('self::p', $args);
|
||||||
|
|
||||||
|
if (is_bool($stmt)) {
|
||||||
|
$retval = $stmt;
|
||||||
|
} else {
|
||||||
|
$retval = (self::num_rows($stmt) > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
self::close($stmt);
|
||||||
|
|
||||||
|
return $retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Fetches the first row
|
||||||
|
*
|
||||||
|
* @param string $sql SQL statement
|
||||||
|
* @return array first row of query
|
||||||
|
*/
|
||||||
|
static public function fetch_first($sql) {
|
||||||
|
$args = func_get_args();
|
||||||
|
|
||||||
|
$stmt = call_user_func_array('self::p', $args);
|
||||||
|
|
||||||
|
if (is_bool($stmt)) {
|
||||||
|
$retval = $stmt;
|
||||||
|
} else {
|
||||||
|
$retval = self::fetch($stmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
self::close($stmt);
|
||||||
|
|
||||||
|
return $retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the number of rows of a statement
|
||||||
|
*
|
||||||
|
* @param object Statement object
|
||||||
|
* @return int Number of rows
|
||||||
|
*/
|
||||||
|
static public function num_rows($stmt) {
|
||||||
|
switch (self::$dbo->driver) {
|
||||||
|
case 'pdo':
|
||||||
|
return $stmt->rowCount();
|
||||||
|
case 'mysqli':
|
||||||
|
return $stmt->num_rows;
|
||||||
|
case 'mysql':
|
||||||
|
return mysql_num_rows($stmt);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Fetch a single row
|
||||||
|
*
|
||||||
|
* @param object $stmt statement object
|
||||||
|
* @return array current row
|
||||||
|
*/
|
||||||
|
static public function fetch($stmt) {
|
||||||
|
if (!is_object($stmt)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (self::$dbo->driver) {
|
||||||
|
case 'pdo':
|
||||||
|
return $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
case 'mysqli':
|
||||||
|
// This code works, but is slow
|
||||||
|
|
||||||
|
// Bind the result to a result array
|
||||||
|
$cols = array();
|
||||||
|
|
||||||
|
$cols_num = array();
|
||||||
|
for ($x = 0; $x < $stmt->field_count; $x++) {
|
||||||
|
$cols[] = &$cols_num[$x];
|
||||||
|
}
|
||||||
|
|
||||||
|
call_user_func_array(array($stmt, 'bind_result'), $cols);
|
||||||
|
|
||||||
|
if (!$stmt->fetch()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The slow part:
|
||||||
|
// We need to get the field names for the array keys
|
||||||
|
// It seems that there is no better way to do this.
|
||||||
|
$result = $stmt->result_metadata();
|
||||||
|
$fields = $result->fetch_fields();
|
||||||
|
|
||||||
|
$columns = array();
|
||||||
|
foreach ($cols_num AS $param => $col) {
|
||||||
|
$columns[$fields[$param]->name] = $col;
|
||||||
|
}
|
||||||
|
return $columns;
|
||||||
|
case 'mysql':
|
||||||
|
return mysql_fetch_array(self::$dbo->result, MYSQL_ASSOC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Insert a row into a table
|
||||||
|
*
|
||||||
|
* @param string $table Table name
|
||||||
|
* @param array $param parameter array
|
||||||
|
*
|
||||||
|
* @return boolean was the insert successfull?
|
||||||
|
*/
|
||||||
|
static public function insert($table, $param) {
|
||||||
|
$sql = "INSERT INTO `".self::$dbo->escape($table)."` (`".implode("`, `", array_keys($param))."`) VALUES (".
|
||||||
|
substr(str_repeat("?, ", count($param)), 0, -2).");";
|
||||||
|
|
||||||
|
return self::e($sql, $param);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Build the array with the table relations
|
||||||
|
*
|
||||||
|
* The array is build from the database definitions in dbstructure.php
|
||||||
|
*
|
||||||
|
* This process must only be started once, since the value is cached.
|
||||||
|
*/
|
||||||
|
static private function build_relation_data() {
|
||||||
|
$definition = db_definition();
|
||||||
|
|
||||||
|
foreach ($definition AS $table => $structure) {
|
||||||
|
foreach ($structure['fields'] AS $field => $field_struct) {
|
||||||
|
if (isset($field_struct['relation'])) {
|
||||||
|
foreach ($field_struct['relation'] AS $rel_table => $rel_field) {
|
||||||
|
self::$relation[$rel_table][$rel_field][$table][] = $field;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Insert a row into a table
|
||||||
|
*
|
||||||
|
* @param string $table Table name
|
||||||
|
* @param array $param parameter array
|
||||||
|
* @param boolean $in_commit Internal use: Only do a commit after the last delete
|
||||||
|
* @param array $callstack Internal use: prevent endless loops
|
||||||
|
*
|
||||||
|
* @return boolean|array was the delete successfull? When $in_commit is set: deletion data
|
||||||
|
*/
|
||||||
|
static public function delete($table, $param, $in_commit = false, &$callstack = array()) {
|
||||||
|
|
||||||
|
$commands = array();
|
||||||
|
|
||||||
|
// Create a key for the loop prevention
|
||||||
|
$key = $table.':'.implode(':', array_keys($param)).':'.implode(':', $param);
|
||||||
|
|
||||||
|
// We quit when this key already exists in the callstack.
|
||||||
|
if (isset($callstack[$key])) {
|
||||||
|
return $commands;
|
||||||
|
}
|
||||||
|
|
||||||
|
$callstack[$key] = true;
|
||||||
|
|
||||||
|
$table = self::$dbo->escape($table);
|
||||||
|
|
||||||
|
$commands[$key] = array('table' => $table, 'param' => $param);
|
||||||
|
|
||||||
|
// To speed up the whole process we cache the table relations
|
||||||
|
if (count(self::$relation) == 0) {
|
||||||
|
self::build_relation_data();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Is there a relation entry for the table?
|
||||||
|
if (isset(self::$relation[$table])) {
|
||||||
|
// We only allow a simple "one field" relation.
|
||||||
|
$field = array_keys(self::$relation[$table])[0];
|
||||||
|
$rel_def = array_values(self::$relation[$table])[0];
|
||||||
|
|
||||||
|
// Create a key for preventing double queries
|
||||||
|
$qkey = $field.'-'.$table.':'.implode(':', array_keys($param)).':'.implode(':', $param);
|
||||||
|
|
||||||
|
// When the search field is the relation field, we don't need to fetch the rows
|
||||||
|
// This is useful when the leading record is already deleted in the frontend but the rest is done in the backend
|
||||||
|
if ((count($param) == 1) AND ($field == array_keys($param)[0])) {
|
||||||
|
foreach ($rel_def AS $rel_table => $rel_fields) {
|
||||||
|
foreach ($rel_fields AS $rel_field) {
|
||||||
|
$retval = self::delete($rel_table, array($rel_field => array_values($param)[0]), true, $callstack);
|
||||||
|
$commands = array_merge($commands, $retval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// We quit when this key already exists in the callstack.
|
||||||
|
} elseif (!isset($callstack[$qkey])) {
|
||||||
|
|
||||||
|
$callstack[$qkey] = true;
|
||||||
|
|
||||||
|
// Fetch all rows that are to be deleted
|
||||||
|
$sql = "SELECT ".self::$dbo->escape($field)." FROM `".$table."` WHERE `".
|
||||||
|
implode("` = ? AND `", array_keys($param))."` = ?";
|
||||||
|
|
||||||
|
$data = self::p($sql, $param);
|
||||||
|
while ($row = self::fetch($data)) {
|
||||||
|
// Now we accumulate the delete commands
|
||||||
|
$retval = self::delete($table, array($field => $row[$field]), true, $callstack);
|
||||||
|
$commands = array_merge($commands, $retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Since we had split the delete command we don't need the original command anymore
|
||||||
|
unset($commands[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$in_commit) {
|
||||||
|
// Now we finalize the process
|
||||||
|
self::p("COMMIT");
|
||||||
|
self::p("START TRANSACTION");
|
||||||
|
|
||||||
|
$compacted = array();
|
||||||
|
$counter = array();
|
||||||
|
foreach ($commands AS $command) {
|
||||||
|
if (count($command['param']) > 1) {
|
||||||
|
$sql = "DELETE FROM `".$command['table']."` WHERE `".
|
||||||
|
implode("` = ? AND `", array_keys($command['param']))."` = ?";
|
||||||
|
|
||||||
|
logger(dba::replace_parameters($sql, $command['param']), LOGGER_DATA);
|
||||||
|
|
||||||
|
if (!self::e($sql, $command['param'])) {
|
||||||
|
self::p("ROLLBACK");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$key_table = $command['table'];
|
||||||
|
$key_param = array_keys($command['param'])[0];
|
||||||
|
$value = array_values($command['param'])[0];
|
||||||
|
|
||||||
|
// Split the SQL queries in chunks of 100 values
|
||||||
|
// We do the $i stuff here to make the code better readable
|
||||||
|
$i = $counter[$key_table][$key_param];
|
||||||
|
if (count($compacted[$key_table][$key_param][$i]) > 100) {
|
||||||
|
++$i;
|
||||||
|
}
|
||||||
|
|
||||||
|
$compacted[$key_table][$key_param][$i][$value] = $value;
|
||||||
|
$counter[$key_table][$key_param] = $i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($compacted AS $table => $values) {
|
||||||
|
foreach ($values AS $field => $field_value_list) {
|
||||||
|
foreach ($field_value_list AS $field_values) {
|
||||||
|
$sql = "DELETE FROM `".$table."` WHERE `".$field."` IN (".
|
||||||
|
substr(str_repeat("?, ", count($field_values)), 0, -2).");";
|
||||||
|
|
||||||
|
logger(dba::replace_parameters($sql, $field_values), LOGGER_DATA);
|
||||||
|
|
||||||
|
if (!self::e($sql, $field_values)) {
|
||||||
|
self::p("ROLLBACK");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self::p("COMMIT");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $commands;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Updates rows
|
||||||
|
*
|
||||||
|
* Updates rows in the database. When $old_fields is set to an array,
|
||||||
|
* the system will only do an update if the fields in that array changed.
|
||||||
|
*
|
||||||
|
* Attention:
|
||||||
|
* Only the values in $old_fields are compared.
|
||||||
|
* This is an intentional behaviour.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* We include the timestamp field in $fields but not in $old_fields.
|
||||||
|
* Then the row will only get the new timestamp when the other fields had changed.
|
||||||
|
*
|
||||||
|
* When $old_fields is set to a boolean value the system will do this compare itself.
|
||||||
|
* When $old_fields is set to "true" the system will do an insert if the row doesn't exists.
|
||||||
|
*
|
||||||
|
* Attention:
|
||||||
|
* Only set $old_fields to a boolean value when you are sure that you will update a single row.
|
||||||
|
* When you set $old_fields to "true" then $fields must contain all relevant fields!
|
||||||
|
*
|
||||||
|
* @param string $table Table name
|
||||||
|
* @param array $fields contains the fields that are updated
|
||||||
|
* @param array $condition condition array with the key values
|
||||||
|
* @param array|boolean $old_fields array with the old field values that are about to be replaced
|
||||||
|
*
|
||||||
|
* @return boolean was the update successfull?
|
||||||
|
*/
|
||||||
|
static public function update($table, $fields, $condition, $old_fields = array()) {
|
||||||
|
|
||||||
|
/** @todo We may use MySQL specific functions here:
|
||||||
|
* INSERT INTO `config` (`cat`, `k`, `v`) VALUES ('%s', '%s', '%s') ON DUPLICATE KEY UPDATE `v` = '%s'"
|
||||||
|
* But I think that it doesn't make sense here.
|
||||||
|
*/
|
||||||
|
|
||||||
|
$table = self::$dbo->escape($table);
|
||||||
|
|
||||||
|
if (is_bool($old_fields)) {
|
||||||
|
$sql = "SELECT * FROM `".$table."` WHERE `".
|
||||||
|
implode("` = ? AND `", array_keys($condition))."` = ? LIMIT 1";
|
||||||
|
|
||||||
|
$params = array();
|
||||||
|
foreach ($condition AS $value) {
|
||||||
|
$params[] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
$do_insert = $old_fields;
|
||||||
|
|
||||||
|
$old_fields = self::fetch_first($sql, $params);
|
||||||
|
if (is_bool($old_fields)) {
|
||||||
|
if ($do_insert) {
|
||||||
|
return self::insert($table, $fields);
|
||||||
|
}
|
||||||
|
$old_fields = array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$do_update = (count($old_fields) == 0);
|
||||||
|
|
||||||
|
foreach ($old_fields AS $fieldname => $content) {
|
||||||
|
if (isset($fields[$fieldname])) {
|
||||||
|
if ($fields[$fieldname] == $content) {
|
||||||
|
unset($fields[$fieldname]);
|
||||||
|
} else {
|
||||||
|
$do_update = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$do_update OR (count($fields) == 0)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "UPDATE `".$table."` SET `".
|
||||||
|
implode("` = ?, `", array_keys($fields))."` = ? WHERE `".
|
||||||
|
implode("` = ? AND `", array_keys($condition))."` = ?";
|
||||||
|
|
||||||
|
$params = array();
|
||||||
|
foreach ($fields AS $value) {
|
||||||
|
$params[] = $value;
|
||||||
|
}
|
||||||
|
foreach ($condition AS $value) {
|
||||||
|
$params[] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::e($sql, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Select rows from a table
|
||||||
|
*
|
||||||
|
* @param string $table Table name
|
||||||
|
* @param array $fields array of selected fields
|
||||||
|
* @param array $condition array of fields for condition
|
||||||
|
* @param array $params array of several parameters
|
||||||
|
*
|
||||||
|
* @return boolean|object If "limit" is equal "1" only a single row is returned, else a query object is returned
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* $table = "item";
|
||||||
|
* $fields = array("id", "uri", "uid", "network");
|
||||||
|
* $condition = array("uid" => 1, "network" => 'dspr');
|
||||||
|
* $params = array("order" => array("id", "received" => true), "limit" => 1);
|
||||||
|
*
|
||||||
|
* $data = dba::select($table, $fields, $condition, $params);
|
||||||
|
*/
|
||||||
|
static public function select($table, $fields = array(), $condition = array(), $params = array()) {
|
||||||
|
if ($table == '') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($fields) > 0) {
|
||||||
|
$select_fields = "`".implode("`, `", array_values($fields))."`";
|
||||||
|
} else {
|
||||||
|
$select_fields = "*";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($condition) > 0) {
|
||||||
|
$condition_string = " WHERE `".implode("` = ? AND `", array_keys($condition))."` = ?";
|
||||||
|
} else {
|
||||||
|
$condition_string = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
$param_string = '';
|
||||||
|
$single_row = false;
|
||||||
|
|
||||||
|
if (isset($params['order'])) {
|
||||||
|
$param_string .= " ORDER BY ";
|
||||||
|
foreach ($params['order'] AS $fields => $order) {
|
||||||
|
if (!is_int($fields)) {
|
||||||
|
$param_string .= "`".$fields."` ".($order ? "DESC" : "ASC").", ";
|
||||||
|
} else {
|
||||||
|
$param_string .= "`".$order."`, ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$param_string = substr($param_string, 0, -2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($params['limit'])) {
|
||||||
|
if (is_int($params['limit'])) {
|
||||||
|
$param_string .= " LIMIT ".$params['limit'];
|
||||||
|
$single_row =($params['limit'] == 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "SELECT ".$select_fields." FROM `".$table."`".$condition_string.$param_string;
|
||||||
|
|
||||||
|
$result = self::p($sql, $condition);
|
||||||
|
|
||||||
|
if (is_bool($result) OR !$single_row) {
|
||||||
|
return $result;
|
||||||
|
} else {
|
||||||
|
$row = self::fetch($result);
|
||||||
|
self::close($result);
|
||||||
|
return $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Closes the current statement
|
||||||
|
*
|
||||||
|
* @param object $stmt statement object
|
||||||
|
* @return boolean was the close successfull?
|
||||||
|
*/
|
||||||
|
static public function close($stmt) {
|
||||||
|
if (!is_object($stmt)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (self::$dbo->driver) {
|
||||||
|
case 'pdo':
|
||||||
|
return $stmt->closeCursor();
|
||||||
|
case 'mysqli':
|
||||||
|
return $stmt->free_result();
|
||||||
|
return $stmt->close();
|
||||||
|
case 'mysql':
|
||||||
|
return mysql_free_result($stmt);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function printable($s) {
|
function printable($s) {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* @brief The script is called from time to time to clean the database entries and remove orphaned data.
|
* @brief The script is called from time to time to clean the database entries and remove orphaned data.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
function dbclean_run(&$argv, &$argc) {
|
function dbclean_run(&$argv, &$argc) {
|
||||||
if (!Config::get('system', 'dbclean', false)) {
|
if (!Config::get('system', 'dbclean', false)) {
|
||||||
|
@ -43,96 +43,103 @@ function remove_orphans($stage = 0) {
|
||||||
|
|
||||||
if (($stage == 1) OR ($stage == 0)) {
|
if (($stage == 1) OR ($stage == 0)) {
|
||||||
logger("Deleting old global item entries from item table without user copy");
|
logger("Deleting old global item entries from item table without user copy");
|
||||||
if ($db->q("SELECT `id` FROM `item` WHERE `uid` = 0
|
$r = dba::p("SELECT `id` FROM `item` WHERE `uid` = 0
|
||||||
AND NOT EXISTS (SELECT `guid` FROM `item` AS `i` WHERE `item`.`guid` = `i`.`guid` AND `i`.`uid` != 0)
|
AND NOT EXISTS (SELECT `guid` FROM `item` AS `i` WHERE `item`.`guid` = `i`.`guid` AND `i`.`uid` != 0)
|
||||||
AND `received` < UTC_TIMESTAMP() - INTERVAL 90 DAY LIMIT ".intval($limit), true)) {
|
AND `received` < UTC_TIMESTAMP() - INTERVAL 90 DAY LIMIT ".intval($limit));
|
||||||
$count = $db->num_rows();
|
$count = dba::num_rows($r);
|
||||||
|
if ($count > 0) {
|
||||||
logger("found global item orphans: ".$count);
|
logger("found global item orphans: ".$count);
|
||||||
while ($orphan = $db->qfetch()) {
|
while ($orphan = dba::fetch($r)) {
|
||||||
q("DELETE FROM `item` WHERE `id` = %d", intval($orphan["id"]));
|
q("DELETE FROM `item` WHERE `id` = %d", intval($orphan["id"]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$db->qclose();
|
dba::close($r);
|
||||||
logger("Done deleting old global item entries from item table without user copy");
|
logger("Done deleting old global item entries from item table without user copy");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($stage == 2) OR ($stage == 0)) {
|
if (($stage == 2) OR ($stage == 0)) {
|
||||||
logger("Deleting items without parents");
|
logger("Deleting items without parents");
|
||||||
if ($db->q("SELECT `id` FROM `item` WHERE NOT EXISTS (SELECT `id` FROM `item` AS `i` WHERE `item`.`parent` = `i`.`id`) LIMIT ".intval($limit), true)) {
|
$r = dba::p("SELECT `id` FROM `item` WHERE NOT EXISTS (SELECT `id` FROM `item` AS `i` WHERE `item`.`parent` = `i`.`id`) LIMIT ".intval($limit));
|
||||||
$count = $db->num_rows();
|
$count = dba::num_rows($r);
|
||||||
|
if ($count > 0) {
|
||||||
logger("found item orphans without parents: ".$count);
|
logger("found item orphans without parents: ".$count);
|
||||||
while ($orphan = $db->qfetch()) {
|
while ($orphan = dba::fetch($r)) {
|
||||||
q("DELETE FROM `item` WHERE `id` = %d", intval($orphan["id"]));
|
q("DELETE FROM `item` WHERE `id` = %d", intval($orphan["id"]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$db->qclose();
|
dba::close($r);
|
||||||
logger("Done deleting items without parents");
|
logger("Done deleting items without parents");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($stage == 3) OR ($stage == 0)) {
|
if (($stage == 3) OR ($stage == 0)) {
|
||||||
logger("Deleting orphaned data from thread table");
|
logger("Deleting orphaned data from thread table");
|
||||||
if ($db->q("SELECT `iid` FROM `thread` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`parent` = `thread`.`iid`) LIMIT ".intval($limit), true)) {
|
$r = dba::p("SELECT `iid` FROM `thread` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`parent` = `thread`.`iid`) LIMIT ".intval($limit));
|
||||||
$count = $db->num_rows();
|
$count = dba::num_rows($r);
|
||||||
|
if ($count > 0) {
|
||||||
logger("found thread orphans: ".$count);
|
logger("found thread orphans: ".$count);
|
||||||
while ($orphan = $db->qfetch()) {
|
while ($orphan = dba::fetch($r)) {
|
||||||
q("DELETE FROM `thread` WHERE `iid` = %d", intval($orphan["iid"]));
|
q("DELETE FROM `thread` WHERE `iid` = %d", intval($orphan["iid"]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$db->qclose();
|
dba::close($r);
|
||||||
logger("Done deleting orphaned data from thread table");
|
logger("Done deleting orphaned data from thread table");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($stage == 4) OR ($stage == 0)) {
|
if (($stage == 4) OR ($stage == 0)) {
|
||||||
logger("Deleting orphaned data from notify table");
|
logger("Deleting orphaned data from notify table");
|
||||||
if ($db->q("SELECT `iid` FROM `notify` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `notify`.`iid`) LIMIT ".intval($limit), true)) {
|
$r = dba::p("SELECT `iid` FROM `notify` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `notify`.`iid`) LIMIT ".intval($limit));
|
||||||
$count = $db->num_rows();
|
$count = dba::num_rows($r);
|
||||||
|
if ($count > 0) {
|
||||||
logger("found notify orphans: ".$count);
|
logger("found notify orphans: ".$count);
|
||||||
while ($orphan = $db->qfetch()) {
|
while ($orphan = dba::fetch($r)) {
|
||||||
q("DELETE FROM `notify` WHERE `iid` = %d", intval($orphan["iid"]));
|
q("DELETE FROM `notify` WHERE `iid` = %d", intval($orphan["iid"]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$db->qclose();
|
dba::close($r);
|
||||||
logger("Done deleting orphaned data from notify table");
|
logger("Done deleting orphaned data from notify table");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($stage == 5) OR ($stage == 0)) {
|
if (($stage == 5) OR ($stage == 0)) {
|
||||||
logger("Deleting orphaned data from notify-threads table");
|
logger("Deleting orphaned data from notify-threads table");
|
||||||
if ($db->q("SELECT `id` FROM `notify-threads` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`parent` = `notify-threads`.`master-parent-item`) LIMIT ".intval($limit), true)) {
|
$r = dba::p("SELECT `id` FROM `notify-threads` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`parent` = `notify-threads`.`master-parent-item`) LIMIT ".intval($limit));
|
||||||
$count = $db->num_rows();
|
$count = dba::num_rows($r);
|
||||||
|
if ($count > 0) {
|
||||||
logger("found notify-threads orphans: ".$count);
|
logger("found notify-threads orphans: ".$count);
|
||||||
while ($orphan = $db->qfetch()) {
|
while ($orphan = dba::fetch($r)) {
|
||||||
q("DELETE FROM `notify-threads` WHERE `id` = %d", intval($orphan["id"]));
|
q("DELETE FROM `notify-threads` WHERE `id` = %d", intval($orphan["id"]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$db->qclose();
|
dba::close($r);
|
||||||
logger("Done deleting orphaned data from notify-threads table");
|
logger("Done deleting orphaned data from notify-threads table");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (($stage == 6) OR ($stage == 0)) {
|
if (($stage == 6) OR ($stage == 0)) {
|
||||||
logger("Deleting orphaned data from sign table");
|
logger("Deleting orphaned data from sign table");
|
||||||
if ($db->q("SELECT `iid` FROM `sign` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `sign`.`iid`) LIMIT ".intval($limit), true)) {
|
$r = dba::p("SELECT `iid` FROM `sign` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `sign`.`iid`) LIMIT ".intval($limit));
|
||||||
$count = $db->num_rows();
|
$count = dba::num_rows($r);
|
||||||
|
if ($count > 0) {
|
||||||
logger("found sign orphans: ".$count);
|
logger("found sign orphans: ".$count);
|
||||||
while ($orphan = $db->qfetch()) {
|
while ($orphan = dba::fetch($r)) {
|
||||||
q("DELETE FROM `sign` WHERE `iid` = %d", intval($orphan["iid"]));
|
q("DELETE FROM `sign` WHERE `iid` = %d", intval($orphan["iid"]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$db->qclose();
|
dba::close($r);
|
||||||
logger("Done deleting orphaned data from sign table");
|
logger("Done deleting orphaned data from sign table");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (($stage == 7) OR ($stage == 0)) {
|
if (($stage == 7) OR ($stage == 0)) {
|
||||||
logger("Deleting orphaned data from term table");
|
logger("Deleting orphaned data from term table");
|
||||||
if ($db->q("SELECT `oid` FROM `term` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `term`.`oid`) LIMIT ".intval($limit), true)) {
|
$r = dba::p("SELECT `oid` FROM `term` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `term`.`oid`) LIMIT ".intval($limit));
|
||||||
$count = $db->num_rows();
|
$count = dba::num_rows($r);
|
||||||
|
if ($count > 0) {
|
||||||
logger("found term orphans: ".$count);
|
logger("found term orphans: ".$count);
|
||||||
while ($orphan = $db->qfetch()) {
|
while ($orphan = dba::fetch($r)) {
|
||||||
q("DELETE FROM `term` WHERE `oid` = %d", intval($orphan["oid"]));
|
q("DELETE FROM `term` WHERE `oid` = %d", intval($orphan["oid"]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$db->qclose();
|
dba::close($r);
|
||||||
logger("Done deleting orphaned data from term table");
|
logger("Done deleting orphaned data from term table");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,4 +149,3 @@ function remove_orphans($stage = 0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
/**
|
/**
|
||||||
* @brief This class contain functions for the database management
|
* @brief This class contain functions for the database management
|
||||||
*
|
*
|
||||||
|
* This class contains functions that doesn't need to know if pdo, mysqli or whatever is used.
|
||||||
*/
|
*/
|
||||||
class dbm {
|
class dbm {
|
||||||
/**
|
/**
|
||||||
|
@ -47,6 +48,11 @@ class dbm {
|
||||||
if (is_bool($array)) {
|
if (is_bool($array)) {
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_object($array)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return (is_array($array) && count($array) > 0);
|
return (is_array($array) && count($array) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,4 +110,3 @@ class dbm {
|
||||||
return date('Y-m-d H:i:s', $timestamp);
|
return date('Y-m-d H:i:s', $timestamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,19 +1,45 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\App;
|
||||||
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
require_once("boot.php");
|
require_once("boot.php");
|
||||||
require_once("include/text.php");
|
require_once("include/text.php");
|
||||||
|
|
||||||
define('NEW_UPDATE_ROUTINE_VERSION', 1170);
|
define('NEW_UPDATE_ROUTINE_VERSION', 1170);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Converts all tables from MyISAM to InnoDB
|
||||||
|
*/
|
||||||
|
function convert_to_innodb() {
|
||||||
|
global $db;
|
||||||
|
|
||||||
|
$r = q("SELECT `TABLE_NAME` FROM `information_schema`.`tables` WHERE `engine` = 'MyISAM' AND `table_schema` = '%s'",
|
||||||
|
dbesc($db->database_name()));
|
||||||
|
|
||||||
|
if (!dbm::is_result($r)) {
|
||||||
|
echo t('There are no tables on MyISAM.')."\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($r AS $table) {
|
||||||
|
$sql = sprintf("ALTER TABLE `%s` engine=InnoDB;", dbesc($table['TABLE_NAME']));
|
||||||
|
echo $sql."\n";
|
||||||
|
|
||||||
|
$result = @$db->q($sql);
|
||||||
|
if (!dbm::is_result($result)) {
|
||||||
|
print_update_error($db, $sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* send the email and do what is needed to do on update fails
|
* send the email and do what is needed to do on update fails
|
||||||
*
|
*
|
||||||
* @param update_id (int) number of failed update
|
* @param update_id (int) number of failed update
|
||||||
* @param error_message (str) error message
|
* @param error_message (str) error message
|
||||||
*/
|
*/
|
||||||
function update_fail($update_id, $error_message){
|
function update_fail($update_id, $error_message) {
|
||||||
//send the administrators an e-mail
|
//send the administrators an e-mail
|
||||||
$admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
|
$admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
|
||||||
$adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
|
$adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
|
||||||
|
@ -95,10 +121,6 @@ function table_structure($table) {
|
||||||
|
|
||||||
if (dbm::is_result($indexes))
|
if (dbm::is_result($indexes))
|
||||||
foreach ($indexes AS $index) {
|
foreach ($indexes AS $index) {
|
||||||
if ($index["Index_type"] == "FULLTEXT") {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
|
if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
|
||||||
$indexdata[$index["Key_name"]] = array('UNIQUE');
|
$indexdata[$index["Key_name"]] = array('UNIQUE');
|
||||||
}
|
}
|
||||||
|
@ -279,6 +301,9 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
|
||||||
// Compare the field definition
|
// Compare the field definition
|
||||||
$field_definition = $database[$name]["fields"][$fieldname];
|
$field_definition = $database[$name]["fields"][$fieldname];
|
||||||
|
|
||||||
|
// Remove the relation data that is used for the referential integrity
|
||||||
|
unset($parameters['relation']);
|
||||||
|
|
||||||
// We change the collation after the indexes had been changed.
|
// We change the collation after the indexes had been changed.
|
||||||
// This is done to avoid index length problems.
|
// This is done to avoid index length problems.
|
||||||
// So here we always ensure that there is no need to change it.
|
// So here we always ensure that there is no need to change it.
|
||||||
|
@ -374,6 +399,14 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
|
||||||
$sql3 .= ";";
|
$sql3 .= ";";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$field_list = '';
|
||||||
|
if ($is_unique && $ignore == '') {
|
||||||
|
foreach ($structure['fields'] AS $fieldname => $parameters) {
|
||||||
|
$field_list .= 'ANY_VALUE(`' . $fieldname . '`),';
|
||||||
|
}
|
||||||
|
$field_list = rtrim($field_list, ',');
|
||||||
|
}
|
||||||
|
|
||||||
if ($verbose) {
|
if ($verbose) {
|
||||||
// Ensure index conversion to unique removes duplicates
|
// Ensure index conversion to unique removes duplicates
|
||||||
if ($is_unique) {
|
if ($is_unique) {
|
||||||
|
@ -390,7 +423,7 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
|
||||||
if ($ignore != "") {
|
if ($ignore != "") {
|
||||||
echo "SET session old_alter_table=0;\n";
|
echo "SET session old_alter_table=0;\n";
|
||||||
} else {
|
} else {
|
||||||
echo "INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";\n";
|
echo "INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";\n";
|
||||||
echo "DROP TABLE `".$name."`;\n";
|
echo "DROP TABLE `".$name."`;\n";
|
||||||
echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
|
echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
|
||||||
}
|
}
|
||||||
|
@ -421,7 +454,7 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
|
||||||
if ($ignore != "") {
|
if ($ignore != "") {
|
||||||
$db->q("SET session old_alter_table=0;");
|
$db->q("SET session old_alter_table=0;");
|
||||||
} else {
|
} else {
|
||||||
$r = $db->q("INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";");
|
$r = $db->q("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
|
||||||
if (!dbm::is_result($r)) {
|
if (!dbm::is_result($r)) {
|
||||||
$errors .= print_update_error($db, $sql3);
|
$errors .= print_update_error($db, $sql3);
|
||||||
return $errors;
|
return $errors;
|
||||||
|
@ -460,7 +493,7 @@ function db_field_command($parameters, $create = true) {
|
||||||
if ($parameters["not null"])
|
if ($parameters["not null"])
|
||||||
$fieldstruct .= " NOT NULL";
|
$fieldstruct .= " NOT NULL";
|
||||||
|
|
||||||
if (isset($parameters["default"])){
|
if (isset($parameters["default"])) {
|
||||||
if (strpos(strtolower($parameters["type"]),"int")!==false) {
|
if (strpos(strtolower($parameters["type"]),"int")!==false) {
|
||||||
$fieldstruct .= " DEFAULT ".$parameters["default"];
|
$fieldstruct .= " DEFAULT ".$parameters["default"];
|
||||||
} else {
|
} else {
|
||||||
|
@ -487,7 +520,7 @@ function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
|
||||||
$primary_keys = array();
|
$primary_keys = array();
|
||||||
foreach ($fields AS $fieldname => $field) {
|
foreach ($fields AS $fieldname => $field) {
|
||||||
$sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
|
$sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
|
||||||
if (x($field,'primary') and $field['primary']!=''){
|
if (x($field,'primary') and $field['primary']!='') {
|
||||||
$primary_keys[] = $fieldname;
|
$primary_keys[] = $fieldname;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -606,7 +639,7 @@ function db_definition() {
|
||||||
$database["attach"] = array(
|
$database["attach"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
|
"hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
|
||||||
"filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
|
"filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
|
||||||
|
@ -626,7 +659,7 @@ function db_definition() {
|
||||||
$database["auth_codes"] = array(
|
$database["auth_codes"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
|
"id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
|
||||||
"client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
|
"client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
|
||||||
"redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
|
"redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
|
||||||
"expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||||
"scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
|
"scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
|
||||||
|
@ -667,7 +700,7 @@ function db_definition() {
|
||||||
"redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
|
"redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
|
||||||
"name" => array("type" => "text"),
|
"name" => array("type" => "text"),
|
||||||
"icon" => array("type" => "text"),
|
"icon" => array("type" => "text"),
|
||||||
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
),
|
),
|
||||||
"indexes" => array(
|
"indexes" => array(
|
||||||
"PRIMARY" => array("client_id"),
|
"PRIMARY" => array("client_id"),
|
||||||
|
@ -688,7 +721,7 @@ function db_definition() {
|
||||||
$database["contact"] = array(
|
$database["contact"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||||
"self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
"self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||||
"remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
"remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||||
|
@ -777,7 +810,7 @@ function db_definition() {
|
||||||
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
|
"guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
|
||||||
"recips" => array("type" => "text"),
|
"recips" => array("type" => "text"),
|
||||||
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||||
"updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
"updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||||
|
@ -788,12 +821,27 @@ function db_definition() {
|
||||||
"uid" => array("uid"),
|
"uid" => array("uid"),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
$database["conversation"] = array(
|
||||||
|
"fields" => array(
|
||||||
|
"item-uri" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
|
||||||
|
"reply-to-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
|
||||||
|
"conversation-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
|
||||||
|
"conversation-href" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
|
||||||
|
"protocol" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
|
||||||
|
"source" => array("type" => "mediumtext"),
|
||||||
|
"received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||||
|
),
|
||||||
|
"indexes" => array(
|
||||||
|
"PRIMARY" => array("item-uri"),
|
||||||
|
"conversation-uri" => array("conversation-uri"),
|
||||||
|
)
|
||||||
|
);
|
||||||
$database["event"] = array(
|
$database["event"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
|
||||||
"uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||||
"edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
"edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||||
|
@ -839,15 +887,15 @@ function db_definition() {
|
||||||
"indexes" => array(
|
"indexes" => array(
|
||||||
"PRIMARY" => array("id"),
|
"PRIMARY" => array("id"),
|
||||||
"addr" => array("addr(32)"),
|
"addr" => array("addr(32)"),
|
||||||
"url" => array("url"),
|
"url" => array("UNIQUE", "url(190)"),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$database["ffinder"] = array(
|
$database["ffinder"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
"cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
|
||||||
"fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
"fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id")),
|
||||||
),
|
),
|
||||||
"indexes" => array(
|
"indexes" => array(
|
||||||
"PRIMARY" => array("id"),
|
"PRIMARY" => array("id"),
|
||||||
|
@ -868,8 +916,8 @@ function db_definition() {
|
||||||
$database["fsuggest"] = array(
|
$database["fsuggest"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
|
||||||
"name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
|
@ -884,8 +932,8 @@ function db_definition() {
|
||||||
$database["gcign"] = array(
|
$database["gcign"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
|
||||||
),
|
),
|
||||||
"indexes" => array(
|
"indexes" => array(
|
||||||
"PRIMARY" => array("id"),
|
"PRIMARY" => array("id"),
|
||||||
|
@ -924,7 +972,7 @@ function db_definition() {
|
||||||
),
|
),
|
||||||
"indexes" => array(
|
"indexes" => array(
|
||||||
"PRIMARY" => array("id"),
|
"PRIMARY" => array("id"),
|
||||||
"nurl" => array("nurl(64)"),
|
"nurl" => array("UNIQUE", "nurl(190)"),
|
||||||
"name" => array("name(64)"),
|
"name" => array("name(64)"),
|
||||||
"nick" => array("nick(32)"),
|
"nick" => array("nick(32)"),
|
||||||
"addr" => array("addr(64)"),
|
"addr" => array("addr(64)"),
|
||||||
|
@ -935,10 +983,10 @@ function db_definition() {
|
||||||
$database["glink"] = array(
|
$database["glink"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
|
||||||
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
|
||||||
"zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
|
||||||
"updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
"updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||||
),
|
),
|
||||||
"indexes" => array(
|
"indexes" => array(
|
||||||
|
@ -950,7 +998,7 @@ function db_definition() {
|
||||||
$database["group"] = array(
|
$database["group"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
"visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||||
"deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
"deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||||
"name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
|
@ -963,9 +1011,9 @@ function db_definition() {
|
||||||
$database["group_member"] = array(
|
$database["group_member"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
"gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("group" => "id")),
|
||||||
"contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
"contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
|
||||||
),
|
),
|
||||||
"indexes" => array(
|
"indexes" => array(
|
||||||
"PRIMARY" => array("id"),
|
"PRIMARY" => array("id"),
|
||||||
|
@ -994,7 +1042,7 @@ function db_definition() {
|
||||||
),
|
),
|
||||||
"indexes" => array(
|
"indexes" => array(
|
||||||
"PRIMARY" => array("id"),
|
"PRIMARY" => array("id"),
|
||||||
"nurl" => array("nurl(32)"),
|
"nurl" => array("UNIQUE", "nurl(190)"),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$database["hook"] = array(
|
$database["hook"] = array(
|
||||||
|
@ -1013,9 +1061,9 @@ function db_definition() {
|
||||||
$database["intro"] = array(
|
$database["intro"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"fid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id")),
|
||||||
"contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
|
||||||
"knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
"knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||||
"duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
"duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||||
"note" => array("type" => "text"),
|
"note" => array("type" => "text"),
|
||||||
|
@ -1030,16 +1078,16 @@ function db_definition() {
|
||||||
);
|
);
|
||||||
$database["item"] = array(
|
$database["item"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => array("thread" => "iid")),
|
||||||
"guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
|
||||||
"gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
|
"gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
|
||||||
"type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
"wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||||
"gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
"gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||||
"parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
"parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
|
||||||
"parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
|
@ -1048,11 +1096,11 @@ function db_definition() {
|
||||||
"commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
"commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||||
"received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
"received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||||
"changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
"changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||||
"owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
|
||||||
"owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
|
||||||
"author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
|
@ -1067,7 +1115,7 @@ function db_definition() {
|
||||||
"postopts" => array("type" => "text"),
|
"postopts" => array("type" => "text"),
|
||||||
"plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("event" => "id")),
|
||||||
"tag" => array("type" => "mediumtext"),
|
"tag" => array("type" => "mediumtext"),
|
||||||
"attach" => array("type" => "mediumtext"),
|
"attach" => array("type" => "mediumtext"),
|
||||||
"inform" => array("type" => "mediumtext"),
|
"inform" => array("type" => "mediumtext"),
|
||||||
|
@ -1113,6 +1161,7 @@ function db_definition() {
|
||||||
"uid_parenturi" => array("uid","parent-uri(190)"),
|
"uid_parenturi" => array("uid","parent-uri(190)"),
|
||||||
"uid_contactid_created" => array("uid","contact-id","created"),
|
"uid_contactid_created" => array("uid","contact-id","created"),
|
||||||
"authorid_created" => array("author-id","created"),
|
"authorid_created" => array("author-id","created"),
|
||||||
|
"ownerid" => array("owner-id"),
|
||||||
"uid_uri" => array("uid", "uri(190)"),
|
"uid_uri" => array("uid", "uri(190)"),
|
||||||
"resource-id" => array("resource-id"),
|
"resource-id" => array("resource-id"),
|
||||||
"contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"), //
|
"contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"), //
|
||||||
|
@ -1128,8 +1177,8 @@ function db_definition() {
|
||||||
$database["item_id"] = array(
|
$database["item_id"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"iid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
|
||||||
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
),
|
),
|
||||||
|
@ -1155,13 +1204,13 @@ function db_definition() {
|
||||||
$database["mail"] = array(
|
$database["mail"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
|
"guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
|
||||||
"from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "relation" => array("contact" => "id")),
|
||||||
"convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
|
"convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("conv" => "id")),
|
||||||
"title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"body" => array("type" => "mediumtext"),
|
"body" => array("type" => "mediumtext"),
|
||||||
"seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
"seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||||
|
@ -1178,12 +1227,13 @@ function db_definition() {
|
||||||
"convid" => array("convid"),
|
"convid" => array("convid"),
|
||||||
"uri" => array("uri(64)"),
|
"uri" => array("uri(64)"),
|
||||||
"parent-uri" => array("parent-uri(64)"),
|
"parent-uri" => array("parent-uri(64)"),
|
||||||
|
"contactid" => array("contact-id"),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$database["mailacct"] = array(
|
$database["mailacct"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||||
"ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
|
"ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
|
||||||
|
@ -1203,8 +1253,8 @@ function db_definition() {
|
||||||
$database["manage"] = array(
|
$database["manage"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"mid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
),
|
),
|
||||||
"indexes" => array(
|
"indexes" => array(
|
||||||
"PRIMARY" => array("id"),
|
"PRIMARY" => array("id"),
|
||||||
|
@ -1221,10 +1271,10 @@ function db_definition() {
|
||||||
"photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
"date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||||
"msg" => array("type" => "mediumtext"),
|
"msg" => array("type" => "mediumtext"),
|
||||||
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"iid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
|
||||||
"parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"parent" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
|
||||||
"seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
"seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||||
"verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
|
"otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
|
||||||
|
@ -1242,10 +1292,10 @@ function db_definition() {
|
||||||
$database["notify-threads"] = array(
|
$database["notify-threads"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("notify" => "id")),
|
||||||
"master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
"master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
|
||||||
"parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
"parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
||||||
"receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
),
|
),
|
||||||
"indexes" => array(
|
"indexes" => array(
|
||||||
"PRIMARY" => array("id"),
|
"PRIMARY" => array("id"),
|
||||||
|
@ -1278,7 +1328,7 @@ function db_definition() {
|
||||||
$database["pconfig"] = array(
|
$database["pconfig"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
|
"cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
|
||||||
"k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
|
"k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
|
||||||
"v" => array("type" => "mediumtext"),
|
"v" => array("type" => "mediumtext"),
|
||||||
|
@ -1291,8 +1341,8 @@ function db_definition() {
|
||||||
$database["photo"] = array(
|
$database["photo"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
"contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
|
||||||
"guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
|
"guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
|
||||||
"resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||||
|
@ -1315,6 +1365,7 @@ function db_definition() {
|
||||||
),
|
),
|
||||||
"indexes" => array(
|
"indexes" => array(
|
||||||
"PRIMARY" => array("id"),
|
"PRIMARY" => array("id"),
|
||||||
|
"contactid" => array("contact-id"),
|
||||||
"uid_contactid" => array("uid", "contact-id"),
|
"uid_contactid" => array("uid", "contact-id"),
|
||||||
"uid_profile" => array("uid", "profile"),
|
"uid_profile" => array("uid", "profile"),
|
||||||
"uid_album_scale_created" => array("uid", "album(32)", "scale", "created"),
|
"uid_album_scale_created" => array("uid", "album(32)", "scale", "created"),
|
||||||
|
@ -1325,7 +1376,7 @@ function db_definition() {
|
||||||
$database["poll"] = array(
|
$database["poll"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"q0" => array("type" => "text"),
|
"q0" => array("type" => "text"),
|
||||||
"q1" => array("type" => "text"),
|
"q1" => array("type" => "text"),
|
||||||
"q2" => array("type" => "text"),
|
"q2" => array("type" => "text"),
|
||||||
|
@ -1345,7 +1396,7 @@ function db_definition() {
|
||||||
$database["poll_result"] = array(
|
$database["poll_result"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("poll" => "id")),
|
||||||
"choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||||
),
|
),
|
||||||
"indexes" => array(
|
"indexes" => array(
|
||||||
|
@ -1368,7 +1419,7 @@ function db_definition() {
|
||||||
$database["profile"] = array(
|
$database["profile"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
"is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||||
"hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
"hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||||
|
@ -1418,8 +1469,8 @@ function db_definition() {
|
||||||
$database["profile_check"] = array(
|
$database["profile_check"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
"cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
|
||||||
"dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||||
|
@ -1431,7 +1482,7 @@ function db_definition() {
|
||||||
$database["push_subscriber"] = array(
|
$database["push_subscriber"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
|
@ -1446,7 +1497,7 @@ function db_definition() {
|
||||||
$database["queue"] = array(
|
$database["queue"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
|
||||||
"network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
|
"network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
|
||||||
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||||
"last" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
"last" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||||
|
@ -1467,7 +1518,7 @@ function db_definition() {
|
||||||
"id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||||
"uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
|
"language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
|
||||||
"note" => array("type" => "text"),
|
"note" => array("type" => "text"),
|
||||||
|
@ -1479,7 +1530,7 @@ function db_definition() {
|
||||||
$database["search"] = array(
|
$database["search"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
),
|
),
|
||||||
"indexes" => array(
|
"indexes" => array(
|
||||||
|
@ -1503,7 +1554,7 @@ function db_definition() {
|
||||||
$database["sign"] = array(
|
$database["sign"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
"iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
|
||||||
"signed_text" => array("type" => "mediumtext"),
|
"signed_text" => array("type" => "mediumtext"),
|
||||||
"signature" => array("type" => "text"),
|
"signature" => array("type" => "text"),
|
||||||
"signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
|
@ -1516,7 +1567,7 @@ function db_definition() {
|
||||||
$database["spam"] = array(
|
$database["spam"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||||
"ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||||
"term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
|
@ -1533,7 +1584,7 @@ function db_definition() {
|
||||||
$database["term"] = array(
|
$database["term"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
"oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
"oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
|
||||||
"otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
|
"otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
|
||||||
"type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
|
"type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
|
||||||
"term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
|
@ -1543,7 +1594,7 @@ function db_definition() {
|
||||||
"received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
"received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||||
"global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
"global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||||
"aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
"aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
||||||
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
),
|
),
|
||||||
"indexes" => array(
|
"indexes" => array(
|
||||||
"PRIMARY" => array("tid"),
|
"PRIMARY" => array("tid"),
|
||||||
|
@ -1555,12 +1606,12 @@ function db_definition() {
|
||||||
);
|
);
|
||||||
$database["thread"] = array(
|
$database["thread"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
|
"iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => array("item" => "id")),
|
||||||
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
"contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
|
"contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
|
||||||
"gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
|
"gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
|
||||||
"owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
|
"owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
|
||||||
"author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
|
"author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
|
||||||
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||||
"edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
"edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||||
"commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
"commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||||
|
@ -1588,6 +1639,9 @@ function db_definition() {
|
||||||
"uid_network_created" => array("uid","network","created"),
|
"uid_network_created" => array("uid","network","created"),
|
||||||
"uid_contactid_commented" => array("uid","contact-id","commented"),
|
"uid_contactid_commented" => array("uid","contact-id","commented"),
|
||||||
"uid_contactid_created" => array("uid","contact-id","created"),
|
"uid_contactid_created" => array("uid","contact-id","created"),
|
||||||
|
"contactid" => array("contact-id"),
|
||||||
|
"ownerid" => array("owner-id"),
|
||||||
|
"authorid" => array("author-id"),
|
||||||
"uid_created" => array("uid","created"),
|
"uid_created" => array("uid","created"),
|
||||||
"uid_commented" => array("uid","commented"),
|
"uid_commented" => array("uid","commented"),
|
||||||
"uid_wall_created" => array("uid","wall","created"),
|
"uid_wall_created" => array("uid","wall","created"),
|
||||||
|
@ -1597,10 +1651,10 @@ function db_definition() {
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
|
"id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
|
||||||
"secret" => array("type" => "text"),
|
"secret" => array("type" => "text"),
|
||||||
"client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
|
"client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
|
||||||
"expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||||
"scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
|
"scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
|
||||||
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||||
),
|
),
|
||||||
"indexes" => array(
|
"indexes" => array(
|
||||||
"PRIMARY" => array("id"),
|
"PRIMARY" => array("id"),
|
||||||
|
@ -1691,8 +1745,8 @@ function db_definition() {
|
||||||
function dbstructure_run(&$argv, &$argc) {
|
function dbstructure_run(&$argv, &$argc) {
|
||||||
global $a, $db;
|
global $a, $db;
|
||||||
|
|
||||||
if (is_null($a)){
|
if (is_null($a)) {
|
||||||
$a = new App;
|
$a = new App(dirname(__DIR__));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($db)) {
|
if (is_null($db)) {
|
||||||
|
@ -1730,6 +1784,9 @@ function dbstructure_run(&$argv, &$argc) {
|
||||||
case "dumpsql":
|
case "dumpsql":
|
||||||
print_structure(db_definition());
|
print_structure(db_definition());
|
||||||
return;
|
return;
|
||||||
|
case "toinnodb":
|
||||||
|
convert_to_innodb();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1741,11 +1798,12 @@ function dbstructure_run(&$argv, &$argc) {
|
||||||
echo "dryrun show database update schema queries without running them\n";
|
echo "dryrun show database update schema queries without running them\n";
|
||||||
echo "update update database schema\n";
|
echo "update update database schema\n";
|
||||||
echo "dumpsql dump database schema\n";
|
echo "dumpsql dump database schema\n";
|
||||||
|
echo "toinnodb convert all tables from MyISAM to InnoDB\n";
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_search(__file__,get_included_files())===0){
|
if (array_search(__file__,get_included_files())===0) {
|
||||||
dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);
|
dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
function dbupdate_run(&$argv, &$argc) {
|
function dbupdate_run(&$argv, &$argc) {
|
||||||
global $a;
|
global $a;
|
||||||
|
|
|
@ -1,21 +1,22 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\App;
|
||||||
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
require_once('include/queue_fn.php');
|
require_once 'include/queue_fn.php';
|
||||||
require_once('include/html2plain.php');
|
require_once 'include/html2plain.php';
|
||||||
require_once('include/Scrape.php');
|
require_once 'include/probe.php';
|
||||||
require_once('include/diaspora.php');
|
require_once 'include/diaspora.php';
|
||||||
require_once('include/ostatus.php');
|
require_once 'include/ostatus.php';
|
||||||
require_once('include/dfrn.php');
|
require_once 'include/dfrn.php';
|
||||||
|
|
||||||
function delivery_run(&$argv, &$argc){
|
function delivery_run(&$argv, &$argc){
|
||||||
global $a;
|
global $a;
|
||||||
|
|
||||||
require_once('include/datetime.php');
|
require_once 'include/datetime.php';
|
||||||
require_once('include/items.php');
|
require_once 'include/items.php';
|
||||||
require_once('include/bbcode.php');
|
require_once 'include/bbcode.php';
|
||||||
require_once('include/email.php');
|
require_once 'include/email.php';
|
||||||
|
|
||||||
if ($argc < 3) {
|
if ($argc < 3) {
|
||||||
return;
|
return;
|
||||||
|
@ -165,7 +166,7 @@ function delivery_run(&$argv, &$argc){
|
||||||
$public_message = true;
|
$public_message = true;
|
||||||
|
|
||||||
if (!($mail || $fsuggest || $relocate)) {
|
if (!($mail || $fsuggest || $relocate)) {
|
||||||
require_once('include/group.php');
|
require_once 'include/group.php';
|
||||||
|
|
||||||
$parent = $items[0];
|
$parent = $items[0];
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
* https://github.com/friendica/friendica/blob/master/spec/dfrn2.pdf
|
* https://github.com/friendica/friendica/blob/master/spec/dfrn2.pdf
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
|
||||||
require_once("include/Contact.php");
|
require_once("include/Contact.php");
|
||||||
require_once("include/ostatus.php");
|
require_once("include/ostatus.php");
|
||||||
require_once("include/enotify.php");
|
require_once("include/enotify.php");
|
||||||
|
@ -370,7 +372,7 @@ class dfrn {
|
||||||
$ext = Photo::supportedTypes();
|
$ext = Photo::supportedTypes();
|
||||||
|
|
||||||
foreach ($rp as $p) {
|
foreach ($rp as $p) {
|
||||||
$photos[$p['scale']] = app::get_baseurl().'/photo/'.$p['resource-id'].'-'.$p['scale'].'.'.$ext[$p['type']];
|
$photos[$p['scale']] = App::get_baseurl().'/photo/'.$p['resource-id'].'-'.$p['scale'].'.'.$ext[$p['type']];
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($rp, $ext);
|
unset($rp, $ext);
|
||||||
|
@ -431,7 +433,7 @@ class dfrn {
|
||||||
$root->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS);
|
$root->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS);
|
||||||
$root->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
|
$root->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
|
||||||
|
|
||||||
xml::add_element($doc, $root, "id", app::get_baseurl()."/profile/".$owner["nick"]);
|
xml::add_element($doc, $root, "id", App::get_baseurl()."/profile/".$owner["nick"]);
|
||||||
xml::add_element($doc, $root, "title", $owner["name"]);
|
xml::add_element($doc, $root, "title", $owner["name"]);
|
||||||
|
|
||||||
$attributes = array("uri" => "https://friendi.ca", "version" => FRIENDICA_VERSION."-".DB_UPDATE_VERSION);
|
$attributes = array("uri" => "https://friendi.ca", "version" => FRIENDICA_VERSION."-".DB_UPDATE_VERSION);
|
||||||
|
@ -448,13 +450,13 @@ class dfrn {
|
||||||
// DFRN itself doesn't uses this. But maybe someone else wants to subscribe to the public feed.
|
// DFRN itself doesn't uses this. But maybe someone else wants to subscribe to the public feed.
|
||||||
ostatus::hublinks($doc, $root);
|
ostatus::hublinks($doc, $root);
|
||||||
|
|
||||||
$attributes = array("rel" => "salmon", "href" => app::get_baseurl()."/salmon/".$owner["nick"]);
|
$attributes = array("rel" => "salmon", "href" => App::get_baseurl()."/salmon/".$owner["nick"]);
|
||||||
xml::add_element($doc, $root, "link", "", $attributes);
|
xml::add_element($doc, $root, "link", "", $attributes);
|
||||||
|
|
||||||
$attributes = array("rel" => "http://salmon-protocol.org/ns/salmon-replies", "href" => app::get_baseurl()."/salmon/".$owner["nick"]);
|
$attributes = array("rel" => "http://salmon-protocol.org/ns/salmon-replies", "href" => App::get_baseurl()."/salmon/".$owner["nick"]);
|
||||||
xml::add_element($doc, $root, "link", "", $attributes);
|
xml::add_element($doc, $root, "link", "", $attributes);
|
||||||
|
|
||||||
$attributes = array("rel" => "http://salmon-protocol.org/ns/salmon-mention", "href" => app::get_baseurl()."/salmon/".$owner["nick"]);
|
$attributes = array("rel" => "http://salmon-protocol.org/ns/salmon-mention", "href" => App::get_baseurl()."/salmon/".$owner["nick"]);
|
||||||
xml::add_element($doc, $root, "link", "", $attributes);
|
xml::add_element($doc, $root, "link", "", $attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -511,7 +513,7 @@ class dfrn {
|
||||||
}
|
}
|
||||||
|
|
||||||
xml::add_element($doc, $author, "name", $owner["name"], $attributes);
|
xml::add_element($doc, $author, "name", $owner["name"], $attributes);
|
||||||
xml::add_element($doc, $author, "uri", app::get_baseurl().'/profile/'.$owner["nickname"], $attributes);
|
xml::add_element($doc, $author, "uri", App::get_baseurl().'/profile/'.$owner["nickname"], $attributes);
|
||||||
xml::add_element($doc, $author, "dfrn:handle", $owner["addr"], $attributes);
|
xml::add_element($doc, $author, "dfrn:handle", $owner["addr"], $attributes);
|
||||||
|
|
||||||
$attributes = array("rel" => "photo", "type" => "image/jpeg",
|
$attributes = array("rel" => "photo", "type" => "image/jpeg",
|
||||||
|
@ -812,11 +814,33 @@ class dfrn {
|
||||||
$parent = q("SELECT `guid` FROM `item` WHERE `id` = %d", intval($item["parent"]));
|
$parent = q("SELECT `guid` FROM `item` WHERE `id` = %d", intval($item["parent"]));
|
||||||
$parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']);
|
$parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']);
|
||||||
$attributes = array("ref" => $parent_item, "type" => "text/html",
|
$attributes = array("ref" => $parent_item, "type" => "text/html",
|
||||||
"href" => app::get_baseurl().'/display/'.$parent[0]['guid'],
|
"href" => App::get_baseurl().'/display/'.$parent[0]['guid'],
|
||||||
"dfrn:diaspora_guid" => $parent[0]['guid']);
|
"dfrn:diaspora_guid" => $parent[0]['guid']);
|
||||||
xml::add_element($doc, $entry, "thr:in-reply-to", "", $attributes);
|
xml::add_element($doc, $entry, "thr:in-reply-to", "", $attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add conversation data. This is used for OStatus
|
||||||
|
$conversation_href = App::get_baseurl()."/display/".$owner["nick"]."/".$item["parent"];
|
||||||
|
$conversation_uri = $conversation_href;
|
||||||
|
|
||||||
|
if (isset($parent_item)) {
|
||||||
|
$r = dba::fetch_first("SELECT `conversation-uri`, `conversation-href` FROM `conversation` WHERE `item-uri` = ?", $item['parent-uri']);
|
||||||
|
if (dbm::is_result($r)) {
|
||||||
|
if ($r['conversation-uri'] != '') {
|
||||||
|
$conversation_uri = $r['conversation-uri'];
|
||||||
|
}
|
||||||
|
if ($r['conversation-href'] != '') {
|
||||||
|
$conversation_href = $r['conversation-href'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$attributes = array(
|
||||||
|
"href" => $conversation_href,
|
||||||
|
"ref" => $conversation_uri);
|
||||||
|
|
||||||
|
xml::add_element($doc, $entry, "ostatus:conversation", $conversation_uri, $attributes);
|
||||||
|
|
||||||
xml::add_element($doc, $entry, "id", $item["uri"]);
|
xml::add_element($doc, $entry, "id", $item["uri"]);
|
||||||
xml::add_element($doc, $entry, "title", $item["title"]);
|
xml::add_element($doc, $entry, "title", $item["title"]);
|
||||||
|
|
||||||
|
@ -832,7 +856,7 @@ class dfrn {
|
||||||
|
|
||||||
// We save this value in "plink". Maybe we should read it from there as well?
|
// We save this value in "plink". Maybe we should read it from there as well?
|
||||||
xml::add_element($doc, $entry, "link", "", array("rel" => "alternate", "type" => "text/html",
|
xml::add_element($doc, $entry, "link", "", array("rel" => "alternate", "type" => "text/html",
|
||||||
"href" => app::get_baseurl()."/display/".$item["guid"]));
|
"href" => App::get_baseurl()."/display/".$item["guid"]));
|
||||||
|
|
||||||
// "comment-allow" is some old fashioned stuff for old Friendica versions.
|
// "comment-allow" is some old fashioned stuff for old Friendica versions.
|
||||||
// It is included in the rewritten code for completeness
|
// It is included in the rewritten code for completeness
|
||||||
|
@ -2209,12 +2233,16 @@ class dfrn {
|
||||||
* @param array $importer Record of the importer user mixed with contact of the content
|
* @param array $importer Record of the importer user mixed with contact of the content
|
||||||
* @todo Add type-hints
|
* @todo Add type-hints
|
||||||
*/
|
*/
|
||||||
private static function process_entry($header, $xpath, $entry, $importer) {
|
private static function process_entry($header, $xpath, $entry, $importer, $xml) {
|
||||||
|
|
||||||
logger("Processing entries");
|
logger("Processing entries");
|
||||||
|
|
||||||
$item = $header;
|
$item = $header;
|
||||||
|
|
||||||
|
$item["protocol"] = PROTOCOL_DFRN;
|
||||||
|
|
||||||
|
$item["source"] = $xml;
|
||||||
|
|
||||||
// Get the uri
|
// Get the uri
|
||||||
$item["uri"] = $xpath->query("atom:id/text()", $entry)->item(0)->nodeValue;
|
$item["uri"] = $xpath->query("atom:id/text()", $entry)->item(0)->nodeValue;
|
||||||
|
|
||||||
|
@ -2373,6 +2401,20 @@ class dfrn {
|
||||||
self::parse_links($links, $item);
|
self::parse_links($links, $item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$item['conversation-uri'] = $xpath->query('ostatus:conversation/text()', $entry)->item(0)->nodeValue;
|
||||||
|
|
||||||
|
$conv = $xpath->query('ostatus:conversation', $entry);
|
||||||
|
if (is_object($conv->item(0))) {
|
||||||
|
foreach ($conv->item(0)->attributes AS $attributes) {
|
||||||
|
if ($attributes->name == "ref") {
|
||||||
|
$item['conversation-uri'] = $attributes->textContent;
|
||||||
|
}
|
||||||
|
if ($attributes->name == "href") {
|
||||||
|
$item['conversation-href'] = $attributes->textContent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Is it a reply or a top level posting?
|
// Is it a reply or a top level posting?
|
||||||
$item["parent-uri"] = $item["uri"];
|
$item["parent-uri"] = $item["uri"];
|
||||||
|
|
||||||
|
@ -2801,7 +2843,7 @@ class dfrn {
|
||||||
if (!$sort_by_date) {
|
if (!$sort_by_date) {
|
||||||
$entries = $xpath->query("/atom:feed/atom:entry");
|
$entries = $xpath->query("/atom:feed/atom:entry");
|
||||||
foreach ($entries AS $entry) {
|
foreach ($entries AS $entry) {
|
||||||
self::process_entry($header, $xpath, $entry, $importer);
|
self::process_entry($header, $xpath, $entry, $importer, $xml);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$newentries = array();
|
$newentries = array();
|
||||||
|
@ -2815,7 +2857,7 @@ class dfrn {
|
||||||
ksort($newentries);
|
ksort($newentries);
|
||||||
|
|
||||||
foreach ($newentries AS $entry) {
|
foreach ($newentries AS $entry) {
|
||||||
self::process_entry($header, $xpath, $entry, $importer);
|
self::process_entry($header, $xpath, $entry, $importer, $xml);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger("Import done for user " . $importer["uid"] . " from contact " . $importer["id"], LOGGER_DEBUG);
|
logger("Import done for user " . $importer["uid"] . " from contact " . $importer["id"], LOGGER_DEBUG);
|
||||||
|
|
|
@ -8,11 +8,12 @@
|
||||||
* This will change in the future.
|
* This will change in the future.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\App;
|
||||||
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
require_once 'include/items.php';
|
require_once 'include/items.php';
|
||||||
require_once 'include/bb2diaspora.php';
|
require_once 'include/bb2diaspora.php';
|
||||||
require_once 'include/Scrape.php';
|
require_once 'include/probe.php';
|
||||||
require_once 'include/Contact.php';
|
require_once 'include/Contact.php';
|
||||||
require_once 'include/Photo.php';
|
require_once 'include/Photo.php';
|
||||||
require_once 'include/socgraph.php';
|
require_once 'include/socgraph.php';
|
||||||
|
@ -187,7 +188,80 @@ class Diaspora {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief: Decodes incoming Diaspora message
|
* @brief: Decodes incoming Diaspora message in the new format
|
||||||
|
*
|
||||||
|
* @param array $importer Array of the importer user
|
||||||
|
* @param string $raw raw post message
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* 'message' -> decoded Diaspora XML message
|
||||||
|
* 'author' -> author diaspora handle
|
||||||
|
* 'key' -> author public key (converted to pkcs#8)
|
||||||
|
*/
|
||||||
|
public static function decode_raw($importer, $raw) {
|
||||||
|
$data = json_decode($raw);
|
||||||
|
|
||||||
|
// Is it a private post? Then decrypt the outer Salmon
|
||||||
|
if (is_object($data)) {
|
||||||
|
$encrypted_aes_key_bundle = base64_decode($data->aes_key);
|
||||||
|
$ciphertext = base64_decode($data->encrypted_magic_envelope);
|
||||||
|
|
||||||
|
$outer_key_bundle = '';
|
||||||
|
@openssl_private_decrypt($encrypted_aes_key_bundle, $outer_key_bundle, $importer['prvkey']);
|
||||||
|
$j_outer_key_bundle = json_decode($outer_key_bundle);
|
||||||
|
|
||||||
|
if (!is_object($j_outer_key_bundle)) {
|
||||||
|
logger('Outer Salmon did not verify. Discarding.');
|
||||||
|
http_status_exit(400);
|
||||||
|
}
|
||||||
|
|
||||||
|
$outer_iv = base64_decode($j_outer_key_bundle->iv);
|
||||||
|
$outer_key = base64_decode($j_outer_key_bundle->key);
|
||||||
|
|
||||||
|
$xml = diaspora::aes_decrypt($outer_key, $outer_iv, $ciphertext);
|
||||||
|
} else {
|
||||||
|
$xml = $raw;
|
||||||
|
}
|
||||||
|
|
||||||
|
$basedom = parse_xml_string($xml);
|
||||||
|
|
||||||
|
if (!is_object($basedom)) {
|
||||||
|
logger('Received data does not seem to be an XML. Discarding.');
|
||||||
|
http_status_exit(400);
|
||||||
|
}
|
||||||
|
|
||||||
|
$base = $basedom->children(NAMESPACE_SALMON_ME);
|
||||||
|
|
||||||
|
// Not sure if this cleaning is needed
|
||||||
|
$data = str_replace(array(" ", "\t", "\r", "\n"), array("", "", "", ""), $base->data);
|
||||||
|
|
||||||
|
// Build the signed data
|
||||||
|
$type = $base->data[0]->attributes()->type[0];
|
||||||
|
$encoding = $base->encoding;
|
||||||
|
$alg = $base->alg;
|
||||||
|
$signed_data = $data.'.'.base64url_encode($type).'.'.base64url_encode($encoding).'.'.base64url_encode($alg);
|
||||||
|
|
||||||
|
// This is the signature
|
||||||
|
$signature = base64url_decode($base->sig);
|
||||||
|
|
||||||
|
// Get the senders' public key
|
||||||
|
$key_id = $base->sig[0]->attributes()->key_id[0];
|
||||||
|
$author_addr = base64_decode($key_id);
|
||||||
|
$key = diaspora::key($author_addr);
|
||||||
|
|
||||||
|
$verify = rsa_verify($signed_data, $signature, $key);
|
||||||
|
if (!$verify) {
|
||||||
|
logger('Message did not verify. Discarding.');
|
||||||
|
http_status_exit(400);
|
||||||
|
}
|
||||||
|
|
||||||
|
return array('message' => (string)base64url_decode($base->data),
|
||||||
|
'author' => unxmlify($author_addr),
|
||||||
|
'key' => (string)$key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief: Decodes incoming Diaspora message in the deprecated format
|
||||||
*
|
*
|
||||||
* @param array $importer Array of the importer user
|
* @param array $importer Array of the importer user
|
||||||
* @param string $xml urldecoded Diaspora salmon
|
* @param string $xml urldecoded Diaspora salmon
|
||||||
|
@ -202,9 +276,10 @@ class Diaspora {
|
||||||
$public = false;
|
$public = false;
|
||||||
$basedom = parse_xml_string($xml);
|
$basedom = parse_xml_string($xml);
|
||||||
|
|
||||||
if (!is_object($basedom))
|
if (!is_object($basedom)) {
|
||||||
|
logger("XML is not parseable.");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
$children = $basedom->children('https://joindiaspora.com/protocol');
|
$children = $basedom->children('https://joindiaspora.com/protocol');
|
||||||
|
|
||||||
if ($children->header) {
|
if ($children->header) {
|
||||||
|
@ -333,6 +408,24 @@ class Diaspora {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!($postdata = self::valid_posting($msg))) {
|
||||||
|
logger("Invalid posting");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$fields = $postdata['fields'];
|
||||||
|
|
||||||
|
// Is it a an action (comment, like, ...) for our own post?
|
||||||
|
if (isset($fields->parent_guid) AND !$postdata["relayed"]) {
|
||||||
|
$guid = notags(unxmlify($fields->parent_guid));
|
||||||
|
$importer = self::importer_for_guid($guid);
|
||||||
|
if (is_array($importer)) {
|
||||||
|
logger("delivering to origin: ".$importer["name"]);
|
||||||
|
$message_id = self::dispatch($importer, $msg, $fields);
|
||||||
|
return $message_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Now distribute it to the followers
|
// Now distribute it to the followers
|
||||||
$r = q("SELECT `user`.* FROM `user` WHERE `user`.`uid` IN
|
$r = q("SELECT `user`.* FROM `user` WHERE `user`.`uid` IN
|
||||||
(SELECT `contact`.`uid` FROM `contact` WHERE `contact`.`network` = '%s' AND `contact`.`addr` = '%s')
|
(SELECT `contact`.`uid` FROM `contact` WHERE `contact`.`network` = '%s' AND `contact`.`addr` = '%s')
|
||||||
|
@ -344,18 +437,14 @@ class Diaspora {
|
||||||
if (dbm::is_result($r)) {
|
if (dbm::is_result($r)) {
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
logger("delivering to: ".$rr["username"]);
|
logger("delivering to: ".$rr["username"]);
|
||||||
self::dispatch($rr,$msg);
|
self::dispatch($rr, $msg, $fields);
|
||||||
}
|
}
|
||||||
} else {
|
} elseif (!Config::get('system', 'relay_subscribe', false)) {
|
||||||
$social_relay = (bool)Config::get('system', 'relay_subscribe', false);
|
|
||||||
|
|
||||||
// Use a dummy importer to import the data for the public copy
|
|
||||||
if ($social_relay) {
|
|
||||||
$importer = array("uid" => 0, "page-flags" => PAGE_FREELOVE);
|
|
||||||
$message_id = self::dispatch($importer,$msg);
|
|
||||||
} else {
|
|
||||||
logger("Unwanted message from ".$msg["author"]." send by ".$_SERVER["REMOTE_ADDR"]." with ".$_SERVER["HTTP_USER_AGENT"].": ".print_r($msg, true), LOGGER_DEBUG);
|
logger("Unwanted message from ".$msg["author"]." send by ".$_SERVER["REMOTE_ADDR"]." with ".$_SERVER["HTTP_USER_AGENT"].": ".print_r($msg, true), LOGGER_DEBUG);
|
||||||
}
|
} else {
|
||||||
|
// Use a dummy importer to import the data for the public copy
|
||||||
|
$importer = array("uid" => 0, "page-flags" => PAGE_FREELOVE);
|
||||||
|
$message_id = self::dispatch($importer, $msg, $fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $message_id;
|
return $message_id;
|
||||||
|
@ -366,19 +455,24 @@ class Diaspora {
|
||||||
*
|
*
|
||||||
* @param array $importer Array of the importer user
|
* @param array $importer Array of the importer user
|
||||||
* @param array $msg The post that will be dispatched
|
* @param array $msg The post that will be dispatched
|
||||||
|
* @param object $fields SimpleXML object that contains the message
|
||||||
*
|
*
|
||||||
* @return int The message id of the generated message, "true" or "false" if there was an error
|
* @return int The message id of the generated message, "true" or "false" if there was an error
|
||||||
*/
|
*/
|
||||||
public static function dispatch($importer, $msg) {
|
public static function dispatch($importer, $msg, $fields = null) {
|
||||||
|
|
||||||
// The sender is the handle of the contact that sent the message.
|
// The sender is the handle of the contact that sent the message.
|
||||||
// This will often be different with relayed messages (for example "like" and "comment")
|
// This will often be different with relayed messages (for example "like" and "comment")
|
||||||
$sender = $msg["author"];
|
$sender = $msg["author"];
|
||||||
|
|
||||||
if (!self::valid_posting($msg, $fields)) {
|
// This is only needed for private postings since this is already done for public ones before
|
||||||
|
if (is_null($fields)) {
|
||||||
|
if (!($postdata = self::valid_posting($msg))) {
|
||||||
logger("Invalid posting");
|
logger("Invalid posting");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
$fields = $postdata['fields'];
|
||||||
|
}
|
||||||
|
|
||||||
$type = $fields->getName();
|
$type = $fields->getName();
|
||||||
|
|
||||||
|
@ -439,11 +533,10 @@ class Diaspora {
|
||||||
* It also does the conversion between the old and the new diaspora format.
|
* It also does the conversion between the old and the new diaspora format.
|
||||||
*
|
*
|
||||||
* @param array $msg Array with the XML, the sender handle and the sender signature
|
* @param array $msg Array with the XML, the sender handle and the sender signature
|
||||||
* @param object $fields SimpleXML object that contains the posting when it is valid
|
|
||||||
*
|
*
|
||||||
* @return bool Is the posting valid?
|
* @return bool|array If the posting is valid then an array with an SimpleXML object is returned
|
||||||
*/
|
*/
|
||||||
private static function valid_posting($msg, &$fields) {
|
private static function valid_posting($msg) {
|
||||||
|
|
||||||
$data = parse_xml_string($msg["message"], false);
|
$data = parse_xml_string($msg["message"], false);
|
||||||
|
|
||||||
|
@ -484,34 +577,40 @@ class Diaspora {
|
||||||
foreach ($element->children() AS $fieldname => $entry) {
|
foreach ($element->children() AS $fieldname => $entry) {
|
||||||
if ($oldXML) {
|
if ($oldXML) {
|
||||||
// Translation for the old XML structure
|
// Translation for the old XML structure
|
||||||
if ($fieldname == "diaspora_handle")
|
if ($fieldname == "diaspora_handle") {
|
||||||
$fieldname = "author";
|
$fieldname = "author";
|
||||||
|
}
|
||||||
if ($fieldname == "participant_handles")
|
if ($fieldname == "participant_handles") {
|
||||||
$fieldname = "participants";
|
$fieldname = "participants";
|
||||||
|
}
|
||||||
if (in_array($type, array("like", "participation"))) {
|
if (in_array($type, array("like", "participation"))) {
|
||||||
if ($fieldname == "target_type")
|
if ($fieldname == "target_type") {
|
||||||
$fieldname = "parent_type";
|
$fieldname = "parent_type";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ($fieldname == "sender_handle")
|
if ($fieldname == "sender_handle") {
|
||||||
$fieldname = "author";
|
$fieldname = "author";
|
||||||
|
}
|
||||||
if ($fieldname == "recipient_handle")
|
if ($fieldname == "recipient_handle") {
|
||||||
$fieldname = "recipient";
|
$fieldname = "recipient";
|
||||||
|
}
|
||||||
if ($fieldname == "root_diaspora_id")
|
if ($fieldname == "root_diaspora_id") {
|
||||||
$fieldname = "root_author";
|
$fieldname = "root_author";
|
||||||
|
}
|
||||||
|
if ($type == "status_message") {
|
||||||
|
if ($fieldname == "raw_message") {
|
||||||
|
$fieldname = "text";
|
||||||
|
}
|
||||||
|
}
|
||||||
if ($type == "retraction") {
|
if ($type == "retraction") {
|
||||||
if ($fieldname == "post_guid")
|
if ($fieldname == "post_guid") {
|
||||||
$fieldname = "target_guid";
|
$fieldname = "target_guid";
|
||||||
|
}
|
||||||
if ($fieldname == "type")
|
if ($fieldname == "type") {
|
||||||
$fieldname = "target_type";
|
$fieldname = "target_type";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (($fieldname == "author_signature") AND ($entry != ""))
|
if (($fieldname == "author_signature") AND ($entry != ""))
|
||||||
$author_signature = base64_decode($entry);
|
$author_signature = base64_decode($entry);
|
||||||
|
@ -538,9 +637,9 @@ class Diaspora {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only some message types have signatures. So we quit here for the other types.
|
// Only some message types have signatures. So we quit here for the other types.
|
||||||
if (!in_array($type, array("comment", "message", "like")))
|
if (!in_array($type, array("comment", "like"))) {
|
||||||
return true;
|
return array("fields" => $fields, "relayed" => false);
|
||||||
|
}
|
||||||
// No author_signature? This is a must, so we quit.
|
// No author_signature? This is a must, so we quit.
|
||||||
if (!isset($author_signature)) {
|
if (!isset($author_signature)) {
|
||||||
logger("No author signature for type ".$type." - Message: ".$msg["message"], LOGGER_DEBUG);
|
logger("No author signature for type ".$type." - Message: ".$msg["message"], LOGGER_DEBUG);
|
||||||
|
@ -548,12 +647,16 @@ class Diaspora {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($parent_author_signature)) {
|
if (isset($parent_author_signature)) {
|
||||||
|
$relayed = true;
|
||||||
|
|
||||||
$key = self::key($msg["author"]);
|
$key = self::key($msg["author"]);
|
||||||
|
|
||||||
if (!rsa_verify($signed_data, $parent_author_signature, $key, "sha256")) {
|
if (!rsa_verify($signed_data, $parent_author_signature, $key, "sha256")) {
|
||||||
logger("No valid parent author signature for parent author ".$msg["author"]. " in type ".$type." - signed data: ".$signed_data." - Message: ".$msg["message"]." - Signature ".$parent_author_signature, LOGGER_DEBUG);
|
logger("No valid parent author signature for parent author ".$msg["author"]. " in type ".$type." - signed data: ".$signed_data." - Message: ".$msg["message"]." - Signature ".$parent_author_signature, LOGGER_DEBUG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$relayed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$key = self::key($fields->author);
|
$key = self::key($fields->author);
|
||||||
|
@ -561,8 +664,9 @@ class Diaspora {
|
||||||
if (!rsa_verify($signed_data, $author_signature, $key, "sha256")) {
|
if (!rsa_verify($signed_data, $author_signature, $key, "sha256")) {
|
||||||
logger("No valid author signature for author ".$fields->author. " in type ".$type." - signed data: ".$signed_data." - Message: ".$msg["message"]." - Signature ".$author_signature, LOGGER_DEBUG);
|
logger("No valid author signature for author ".$fields->author. " in type ".$type." - signed data: ".$signed_data." - Message: ".$msg["message"]." - Signature ".$author_signature, LOGGER_DEBUG);
|
||||||
return false;
|
return false;
|
||||||
} else
|
} else {
|
||||||
return true;
|
return array("fields" => $fields, "relayed" => $relayed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -591,7 +695,7 @@ class Diaspora {
|
||||||
*
|
*
|
||||||
* @return array the queried data
|
* @return array the queried data
|
||||||
*/
|
*/
|
||||||
private static function person_by_handle($handle) {
|
public static function person_by_handle($handle) {
|
||||||
|
|
||||||
$r = q("SELECT * FROM `fcontact` WHERE `network` = '%s' AND `addr` = '%s' LIMIT 1",
|
$r = q("SELECT * FROM `fcontact` WHERE `network` = '%s' AND `addr` = '%s' LIMIT 1",
|
||||||
dbesc(NETWORK_DIASPORA),
|
dbesc(NETWORK_DIASPORA),
|
||||||
|
@ -828,17 +932,20 @@ class Diaspora {
|
||||||
logger("defining user ".$contact["nick"]." as friend");
|
logger("defining user ".$contact["nick"]." as friend");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($contact["blocked"]) || ($contact["readonly"]) || ($contact["archive"]))
|
// We don't seem to like that person
|
||||||
|
if ($contact["blocked"] || $contact["readonly"] || $contact["archive"]) {
|
||||||
return false;
|
return false;
|
||||||
if ($contact["rel"] == CONTACT_IS_SHARING || $contact["rel"] == CONTACT_IS_FRIEND)
|
// We are following this person? Then it is okay
|
||||||
|
} elseif (($contact["rel"] == CONTACT_IS_SHARING) || ($contact["rel"] == CONTACT_IS_FRIEND)) {
|
||||||
return true;
|
return true;
|
||||||
if ($contact["rel"] == CONTACT_IS_FOLLOWER)
|
// Is it a post to a community? That's good
|
||||||
if (($importer["page-flags"] == PAGE_COMMUNITY) OR $is_comment)
|
} elseif (($contact["rel"] == CONTACT_IS_FOLLOWER) && ($importer["page-flags"] == PAGE_COMMUNITY)) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
// Messages for the global users are always accepted
|
// Messages for the global users and comments are always accepted
|
||||||
if ($importer["uid"] == 0)
|
if (($importer["uid"] == 0) || $is_comment) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -856,8 +963,13 @@ class Diaspora {
|
||||||
$contact = self::contact_by_handle($importer["uid"], $handle);
|
$contact = self::contact_by_handle($importer["uid"], $handle);
|
||||||
if (!$contact) {
|
if (!$contact) {
|
||||||
logger("A Contact for handle ".$handle." and user ".$importer["uid"]." was not found");
|
logger("A Contact for handle ".$handle." and user ".$importer["uid"]." was not found");
|
||||||
|
// If a contact isn't found, we accept it anyway if it is a comment
|
||||||
|
if ($is_comment) {
|
||||||
|
return $importer;
|
||||||
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!self::post_allow($importer, $contact, $is_comment)) {
|
if (!self::post_allow($importer, $contact, $is_comment)) {
|
||||||
logger("The handle: ".$handle." is not allowed to post to user ".$importer["uid"]);
|
logger("The handle: ".$handle." is not allowed to post to user ".$importer["uid"]);
|
||||||
|
@ -1111,9 +1223,9 @@ class Diaspora {
|
||||||
$cid = $r[0]["id"];
|
$cid = $r[0]["id"];
|
||||||
$network = $r[0]["network"];
|
$network = $r[0]["network"];
|
||||||
|
|
||||||
// We are receiving content from a user that is about to be terminated
|
// We are receiving content from a user that possibly is about to be terminated
|
||||||
// This means the user is vital, so we remove a possible termination date.
|
// This means the user is vital, so we remove a possible termination date.
|
||||||
unmark_for_death($contact);
|
unmark_for_death($r[0]);
|
||||||
} else {
|
} else {
|
||||||
$cid = $contact["id"];
|
$cid = $contact["id"];
|
||||||
$network = NETWORK_DIASPORA;
|
$network = NETWORK_DIASPORA;
|
||||||
|
@ -1227,6 +1339,26 @@ class Diaspora {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Find the best importer for a comment, like, ...
|
||||||
|
*
|
||||||
|
* @param string $guid The guid of the item
|
||||||
|
*
|
||||||
|
* @return array|boolean the origin owner of that post - or false
|
||||||
|
*/
|
||||||
|
private static function importer_for_guid($guid) {
|
||||||
|
$item = dba::fetch_first("SELECT `uid` FROM `item` WHERE `origin` AND `guid` = ? LIMIT 1", $guid);
|
||||||
|
|
||||||
|
if (dbm::is_result($item)) {
|
||||||
|
logger("Found user ".$item['uid']." as owner of item ".$guid, LOGGER_DEBUG);
|
||||||
|
$contact = dba::fetch_first("SELECT * FROM `contact` WHERE `self` AND `uid` = ?", $item['uid']);
|
||||||
|
if (dbm::is_result($contact)) {
|
||||||
|
return $contact;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Processes an incoming comment
|
* @brief Processes an incoming comment
|
||||||
*
|
*
|
||||||
|
@ -1238,10 +1370,10 @@ class Diaspora {
|
||||||
* @return int The message id of the generated comment or "false" if there was an error
|
* @return int The message id of the generated comment or "false" if there was an error
|
||||||
*/
|
*/
|
||||||
private static function receive_comment($importer, $sender, $data, $xml) {
|
private static function receive_comment($importer, $sender, $data, $xml) {
|
||||||
|
$author = notags(unxmlify($data->author));
|
||||||
$guid = notags(unxmlify($data->guid));
|
$guid = notags(unxmlify($data->guid));
|
||||||
$parent_guid = notags(unxmlify($data->parent_guid));
|
$parent_guid = notags(unxmlify($data->parent_guid));
|
||||||
$text = unxmlify($data->text);
|
$text = unxmlify($data->text);
|
||||||
$author = notags(unxmlify($data->author));
|
|
||||||
|
|
||||||
if (isset($data->created_at)) {
|
if (isset($data->created_at)) {
|
||||||
$created_at = datetime_convert("UTC", "UTC", notags(unxmlify($data->created_at)));
|
$created_at = datetime_convert("UTC", "UTC", notags(unxmlify($data->created_at)));
|
||||||
|
@ -1308,7 +1440,9 @@ class Diaspora {
|
||||||
}
|
}
|
||||||
|
|
||||||
$datarray["object-type"] = ACTIVITY_OBJ_COMMENT;
|
$datarray["object-type"] = ACTIVITY_OBJ_COMMENT;
|
||||||
$datarray["object"] = $xml;
|
|
||||||
|
$datarray["protocol"] = PROTOCOL_DIASPORA;
|
||||||
|
$datarray["source"] = $xml;
|
||||||
|
|
||||||
$datarray["changed"] = $datarray["created"] = $datarray["edited"] = $created_at;
|
$datarray["changed"] = $datarray["created"] = $datarray["edited"] = $created_at;
|
||||||
|
|
||||||
|
@ -1354,16 +1488,9 @@ class Diaspora {
|
||||||
* @return bool "true" if it was successful
|
* @return bool "true" if it was successful
|
||||||
*/
|
*/
|
||||||
private static function receive_conversation_message($importer, $contact, $data, $msg, $mesg, $conversation) {
|
private static function receive_conversation_message($importer, $contact, $data, $msg, $mesg, $conversation) {
|
||||||
|
$author = notags(unxmlify($data->author));
|
||||||
$guid = notags(unxmlify($data->guid));
|
$guid = notags(unxmlify($data->guid));
|
||||||
$subject = notags(unxmlify($data->subject));
|
$subject = notags(unxmlify($data->subject));
|
||||||
$author = notags(unxmlify($data->author));
|
|
||||||
|
|
||||||
$msg_guid = notags(unxmlify($mesg->guid));
|
|
||||||
$msg_parent_guid = notags(unxmlify($mesg->parent_guid));
|
|
||||||
$msg_parent_author_signature = notags(unxmlify($mesg->parent_author_signature));
|
|
||||||
$msg_author_signature = notags(unxmlify($mesg->author_signature));
|
|
||||||
$msg_text = unxmlify($mesg->text);
|
|
||||||
$msg_created_at = datetime_convert("UTC", "UTC", notags(unxmlify($mesg->created_at)));
|
|
||||||
|
|
||||||
// "diaspora_handle" is the element name from the old version
|
// "diaspora_handle" is the element name from the old version
|
||||||
// "author" is the element name from the new version
|
// "author" is the element name from the new version
|
||||||
|
@ -1375,7 +1502,10 @@ class Diaspora {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$msg_guid = notags(unxmlify($mesg->guid));
|
||||||
$msg_conversation_guid = notags(unxmlify($mesg->conversation_guid));
|
$msg_conversation_guid = notags(unxmlify($mesg->conversation_guid));
|
||||||
|
$msg_text = unxmlify($mesg->text);
|
||||||
|
$msg_created_at = datetime_convert("UTC", "UTC", notags(unxmlify($mesg->created_at)));
|
||||||
|
|
||||||
if ($msg_conversation_guid != $guid) {
|
if ($msg_conversation_guid != $guid) {
|
||||||
logger("message conversation guid does not belong to the current conversation.");
|
logger("message conversation guid does not belong to the current conversation.");
|
||||||
|
@ -1385,44 +1515,11 @@ class Diaspora {
|
||||||
$body = diaspora2bb($msg_text);
|
$body = diaspora2bb($msg_text);
|
||||||
$message_uri = $msg_author.":".$msg_guid;
|
$message_uri = $msg_author.":".$msg_guid;
|
||||||
|
|
||||||
$author_signed_data = $msg_guid.";".$msg_parent_guid.";".$msg_text.";".unxmlify($mesg->created_at).";".$msg_author.";".$msg_conversation_guid;
|
|
||||||
|
|
||||||
$author_signature = base64_decode($msg_author_signature);
|
|
||||||
|
|
||||||
if (strcasecmp($msg_author,$msg["author"]) == 0) {
|
|
||||||
$person = $contact;
|
|
||||||
$key = $msg["key"];
|
|
||||||
} else {
|
|
||||||
$person = self::person_by_handle($msg_author);
|
$person = self::person_by_handle($msg_author);
|
||||||
|
|
||||||
if (is_array($person) && x($person, "pubkey")) {
|
$r = q("SELECT `id` FROM `mail` WHERE `guid` = '%s' AND `uid` = %d LIMIT 1",
|
||||||
$key = $person["pubkey"];
|
dbesc($msg_guid),
|
||||||
} else {
|
intval($importer["uid"])
|
||||||
logger("unable to find author details");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!rsa_verify($author_signed_data, $author_signature, $key, "sha256")) {
|
|
||||||
logger("verification failed.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($msg_parent_author_signature) {
|
|
||||||
$owner_signed_data = $msg_guid.";".$msg_parent_guid.";".$msg_text.";".unxmlify($mesg->created_at).";".$msg_author.";".$msg_conversation_guid;
|
|
||||||
|
|
||||||
$parent_author_signature = base64_decode($msg_parent_author_signature);
|
|
||||||
|
|
||||||
$key = $msg["key"];
|
|
||||||
|
|
||||||
if (!rsa_verify($owner_signed_data, $parent_author_signature, $key, "sha256")) {
|
|
||||||
logger("owner verification failed.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$r = q("SELECT `id` FROM `mail` WHERE `uri` = '%s' LIMIT 1",
|
|
||||||
dbesc($message_uri)
|
|
||||||
);
|
);
|
||||||
if (dbm::is_result($r)) {
|
if (dbm::is_result($r)) {
|
||||||
logger("duplicate message already delivered.", LOGGER_DEBUG);
|
logger("duplicate message already delivered.", LOGGER_DEBUG);
|
||||||
|
@ -1479,10 +1576,10 @@ class Diaspora {
|
||||||
* @return bool Success
|
* @return bool Success
|
||||||
*/
|
*/
|
||||||
private static function receive_conversation($importer, $msg, $data) {
|
private static function receive_conversation($importer, $msg, $data) {
|
||||||
|
$author = notags(unxmlify($data->author));
|
||||||
$guid = notags(unxmlify($data->guid));
|
$guid = notags(unxmlify($data->guid));
|
||||||
$subject = notags(unxmlify($data->subject));
|
$subject = notags(unxmlify($data->subject));
|
||||||
$created_at = datetime_convert("UTC", "UTC", notags(unxmlify($data->created_at)));
|
$created_at = datetime_convert("UTC", "UTC", notags(unxmlify($data->created_at)));
|
||||||
$author = notags(unxmlify($data->author));
|
|
||||||
$participants = notags(unxmlify($data->participants));
|
$participants = notags(unxmlify($data->participants));
|
||||||
|
|
||||||
$messages = $data->message;
|
$messages = $data->message;
|
||||||
|
@ -1587,11 +1684,11 @@ class Diaspora {
|
||||||
* @return int The message id of the generated like or "false" if there was an error
|
* @return int The message id of the generated like or "false" if there was an error
|
||||||
*/
|
*/
|
||||||
private static function receive_like($importer, $sender, $data) {
|
private static function receive_like($importer, $sender, $data) {
|
||||||
$positive = notags(unxmlify($data->positive));
|
|
||||||
$guid = notags(unxmlify($data->guid));
|
|
||||||
$parent_type = notags(unxmlify($data->parent_type));
|
|
||||||
$parent_guid = notags(unxmlify($data->parent_guid));
|
|
||||||
$author = notags(unxmlify($data->author));
|
$author = notags(unxmlify($data->author));
|
||||||
|
$guid = notags(unxmlify($data->guid));
|
||||||
|
$parent_guid = notags(unxmlify($data->parent_guid));
|
||||||
|
$parent_type = notags(unxmlify($data->parent_type));
|
||||||
|
$positive = notags(unxmlify($data->positive));
|
||||||
|
|
||||||
// likes on comments aren't supported by Diaspora - only on posts
|
// likes on comments aren't supported by Diaspora - only on posts
|
||||||
// But maybe this will be supported in the future, so we will accept it.
|
// But maybe this will be supported in the future, so we will accept it.
|
||||||
|
@ -1628,6 +1725,8 @@ class Diaspora {
|
||||||
|
|
||||||
$datarray = array();
|
$datarray = array();
|
||||||
|
|
||||||
|
$datarray["protocol"] = PROTOCOL_DIASPORA;
|
||||||
|
|
||||||
$datarray["uid"] = $importer["uid"];
|
$datarray["uid"] = $importer["uid"];
|
||||||
$datarray["contact-id"] = $author_contact["cid"];
|
$datarray["contact-id"] = $author_contact["cid"];
|
||||||
$datarray["network"] = $author_contact["network"];
|
$datarray["network"] = $author_contact["network"];
|
||||||
|
@ -1684,12 +1783,11 @@ class Diaspora {
|
||||||
* @return bool Success?
|
* @return bool Success?
|
||||||
*/
|
*/
|
||||||
private static function receive_message($importer, $data) {
|
private static function receive_message($importer, $data) {
|
||||||
|
$author = notags(unxmlify($data->author));
|
||||||
$guid = notags(unxmlify($data->guid));
|
$guid = notags(unxmlify($data->guid));
|
||||||
$parent_guid = notags(unxmlify($data->parent_guid));
|
$conversation_guid = notags(unxmlify($data->conversation_guid));
|
||||||
$text = unxmlify($data->text);
|
$text = unxmlify($data->text);
|
||||||
$created_at = datetime_convert("UTC", "UTC", notags(unxmlify($data->created_at)));
|
$created_at = datetime_convert("UTC", "UTC", notags(unxmlify($data->created_at)));
|
||||||
$author = notags(unxmlify($data->author));
|
|
||||||
$conversation_guid = notags(unxmlify($data->conversation_guid));
|
|
||||||
|
|
||||||
$contact = self::allowed_contact_by_handle($importer, $author, true);
|
$contact = self::allowed_contact_by_handle($importer, $author, true);
|
||||||
if (!$contact) {
|
if (!$contact) {
|
||||||
|
@ -1717,8 +1815,8 @@ class Diaspora {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("SELECT `id` FROM `mail` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
$r = q("SELECT `id` FROM `mail` WHERE `guid` = '%s' AND `uid` = %d LIMIT 1",
|
||||||
dbesc($message_uri),
|
dbesc($guid),
|
||||||
intval($importer["uid"])
|
intval($importer["uid"])
|
||||||
);
|
);
|
||||||
if (dbm::is_result($r)) {
|
if (dbm::is_result($r)) {
|
||||||
|
@ -1744,7 +1842,7 @@ class Diaspora {
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
dbesc($message_uri),
|
dbesc($message_uri),
|
||||||
dbesc($author.":".$parent_guid),
|
dbesc($author.":".$conversation["guid"]),
|
||||||
dbesc($created_at)
|
dbesc($created_at)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1813,9 +1911,9 @@ class Diaspora {
|
||||||
$name = unxmlify($data->first_name).((strlen($data->last_name)) ? " ".unxmlify($data->last_name) : "");
|
$name = unxmlify($data->first_name).((strlen($data->last_name)) ? " ".unxmlify($data->last_name) : "");
|
||||||
$image_url = unxmlify($data->image_url);
|
$image_url = unxmlify($data->image_url);
|
||||||
$birthday = unxmlify($data->birthday);
|
$birthday = unxmlify($data->birthday);
|
||||||
$location = diaspora2bb(unxmlify($data->location));
|
|
||||||
$about = diaspora2bb(unxmlify($data->bio));
|
|
||||||
$gender = unxmlify($data->gender);
|
$gender = unxmlify($data->gender);
|
||||||
|
$about = diaspora2bb(unxmlify($data->bio));
|
||||||
|
$location = diaspora2bb(unxmlify($data->location));
|
||||||
$searchable = (unxmlify($data->searchable) == "true");
|
$searchable = (unxmlify($data->searchable) == "true");
|
||||||
$nsfw = (unxmlify($data->nsfw) == "true");
|
$nsfw = (unxmlify($data->nsfw) == "true");
|
||||||
$tags = unxmlify($data->tag_string);
|
$tags = unxmlify($data->tag_string);
|
||||||
|
@ -1919,6 +2017,7 @@ class Diaspora {
|
||||||
if ($self && $contact["rel"] == CONTACT_IS_FOLLOWER) {
|
if ($self && $contact["rel"] == CONTACT_IS_FOLLOWER) {
|
||||||
|
|
||||||
$arr = array();
|
$arr = array();
|
||||||
|
$arr["protocol"] = PROTOCOL_DIASPORA;
|
||||||
$arr["uri"] = $arr["parent-uri"] = item_new_uri($a->get_hostname(), $importer["uid"]);
|
$arr["uri"] = $arr["parent-uri"] = item_new_uri($a->get_hostname(), $importer["uid"]);
|
||||||
$arr["uid"] = $importer["uid"];
|
$arr["uid"] = $importer["uid"];
|
||||||
$arr["contact-id"] = $self[0]["id"];
|
$arr["contact-id"] = $self[0]["id"];
|
||||||
|
@ -2234,12 +2333,13 @@ class Diaspora {
|
||||||
* @return int the message id
|
* @return int the message id
|
||||||
*/
|
*/
|
||||||
private static function receive_reshare($importer, $data, $xml) {
|
private static function receive_reshare($importer, $data, $xml) {
|
||||||
|
$author = notags(unxmlify($data->author));
|
||||||
|
$guid = notags(unxmlify($data->guid));
|
||||||
|
$created_at = datetime_convert("UTC", "UTC", notags(unxmlify($data->created_at)));
|
||||||
$root_author = notags(unxmlify($data->root_author));
|
$root_author = notags(unxmlify($data->root_author));
|
||||||
$root_guid = notags(unxmlify($data->root_guid));
|
$root_guid = notags(unxmlify($data->root_guid));
|
||||||
$guid = notags(unxmlify($data->guid));
|
/// @todo handle unprocessed property "provider_display_name"
|
||||||
$author = notags(unxmlify($data->author));
|
|
||||||
$public = notags(unxmlify($data->public));
|
$public = notags(unxmlify($data->public));
|
||||||
$created_at = datetime_convert("UTC", "UTC", notags(unxmlify($data->created_at)));
|
|
||||||
|
|
||||||
$contact = self::allowed_contact_by_handle($importer, $author, false);
|
$contact = self::allowed_contact_by_handle($importer, $author, false);
|
||||||
if (!$contact) {
|
if (!$contact) {
|
||||||
|
@ -2278,7 +2378,8 @@ class Diaspora {
|
||||||
$datarray["verb"] = ACTIVITY_POST;
|
$datarray["verb"] = ACTIVITY_POST;
|
||||||
$datarray["gravity"] = GRAVITY_PARENT;
|
$datarray["gravity"] = GRAVITY_PARENT;
|
||||||
|
|
||||||
$datarray["object"] = $xml;
|
$datarray["protocol"] = PROTOCOL_DIASPORA;
|
||||||
|
$datarray["source"] = $xml;
|
||||||
|
|
||||||
$prefix = share_header($original_item["author-name"], $original_item["author-link"], $original_item["author-avatar"],
|
$prefix = share_header($original_item["author-name"], $original_item["author-link"], $original_item["author-avatar"],
|
||||||
$original_item["guid"], $original_item["created"], $orig_url);
|
$original_item["guid"], $original_item["created"], $orig_url);
|
||||||
|
@ -2313,9 +2414,9 @@ class Diaspora {
|
||||||
* @return bool success
|
* @return bool success
|
||||||
*/
|
*/
|
||||||
private static function item_retraction($importer, $contact, $data) {
|
private static function item_retraction($importer, $contact, $data) {
|
||||||
$target_type = notags(unxmlify($data->target_type));
|
|
||||||
$target_guid = notags(unxmlify($data->target_guid));
|
|
||||||
$author = notags(unxmlify($data->author));
|
$author = notags(unxmlify($data->author));
|
||||||
|
$target_guid = notags(unxmlify($data->target_guid));
|
||||||
|
$target_type = notags(unxmlify($data->target_type));
|
||||||
|
|
||||||
$person = self::person_by_handle($author);
|
$person = self::person_by_handle($author);
|
||||||
if (!is_array($person)) {
|
if (!is_array($person)) {
|
||||||
|
@ -2323,11 +2424,16 @@ class Diaspora {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isset($contact["url"])) {
|
||||||
|
$contact["url"] = $person["url"];
|
||||||
|
}
|
||||||
|
|
||||||
$r = q("SELECT `id`, `parent`, `parent-uri`, `author-link` FROM `item` WHERE `guid` = '%s' AND `uid` = %d AND NOT `file` LIKE '%%[%%' LIMIT 1",
|
$r = q("SELECT `id`, `parent`, `parent-uri`, `author-link` FROM `item` WHERE `guid` = '%s' AND `uid` = %d AND NOT `file` LIKE '%%[%%' LIMIT 1",
|
||||||
dbesc($target_guid),
|
dbesc($target_guid),
|
||||||
intval($importer["uid"])
|
intval($importer["uid"])
|
||||||
);
|
);
|
||||||
if (!$r) {
|
if (!$r) {
|
||||||
|
logger("Target guid ".$target_guid." was not found for user ".$importer["uid"]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2373,7 +2479,7 @@ class Diaspora {
|
||||||
$target_type = notags(unxmlify($data->target_type));
|
$target_type = notags(unxmlify($data->target_type));
|
||||||
|
|
||||||
$contact = self::contact_by_handle($importer["uid"], $sender);
|
$contact = self::contact_by_handle($importer["uid"], $sender);
|
||||||
if (!$contact) {
|
if (!$contact AND (in_array($target_type, array("Contact", "Person")))) {
|
||||||
logger("cannot find contact for sender: ".$sender." and user ".$importer["uid"]);
|
logger("cannot find contact for sender: ".$sender." and user ".$importer["uid"]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2386,7 +2492,7 @@ class Diaspora {
|
||||||
case "Post": // "Post" will be supported in a future version
|
case "Post": // "Post" will be supported in a future version
|
||||||
case "Reshare":
|
case "Reshare":
|
||||||
case "StatusMessage":
|
case "StatusMessage":
|
||||||
return self::item_retraction($importer, $contact, $data);;
|
return self::item_retraction($importer, $contact, $data);
|
||||||
|
|
||||||
case "Contact":
|
case "Contact":
|
||||||
case "Person":
|
case "Person":
|
||||||
|
@ -2412,19 +2518,13 @@ class Diaspora {
|
||||||
* @return int The message id of the newly created item
|
* @return int The message id of the newly created item
|
||||||
*/
|
*/
|
||||||
private static function receive_status_message($importer, $data, $xml) {
|
private static function receive_status_message($importer, $data, $xml) {
|
||||||
$raw_message = unxmlify($data->raw_message);
|
|
||||||
$guid = notags(unxmlify($data->guid));
|
|
||||||
$author = notags(unxmlify($data->author));
|
$author = notags(unxmlify($data->author));
|
||||||
$public = notags(unxmlify($data->public));
|
$guid = notags(unxmlify($data->guid));
|
||||||
$created_at = datetime_convert("UTC", "UTC", notags(unxmlify($data->created_at)));
|
$created_at = datetime_convert("UTC", "UTC", notags(unxmlify($data->created_at)));
|
||||||
|
$public = notags(unxmlify($data->public));
|
||||||
|
$text = unxmlify($data->text);
|
||||||
$provider_display_name = notags(unxmlify($data->provider_display_name));
|
$provider_display_name = notags(unxmlify($data->provider_display_name));
|
||||||
|
|
||||||
/// @todo enable support for polls
|
|
||||||
//if ($data->poll) {
|
|
||||||
// foreach ($data->poll AS $poll)
|
|
||||||
// print_r($poll);
|
|
||||||
// die("poll!\n");
|
|
||||||
//}
|
|
||||||
$contact = self::allowed_contact_by_handle($importer, $author, false);
|
$contact = self::allowed_contact_by_handle($importer, $author, false);
|
||||||
if (!$contact) {
|
if (!$contact) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -2442,7 +2542,7 @@ class Diaspora {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$body = diaspora2bb($raw_message);
|
$body = diaspora2bb($text);
|
||||||
|
|
||||||
$datarray = array();
|
$datarray = array();
|
||||||
|
|
||||||
|
@ -2463,6 +2563,15 @@ class Diaspora {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @todo enable support for polls
|
||||||
|
//if ($data->poll) {
|
||||||
|
// foreach ($data->poll AS $poll)
|
||||||
|
// print_r($poll);
|
||||||
|
// die("poll!\n");
|
||||||
|
//}
|
||||||
|
|
||||||
|
/// @todo enable support for events
|
||||||
|
|
||||||
$datarray["uid"] = $importer["uid"];
|
$datarray["uid"] = $importer["uid"];
|
||||||
$datarray["contact-id"] = $contact["id"];
|
$datarray["contact-id"] = $contact["id"];
|
||||||
$datarray["network"] = NETWORK_DIASPORA;
|
$datarray["network"] = NETWORK_DIASPORA;
|
||||||
|
@ -2481,7 +2590,8 @@ class Diaspora {
|
||||||
$datarray["verb"] = ACTIVITY_POST;
|
$datarray["verb"] = ACTIVITY_POST;
|
||||||
$datarray["gravity"] = GRAVITY_PARENT;
|
$datarray["gravity"] = GRAVITY_PARENT;
|
||||||
|
|
||||||
$datarray["object"] = $xml;
|
$datarray["protocol"] = PROTOCOL_DIASPORA;
|
||||||
|
$datarray["source"] = $xml;
|
||||||
|
|
||||||
$datarray["body"] = self::replace_people_guid($body, $contact["url"]);
|
$datarray["body"] = self::replace_people_guid($body, $contact["url"]);
|
||||||
|
|
||||||
|
@ -3711,4 +3821,3 @@ class Diaspora {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
/// @TODO no longer used?
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
function directory_run(&$argv, &$argc){
|
function directory_run(&$argv, &$argc){
|
||||||
$dir = get_config('system', 'directory');
|
$dir = Config::get('system', 'directory');
|
||||||
|
|
||||||
if (!strlen($dir)) {
|
if (!strlen($dir)) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
require_once('include/socgraph.php');
|
require_once 'include/probe.php';
|
||||||
require_once('include/datetime.php');
|
require_once 'include/socgraph.php';
|
||||||
|
require_once 'include/datetime.php';
|
||||||
|
|
||||||
function discover_poco_run(&$argv, &$argc) {
|
function discover_poco_run(&$argv, &$argc) {
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
|
||||||
require_once('include/Emailer.php');
|
require_once('include/Emailer.php');
|
||||||
require_once('include/email.php');
|
require_once('include/email.php');
|
||||||
require_once('include/bbcode.php');
|
require_once('include/bbcode.php');
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
* @brief functions specific to event handling
|
* @brief functions specific to event handling
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
|
||||||
require_once 'include/bbcode.php';
|
require_once 'include/bbcode.php';
|
||||||
require_once 'include/map.php';
|
require_once 'include/map.php';
|
||||||
require_once 'include/datetime.php';
|
require_once 'include/datetime.php';
|
||||||
|
@ -81,74 +83,6 @@ function format_event_html($ev, $simple = false) {
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
@TODO old-lost code found?
|
|
||||||
function parse_event($h) {
|
|
||||||
|
|
||||||
require_once('include/Scrape.php');
|
|
||||||
require_once('include/html2bbcode');
|
|
||||||
|
|
||||||
$h = '<html><body>' . $h . '</body></html>';
|
|
||||||
|
|
||||||
$ret = array();
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
$dom = HTML5_Parser::parse($h);
|
|
||||||
} catch (DOMException $e) {
|
|
||||||
logger('parse_event: parse error: ' . $e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $dom)
|
|
||||||
return $ret;
|
|
||||||
|
|
||||||
$items = $dom->getElementsByTagName('*');
|
|
||||||
|
|
||||||
foreach ($items as $item) {
|
|
||||||
if (attribute_contains($item->getAttribute('class'), 'vevent')) {
|
|
||||||
$level2 = $item->getElementsByTagName('*');
|
|
||||||
foreach ($level2 as $x) {
|
|
||||||
if (attribute_contains($x->getAttribute('class'),'dtstart') && $x->getAttribute('title')) {
|
|
||||||
$ret['start'] = $x->getAttribute('title');
|
|
||||||
if (! strpos($ret['start'],'Z'))
|
|
||||||
$ret['adjust'] = true;
|
|
||||||
}
|
|
||||||
if (attribute_contains($x->getAttribute('class'),'dtend') && $x->getAttribute('title'))
|
|
||||||
$ret['finish'] = $x->getAttribute('title');
|
|
||||||
|
|
||||||
if (attribute_contains($x->getAttribute('class'),'description'))
|
|
||||||
$ret['desc'] = $x->textContent;
|
|
||||||
if (attribute_contains($x->getAttribute('class'),'location'))
|
|
||||||
$ret['location'] = $x->textContent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// sanitise
|
|
||||||
|
|
||||||
if ((x($ret,'desc')) && ((strpos($ret['desc'],'<') !== false) || (strpos($ret['desc'],'>') !== false))) {
|
|
||||||
$config = HTMLPurifier_Config::createDefault();
|
|
||||||
$config->set('Cache.DefinitionImpl', null);
|
|
||||||
$purifier = new HTMLPurifier($config);
|
|
||||||
$ret['desc'] = html2bbcode($purifier->purify($ret['desc']));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((x($ret,'location')) && ((strpos($ret['location'],'<') !== false) || (strpos($ret['location'],'>') !== false))) {
|
|
||||||
$config = HTMLPurifier_Config::createDefault();
|
|
||||||
$config->set('Cache.DefinitionImpl', null);
|
|
||||||
$purifier = new HTMLPurifier($config);
|
|
||||||
$ret['location'] = html2bbcode($purifier->purify($ret['location']));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (x($ret,'start'))
|
|
||||||
$ret['start'] = datetime_convert('UTC','UTC',$ret['start']);
|
|
||||||
if (x($ret,'finish'))
|
|
||||||
$ret['finish'] = datetime_convert('UTC','UTC',$ret['finish']);
|
|
||||||
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
function format_event_bbcode($ev) {
|
function format_event_bbcode($ev) {
|
||||||
|
|
||||||
$o = '';
|
$o = '';
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
function expire_run(&$argv, &$argc){
|
function expire_run(&$argv, &$argc){
|
||||||
global $a;
|
global $a;
|
||||||
|
|
|
@ -366,4 +366,3 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
|
||||||
return array("header" => $author, "items" => $items);
|
return array("header" => $author, "items" => $items);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -47,4 +47,3 @@ function update_files_for_items() {
|
||||||
create_files_from_item($message["id"]);
|
create_files_from_item($message["id"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
require_once("include/Scrape.php");
|
|
||||||
require_once("include/socgraph.php");
|
use Friendica\App;
|
||||||
require_once('include/group.php');
|
|
||||||
require_once('include/salmon.php');
|
require_once 'include/probe.php';
|
||||||
require_once('include/ostatus.php');
|
require_once 'include/socgraph.php';
|
||||||
require_once("include/Photo.php");
|
require_once 'include/group.php';
|
||||||
require_once('include/diaspora.php');
|
require_once 'include/salmon.php';
|
||||||
|
require_once 'include/ostatus.php';
|
||||||
|
require_once 'include/Photo.php';
|
||||||
|
require_once 'include/diaspora.php';
|
||||||
|
|
||||||
function update_contact($id) {
|
function update_contact($id) {
|
||||||
/*
|
/*
|
||||||
|
@ -82,6 +85,11 @@ function new_contact($uid,$url,$interactive = false) {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (blocked_url($url)) {
|
||||||
|
$result['message'] = t('Blocked domain');
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
if (! $url) {
|
if (! $url) {
|
||||||
$result['message'] = t('Connect URL missing.');
|
$result['message'] = t('Connect URL missing.');
|
||||||
return $result;
|
return $result;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
require_once('include/Scrape.php');
|
require_once 'include/probe.php';
|
||||||
require_once('include/socgraph.php');
|
require_once 'include/socgraph.php';
|
||||||
require_once('include/datetime.php');
|
require_once 'include/datetime.php';
|
||||||
|
|
||||||
function gprobe_run(&$argv, &$argc){
|
function gprobe_run(&$argv, &$argc){
|
||||||
if ($argc != 2) {
|
if ($argc != 2) {
|
||||||
|
|
|
@ -325,4 +325,3 @@ function html2bbcode($message)
|
||||||
|
|
||||||
return $message;
|
return $message;
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -233,4 +233,3 @@ function html2plain($html, $wraplength = 75, $compact = false)
|
||||||
|
|
||||||
return(trim($message));
|
return(trim($message));
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
* @file include/identity.php
|
* @file include/identity.php
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
|
||||||
require_once 'include/ForumManager.php';
|
require_once 'include/ForumManager.php';
|
||||||
require_once 'include/bbcode.php';
|
require_once 'include/bbcode.php';
|
||||||
require_once 'mod/proxy.php';
|
require_once 'mod/proxy.php';
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
* @file include/items.php
|
* @file include/items.php
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use \Friendica\ParseUrl;
|
use Friendica\App;
|
||||||
|
use Friendica\ParseUrl;
|
||||||
|
|
||||||
require_once 'include/bbcode.php';
|
require_once 'include/bbcode.php';
|
||||||
require_once 'include/oembed.php';
|
require_once 'include/oembed.php';
|
||||||
|
@ -410,7 +411,70 @@ function uri_to_guid($uri, $host = "") {
|
||||||
return $guid_prefix.$host_hash;
|
return $guid_prefix.$host_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @TODO Maybe $arr must be called-by-reference? This function modifies it
|
/**
|
||||||
|
* @brief Store the conversation data
|
||||||
|
*
|
||||||
|
* @param array $arr Item array with conversation data
|
||||||
|
* @return array Item array with removed conversation data
|
||||||
|
*/
|
||||||
|
function store_conversation($arr) {
|
||||||
|
if (in_array($arr['network'], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) {
|
||||||
|
$conversation = array('item-uri' => $arr['uri'], 'received' => dbm::date());
|
||||||
|
|
||||||
|
if (isset($arr['parent-uri']) AND ($arr['parent-uri'] != $arr['uri'])) {
|
||||||
|
$conversation['reply-to-uri'] = $arr['parent-uri'];
|
||||||
|
}
|
||||||
|
if (isset($arr['thr-parent']) AND ($arr['thr-parent'] != $arr['uri'])) {
|
||||||
|
$conversation['reply-to-uri'] = $arr['thr-parent'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($arr['conversation-uri'])) {
|
||||||
|
$conversation['conversation-uri'] = $arr['conversation-uri'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($arr['conversation-href'])) {
|
||||||
|
$conversation['conversation-href'] = $arr['conversation-href'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($arr['protocol'])) {
|
||||||
|
$conversation['protocol'] = $arr['protocol'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($arr['source'])) {
|
||||||
|
$conversation['source'] = $arr['source'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$old_conv = dba::fetch_first("SELECT `item-uri`, `reply-to-uri`, `conversation-uri`, `conversation-href`, `protocol`, `source`
|
||||||
|
FROM `conversation` WHERE `item-uri` = ?", $conversation['item-uri']);
|
||||||
|
if (dbm::is_result($old_conv)) {
|
||||||
|
// Don't update when only the source has changed.
|
||||||
|
// Only do this when there had been no source before.
|
||||||
|
if ($old_conv['source'] != '') {
|
||||||
|
unset($old_conv['source']);
|
||||||
|
}
|
||||||
|
// Update structure data all the time but the source only when its from a better protocol.
|
||||||
|
if (($old_conv['protocol'] < $conversation['protocol']) AND ($old_conv['protocol'] != 0)) {
|
||||||
|
unset($conversation['protocol']);
|
||||||
|
unset($conversation['source']);
|
||||||
|
}
|
||||||
|
if (!dba::update('conversation', $conversation, array('item-uri' => $conversation['item-uri']), $old_conv)) {
|
||||||
|
logger('Conversation: update for '.$conversation['item-uri'].' from '.$conv['protocol'].' to '.$conversation['protocol'].' failed', LOGGER_DEBUG);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!dba::insert('conversation', $conversation)) {
|
||||||
|
logger('Conversation: insert for '.$conversation['item-uri'].' (protocol '.$conversation['protocol'].') failed', LOGGER_DEBUG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($arr['conversation-uri']);
|
||||||
|
unset($arr['conversation-href']);
|
||||||
|
unset($arr['protocol']);
|
||||||
|
unset($arr['source']);
|
||||||
|
|
||||||
|
return $arr;
|
||||||
|
}
|
||||||
|
|
||||||
/// @TODO add type-hint array
|
/// @TODO add type-hint array
|
||||||
function item_store($arr, $force_parent = false, $notify = false, $dontcache = false) {
|
function item_store($arr, $force_parent = false, $notify = false, $dontcache = false) {
|
||||||
|
|
||||||
|
@ -423,6 +487,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
|
||||||
$arr['origin'] = 1;
|
$arr['origin'] = 1;
|
||||||
$arr['last-child'] = 1;
|
$arr['last-child'] = 1;
|
||||||
$arr['network'] = NETWORK_DFRN;
|
$arr['network'] = NETWORK_DFRN;
|
||||||
|
$arr['protocol'] = PROTOCOL_DFRN;
|
||||||
|
|
||||||
// We have to avoid duplicates. So we create the GUID in form of a hash of the plink or uri.
|
// We have to avoid duplicates. So we create the GUID in form of a hash of the plink or uri.
|
||||||
// In difference to the call to "uri_to_guid" several lines below we add the hash of our own host.
|
// In difference to the call to "uri_to_guid" several lines below we add the hash of our own host.
|
||||||
|
@ -436,6 +501,9 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store conversation data
|
||||||
|
$arr = store_conversation($arr);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If a Diaspora signature structure was passed in, pull it out of the
|
* If a Diaspora signature structure was passed in, pull it out of the
|
||||||
* item array and set it aside for later storage.
|
* item array and set it aside for later storage.
|
||||||
|
@ -690,6 +758,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
|
||||||
item_body_set_hashtags($arr);
|
item_body_set_hashtags($arr);
|
||||||
|
|
||||||
$arr['thr-parent'] = $arr['parent-uri'];
|
$arr['thr-parent'] = $arr['parent-uri'];
|
||||||
|
|
||||||
if ($arr['parent-uri'] === $arr['uri']) {
|
if ($arr['parent-uri'] === $arr['uri']) {
|
||||||
$parent_id = 0;
|
$parent_id = 0;
|
||||||
$parent_deleted = 0;
|
$parent_deleted = 0;
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
|
||||||
require_once("include/diaspora.php");
|
require_once("include/diaspora.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// send a private message
|
// send a private message
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
|
||||||
function send_message($recipient=0, $body='', $subject='', $replyto=''){
|
function send_message($recipient=0, $body='', $subject='', $replyto=''){
|
||||||
|
|
||||||
|
@ -175,7 +174,7 @@ function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
|
||||||
$convid = 0;
|
$convid = 0;
|
||||||
$reply = false;
|
$reply = false;
|
||||||
|
|
||||||
require_once('include/Scrape.php');
|
require_once 'include/probe.php';
|
||||||
|
|
||||||
$me = probe_url($replyto);
|
$me = probe_url($replyto);
|
||||||
|
|
||||||
|
|
|
@ -222,4 +222,3 @@ function removelinebreak($message)
|
||||||
return(implode("\n", $lines));
|
return(implode("\n", $lines));
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
|
||||||
function nav(App $a) {
|
function nav(App $a) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -86,9 +88,9 @@ function nav_info(App $a)
|
||||||
$nav['usermenu'][] = array('notes/', t('Personal notes'), '', t('Your personal notes'));
|
$nav['usermenu'][] = array('notes/', t('Personal notes'), '', t('Your personal notes'));
|
||||||
|
|
||||||
// user info
|
// user info
|
||||||
$r = q("SELECT `micro` FROM `contact` WHERE `uid` = %d AND `self` = 1", intval($a->user['uid']));
|
$r = dba::select('contact', array('micro'), array('uid' => $a->user['uid'], 'self' => true), array('limit' => 1));
|
||||||
$userinfo = array(
|
$userinfo = array(
|
||||||
'icon' => (dbm::is_result($r) ? $a->remove_baseurl($r[0]['micro']) : 'images/person-48.jpg'),
|
'icon' => (dbm::is_result($r) ? $a->remove_baseurl($r['micro']) : 'images/person-48.jpg'),
|
||||||
'name' => $a->user['username'],
|
'name' => $a->user['username'],
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -4,10 +4,11 @@
|
||||||
* @file include/network.php
|
* @file include/network.php
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\App;
|
||||||
|
use Friendica\Core\Config;
|
||||||
|
use Friendica\Network\Probe;
|
||||||
|
|
||||||
require_once("include/xml.php");
|
require_once("include/xml.php");
|
||||||
require_once('include/Probe.php');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Curl wrapper
|
* @brief Curl wrapper
|
||||||
|
@ -62,23 +63,27 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_
|
||||||
* string 'header' => HTTP headers
|
* string 'header' => HTTP headers
|
||||||
* string 'body' => fetched content
|
* string 'body' => fetched content
|
||||||
*/
|
*/
|
||||||
function z_fetch_url($url,$binary = false, &$redirects = 0, $opts=array()) {
|
function z_fetch_url($url, $binary = false, &$redirects = 0, $opts = array()) {
|
||||||
|
$ret = array('return_code' => 0, 'success' => false, 'header' => '', 'body' => '');
|
||||||
$ret = array('return_code' => 0, 'success' => false, 'header' => "", 'body' => "");
|
|
||||||
|
|
||||||
|
|
||||||
$stamp1 = microtime(true);
|
$stamp1 = microtime(true);
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
|
if (blocked_url($url)) {
|
||||||
|
logger('z_fetch_url: domain of ' . $url . ' is blocked', LOGGER_DATA);
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
$ch = @curl_init($url);
|
$ch = @curl_init($url);
|
||||||
if (($redirects > 8) || (! $ch)) {
|
|
||||||
|
if (($redirects > 8) || (!$ch)) {
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@curl_setopt($ch, CURLOPT_HEADER, true);
|
@curl_setopt($ch, CURLOPT_HEADER, true);
|
||||||
|
|
||||||
if (x($opts,"cookiejar")) {
|
if (x($opts, "cookiejar")) {
|
||||||
curl_setopt($ch, CURLOPT_COOKIEJAR, $opts["cookiejar"]);
|
curl_setopt($ch, CURLOPT_COOKIEJAR, $opts["cookiejar"]);
|
||||||
curl_setopt($ch, CURLOPT_COOKIEFILE, $opts["cookiejar"]);
|
curl_setopt($ch, CURLOPT_COOKIEFILE, $opts["cookiejar"]);
|
||||||
}
|
}
|
||||||
|
@ -87,52 +92,61 @@ function z_fetch_url($url,$binary = false, &$redirects = 0, $opts=array()) {
|
||||||
// @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
// @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||||
// @curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
|
// @curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
|
||||||
|
|
||||||
if (x($opts,'accept_content')){
|
if (x($opts, 'accept_content')) {
|
||||||
curl_setopt($ch,CURLOPT_HTTPHEADER, array (
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||||
"Accept: " . $opts['accept_content']
|
'Accept: ' . $opts['accept_content']
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
|
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
@curl_setopt($ch, CURLOPT_USERAGENT, $a->get_useragent());
|
@curl_setopt($ch, CURLOPT_USERAGENT, $a->get_useragent());
|
||||||
|
|
||||||
$range = intval(Config::get('system', 'curl_range_bytes', 0));
|
$range = intval(Config::get('system', 'curl_range_bytes', 0));
|
||||||
|
|
||||||
if ($range > 0) {
|
if ($range > 0) {
|
||||||
@curl_setopt($ch, CURLOPT_RANGE, '0-'.$range);
|
@curl_setopt($ch, CURLOPT_RANGE, '0-' . $range);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x($opts,'headers')){
|
if (x($opts, 'headers')) {
|
||||||
@curl_setopt($ch, CURLOPT_HTTPHEADER, $opts['headers']);
|
@curl_setopt($ch, CURLOPT_HTTPHEADER, $opts['headers']);
|
||||||
}
|
}
|
||||||
if (x($opts,'nobody')){
|
|
||||||
|
if (x($opts, 'nobody')) {
|
||||||
@curl_setopt($ch, CURLOPT_NOBODY, $opts['nobody']);
|
@curl_setopt($ch, CURLOPT_NOBODY, $opts['nobody']);
|
||||||
}
|
}
|
||||||
if (x($opts,'timeout')){
|
|
||||||
|
if (x($opts, 'timeout')) {
|
||||||
@curl_setopt($ch, CURLOPT_TIMEOUT, $opts['timeout']);
|
@curl_setopt($ch, CURLOPT_TIMEOUT, $opts['timeout']);
|
||||||
} else {
|
} else {
|
||||||
$curl_time = intval(get_config('system','curl_timeout'));
|
$curl_time = intval(get_config('system', 'curl_timeout'));
|
||||||
@curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== false) ? $curl_time : 60));
|
@curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== false) ? $curl_time : 60));
|
||||||
}
|
}
|
||||||
|
|
||||||
// by default we will allow self-signed certs
|
// by default we will allow self-signed certs
|
||||||
// but you can override this
|
// but you can override this
|
||||||
|
|
||||||
$check_cert = get_config('system','verifyssl');
|
$check_cert = get_config('system', 'verifyssl');
|
||||||
@curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, (($check_cert) ? true : false));
|
@curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, (($check_cert) ? true : false));
|
||||||
|
|
||||||
if ($check_cert) {
|
if ($check_cert) {
|
||||||
@curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
@curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
$prx = get_config('system','proxy');
|
$proxy = get_config('system', 'proxy');
|
||||||
if (strlen($prx)) {
|
|
||||||
|
if (strlen($proxy)) {
|
||||||
@curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
|
@curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
|
||||||
@curl_setopt($ch, CURLOPT_PROXY, $prx);
|
@curl_setopt($ch, CURLOPT_PROXY, $proxy);
|
||||||
$prxusr = @get_config('system','proxyuser');
|
$proxyuser = @get_config('system', 'proxyuser');
|
||||||
if (strlen($prxusr))
|
|
||||||
@curl_setopt($ch, CURLOPT_PROXYUSERPWD, $prxusr);
|
if (strlen($proxyuser)) {
|
||||||
|
@curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyuser);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($binary) {
|
||||||
|
@curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
|
||||||
}
|
}
|
||||||
if ($binary)
|
|
||||||
@curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
|
|
||||||
|
|
||||||
$a->set_curl_code(0);
|
$a->set_curl_code(0);
|
||||||
|
|
||||||
|
@ -140,8 +154,9 @@ function z_fetch_url($url,$binary = false, &$redirects = 0, $opts=array()) {
|
||||||
// if it throws any errors.
|
// if it throws any errors.
|
||||||
|
|
||||||
$s = @curl_exec($ch);
|
$s = @curl_exec($ch);
|
||||||
|
|
||||||
if (curl_errno($ch) !== CURLE_OK) {
|
if (curl_errno($ch) !== CURLE_OK) {
|
||||||
logger('fetch_url error fetching '.$url.': '.curl_error($ch), LOGGER_NORMAL);
|
logger('fetch_url error fetching ' . $url . ': ' . curl_error($ch), LOGGER_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret['errno'] = curl_errno($ch);
|
$ret['errno'] = curl_errno($ch);
|
||||||
|
@ -150,16 +165,16 @@ function z_fetch_url($url,$binary = false, &$redirects = 0, $opts=array()) {
|
||||||
$curl_info = @curl_getinfo($ch);
|
$curl_info = @curl_getinfo($ch);
|
||||||
|
|
||||||
$http_code = $curl_info['http_code'];
|
$http_code = $curl_info['http_code'];
|
||||||
logger('fetch_url '.$url.': '.$http_code." ".$s, LOGGER_DATA);
|
logger('fetch_url ' . $url . ': ' . $http_code . " " . $s, LOGGER_DATA);
|
||||||
$header = '';
|
$header = '';
|
||||||
|
|
||||||
// Pull out multiple headers, e.g. proxy and continuation headers
|
// Pull out multiple headers, e.g. proxy and continuation headers
|
||||||
// allow for HTTP/2.x without fixing code
|
// allow for HTTP/2.x without fixing code
|
||||||
|
|
||||||
while (preg_match('/^HTTP\/[1-2].+? [1-5][0-9][0-9]/',$base)) {
|
while (preg_match('/^HTTP\/[1-2].+? [1-5][0-9][0-9]/', $base)) {
|
||||||
$chunk = substr($base,0,strpos($base,"\r\n\r\n")+4);
|
$chunk = substr($base, 0, strpos($base,"\r\n\r\n") + 4);
|
||||||
$header .= $chunk;
|
$header .= $chunk;
|
||||||
$base = substr($base,strlen($chunk));
|
$base = substr($base, strlen($chunk));
|
||||||
}
|
}
|
||||||
|
|
||||||
$a->set_curl_code($http_code);
|
$a->set_curl_code($http_code);
|
||||||
|
@ -167,92 +182,100 @@ function z_fetch_url($url,$binary = false, &$redirects = 0, $opts=array()) {
|
||||||
$a->set_curl_headers($header);
|
$a->set_curl_headers($header);
|
||||||
|
|
||||||
if ($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307) {
|
if ($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307) {
|
||||||
$new_location_info = @parse_url($curl_info["redirect_url"]);
|
$new_location_info = @parse_url($curl_info['redirect_url']);
|
||||||
$old_location_info = @parse_url($curl_info["url"]);
|
$old_location_info = @parse_url($curl_info['url']);
|
||||||
|
|
||||||
$newurl = $curl_info["redirect_url"];
|
$newurl = $curl_info['redirect_url'];
|
||||||
|
|
||||||
if (($new_location_info["path"] == "") AND ($new_location_info["host"] != ""))
|
if (($new_location_info['path'] == '') AND ( $new_location_info['host'] != '')) {
|
||||||
$newurl = $new_location_info["scheme"]."://".$new_location_info["host"].$old_location_info["path"];
|
$newurl = $new_location_info['scheme'] . '://' . $new_location_info['host'] . $old_location_info['path'];
|
||||||
|
}
|
||||||
|
|
||||||
$matches = array();
|
$matches = array();
|
||||||
|
|
||||||
if (preg_match('/(Location:|URI:)(.*?)\n/i', $header, $matches)) {
|
if (preg_match('/(Location:|URI:)(.*?)\n/i', $header, $matches)) {
|
||||||
$newurl = trim(array_pop($matches));
|
$newurl = trim(array_pop($matches));
|
||||||
}
|
}
|
||||||
if (strpos($newurl,'/') === 0)
|
if (strpos($newurl,'/') === 0) {
|
||||||
$newurl = $old_location_info["scheme"]."://".$old_location_info["host"].$newurl;
|
$newurl = $old_location_info["scheme"]."://".$old_location_info["host"].$newurl;
|
||||||
|
}
|
||||||
|
|
||||||
if (filter_var($newurl, FILTER_VALIDATE_URL)) {
|
if (filter_var($newurl, FILTER_VALIDATE_URL)) {
|
||||||
$redirects++;
|
$redirects++;
|
||||||
@curl_close($ch);
|
@curl_close($ch);
|
||||||
return z_fetch_url($newurl,$binary, $redirects, $opts);
|
return z_fetch_url($newurl, $binary, $redirects, $opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$a->set_curl_code($http_code);
|
$a->set_curl_code($http_code);
|
||||||
$a->set_curl_content_type($curl_info['content_type']);
|
$a->set_curl_content_type($curl_info['content_type']);
|
||||||
|
|
||||||
$body = substr($s,strlen($header));
|
$body = substr($s, strlen($header));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$rc = intval($http_code);
|
$rc = intval($http_code);
|
||||||
$ret['return_code'] = $rc;
|
$ret['return_code'] = $rc;
|
||||||
$ret['success'] = (($rc >= 200 && $rc <= 299) ? true : false);
|
$ret['success'] = (($rc >= 200 && $rc <= 299) ? true : false);
|
||||||
$ret['redirect_url'] = $url;
|
$ret['redirect_url'] = $url;
|
||||||
if (! $ret['success']) {
|
|
||||||
|
if (!$ret['success']) {
|
||||||
$ret['error'] = curl_error($ch);
|
$ret['error'] = curl_error($ch);
|
||||||
$ret['debug'] = $curl_info;
|
$ret['debug'] = $curl_info;
|
||||||
logger('z_fetch_url: error: ' . $url . ': ' . $ret['error'], LOGGER_DEBUG);
|
logger('z_fetch_url: error: ' . $url . ': ' . $ret['error'], LOGGER_DEBUG);
|
||||||
logger('z_fetch_url: debug: ' . print_r($curl_info,true), LOGGER_DATA);
|
logger('z_fetch_url: debug: ' . print_r($curl_info, true), LOGGER_DATA);
|
||||||
}
|
}
|
||||||
$ret['body'] = substr($s,strlen($header));
|
|
||||||
|
$ret['body'] = substr($s, strlen($header));
|
||||||
$ret['header'] = $header;
|
$ret['header'] = $header;
|
||||||
if (x($opts,'debug')) {
|
|
||||||
|
if (x($opts, 'debug')) {
|
||||||
$ret['debug'] = $curl_info;
|
$ret['debug'] = $curl_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@curl_close($ch);
|
@curl_close($ch);
|
||||||
|
|
||||||
$a->save_timestamp($stamp1, "network");
|
$a->save_timestamp($stamp1, 'network');
|
||||||
|
|
||||||
return($ret);
|
return($ret);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// post request to $url. $params is an array of post variables.
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Post request to $url
|
* @brief Send POST request to $url
|
||||||
*
|
*
|
||||||
* @param string $url URL to post
|
* @param string $url URL to post
|
||||||
* @param mixed $params
|
* @param mixed $params array of POST variables
|
||||||
* @param string $headers HTTP headers
|
* @param string $headers HTTP headers
|
||||||
* @param integer $redirects Recursion counter for internal use - default = 0
|
* @param integer $redirects Recursion counter for internal use - default = 0
|
||||||
* @param integer $timeout The timeout in seconds, default system config value or 60 seconds
|
* @param integer $timeout The timeout in seconds, default system config value or 60 seconds
|
||||||
*
|
*
|
||||||
* @return string The content
|
* @return string The content
|
||||||
*/
|
*/
|
||||||
function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0) {
|
function post_url($url, $params, $headers = null, &$redirects = 0, $timeout = 0) {
|
||||||
$stamp1 = microtime(true);
|
$stamp1 = microtime(true);
|
||||||
|
|
||||||
|
if (blocked_url($url)) {
|
||||||
|
logger('post_url: domain of ' . $url . ' is blocked', LOGGER_DATA);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
$ch = curl_init($url);
|
$ch = curl_init($url);
|
||||||
if (($redirects > 8) || (! $ch))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
logger("post_url: start ".$url, LOGGER_DATA);
|
if (($redirects > 8) || (!$ch)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger('post_url: start ' . $url, LOGGER_DATA);
|
||||||
|
|
||||||
curl_setopt($ch, CURLOPT_HEADER, true);
|
curl_setopt($ch, CURLOPT_HEADER, true);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($ch, CURLOPT_POST,1);
|
curl_setopt($ch, CURLOPT_POST, 1);
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
|
||||||
curl_setopt($ch, CURLOPT_USERAGENT, $a->get_useragent());
|
curl_setopt($ch, CURLOPT_USERAGENT, $a->get_useragent());
|
||||||
|
|
||||||
if (intval($timeout)) {
|
if (intval($timeout)) {
|
||||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
||||||
}
|
} else {
|
||||||
else {
|
$curl_time = intval(get_config('system', 'curl_timeout'));
|
||||||
$curl_time = intval(get_config('system','curl_timeout'));
|
|
||||||
curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== false) ? $curl_time : 60));
|
curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== false) ? $curl_time : 60));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,21 +288,27 @@ function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($headers)
|
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
|
||||||
|
|
||||||
$check_cert = get_config('system','verifyssl');
|
if ($headers) {
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
$check_cert = get_config('system', 'verifyssl');
|
||||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, (($check_cert) ? true : false));
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, (($check_cert) ? true : false));
|
||||||
|
|
||||||
if ($check_cert) {
|
if ($check_cert) {
|
||||||
@curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
@curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
||||||
}
|
}
|
||||||
$prx = get_config('system','proxy');
|
|
||||||
if (strlen($prx)) {
|
$proxy = get_config('system', 'proxy');
|
||||||
|
|
||||||
|
if (strlen($proxy)) {
|
||||||
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
|
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
|
||||||
curl_setopt($ch, CURLOPT_PROXY, $prx);
|
curl_setopt($ch, CURLOPT_PROXY, $proxy);
|
||||||
$prxusr = get_config('system','proxyuser');
|
$proxyuser = get_config('system', 'proxyuser');
|
||||||
if (strlen($prxusr))
|
if (strlen($proxyuser)) {
|
||||||
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $prxusr);
|
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyuser);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$a->set_curl_code(0);
|
$a->set_curl_code(0);
|
||||||
|
@ -293,44 +322,48 @@ function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0)
|
||||||
$curl_info = curl_getinfo($ch);
|
$curl_info = curl_getinfo($ch);
|
||||||
$http_code = $curl_info['http_code'];
|
$http_code = $curl_info['http_code'];
|
||||||
|
|
||||||
logger("post_url: result ".$http_code." - ".$url, LOGGER_DATA);
|
logger('post_url: result ' . $http_code . ' - ' . $url, LOGGER_DATA);
|
||||||
|
|
||||||
$header = '';
|
$header = '';
|
||||||
|
|
||||||
// Pull out multiple headers, e.g. proxy and continuation headers
|
// Pull out multiple headers, e.g. proxy and continuation headers
|
||||||
// allow for HTTP/2.x without fixing code
|
// allow for HTTP/2.x without fixing code
|
||||||
|
|
||||||
while (preg_match('/^HTTP\/[1-2].+? [1-5][0-9][0-9]/',$base)) {
|
while (preg_match('/^HTTP\/[1-2].+? [1-5][0-9][0-9]/', $base)) {
|
||||||
$chunk = substr($base,0,strpos($base,"\r\n\r\n")+4);
|
$chunk = substr($base, 0, strpos($base, "\r\n\r\n") + 4);
|
||||||
$header .= $chunk;
|
$header .= $chunk;
|
||||||
$base = substr($base,strlen($chunk));
|
$base = substr($base, strlen($chunk));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307) {
|
if ($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307) {
|
||||||
$matches = array();
|
$matches = array();
|
||||||
preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches);
|
preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches);
|
||||||
$newurl = trim(array_pop($matches));
|
$newurl = trim(array_pop($matches));
|
||||||
if (strpos($newurl,'/') === 0)
|
|
||||||
|
if (strpos($newurl, '/') === 0) {
|
||||||
$newurl = $old_location_info["scheme"] . "://" . $old_location_info["host"] . $newurl;
|
$newurl = $old_location_info["scheme"] . "://" . $old_location_info["host"] . $newurl;
|
||||||
|
}
|
||||||
|
|
||||||
if (filter_var($newurl, FILTER_VALIDATE_URL)) {
|
if (filter_var($newurl, FILTER_VALIDATE_URL)) {
|
||||||
$redirects++;
|
$redirects++;
|
||||||
logger("post_url: redirect ".$url." to ".$newurl);
|
logger('post_url: redirect ' . $url . ' to ' . $newurl);
|
||||||
return post_url($newurl,$params, $headers, $redirects, $timeout);
|
return post_url($newurl, $params, $headers, $redirects, $timeout);
|
||||||
//return fetch_url($newurl,false,$redirects,$timeout);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$a->set_curl_code($http_code);
|
$a->set_curl_code($http_code);
|
||||||
$body = substr($s,strlen($header));
|
|
||||||
|
$body = substr($s, strlen($header));
|
||||||
|
|
||||||
$a->set_curl_headers($header);
|
$a->set_curl_headers($header);
|
||||||
|
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
$a->save_timestamp($stamp1, "network");
|
$a->save_timestamp($stamp1, 'network');
|
||||||
|
|
||||||
logger("post_url: end ".$url, LOGGER_DATA);
|
logger('post_url: end ' . $url, LOGGER_DATA);
|
||||||
|
|
||||||
return($body);
|
return $body;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generic XML return
|
// Generic XML return
|
||||||
|
@ -458,26 +491,27 @@ function allowed_url($url) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$str_allowed = get_config('system','allowed_sites');
|
$str_allowed = Config::get('system', 'allowed_sites');
|
||||||
if (! $str_allowed)
|
if (! $str_allowed) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
$found = false;
|
$found = false;
|
||||||
|
|
||||||
$host = strtolower($h['host']);
|
$host = strtolower($h['host']);
|
||||||
|
|
||||||
// always allow our own site
|
// always allow our own site
|
||||||
|
if ($host == strtolower($_SERVER['SERVER_NAME'])) {
|
||||||
if ($host == strtolower($_SERVER['SERVER_NAME']))
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
$fnmatch = function_exists('fnmatch');
|
$fnmatch = function_exists('fnmatch');
|
||||||
$allowed = explode(',',$str_allowed);
|
$allowed = explode(',', $str_allowed);
|
||||||
|
|
||||||
if (count($allowed)) {
|
if (count($allowed)) {
|
||||||
foreach ($allowed as $a) {
|
foreach ($allowed as $a) {
|
||||||
$pat = strtolower(trim($a));
|
$pat = strtolower(trim($a));
|
||||||
if (($fnmatch && fnmatch($pat,$host)) || ($pat == $host)) {
|
if (($fnmatch && fnmatch($pat, $host)) || ($pat == $host)) {
|
||||||
$found = true;
|
$found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -486,6 +520,36 @@ function allowed_url($url) {
|
||||||
return $found;
|
return $found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the provided url domain is on the domain blocklist.
|
||||||
|
* Returns true if it is or malformed URL, false if not.
|
||||||
|
*
|
||||||
|
* @param string $url The url to check the domain from
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function blocked_url($url) {
|
||||||
|
$h = @parse_url($url);
|
||||||
|
|
||||||
|
if (! $h) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$domain_blocklist = Config::get('system', 'blocklist', array());
|
||||||
|
if (! $domain_blocklist) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$host = strtolower($h['host']);
|
||||||
|
|
||||||
|
foreach ($domain_blocklist as $domain_block) {
|
||||||
|
if (strtolower($domain_block['domain']) == $host) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Check if email address is allowed to register here.
|
* @brief Check if email address is allowed to register here.
|
||||||
*
|
*
|
||||||
|
@ -659,22 +723,7 @@ function fix_contact_ssl_policy(&$contact,$new_policy) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ssl_changed) {
|
if ($ssl_changed) {
|
||||||
q("UPDATE `contact` SET
|
dba::update('contact', $contact, array('id' => $contact['id']));
|
||||||
`url` = '%s',
|
|
||||||
`request` = '%s',
|
|
||||||
`notify` = '%s',
|
|
||||||
`poll` = '%s',
|
|
||||||
`confirm` = '%s',
|
|
||||||
`poco` = '%s'
|
|
||||||
WHERE `id` = %d LIMIT 1",
|
|
||||||
dbesc($contact['url']),
|
|
||||||
dbesc($contact['request']),
|
|
||||||
dbesc($contact['notify']),
|
|
||||||
dbesc($contact['poll']),
|
|
||||||
dbesc($contact['confirm']),
|
|
||||||
dbesc($contact['poco']),
|
|
||||||
intval($contact['id'])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\App;
|
||||||
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
require_once('include/queue_fn.php');
|
require_once 'include/queue_fn.php';
|
||||||
require_once('include/html2plain.php');
|
require_once 'include/html2plain.php';
|
||||||
require_once('include/Scrape.php');
|
require_once 'include/probe.php';
|
||||||
require_once('include/diaspora.php');
|
require_once 'include/diaspora.php';
|
||||||
require_once('include/ostatus.php');
|
require_once 'include/ostatus.php';
|
||||||
require_once('include/salmon.php');
|
require_once 'include/salmon.php';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file was at one time responsible for doing all deliveries, but this caused
|
* This file was at one time responsible for doing all deliveries, but this caused
|
||||||
|
@ -45,10 +46,10 @@ require_once('include/salmon.php');
|
||||||
function notifier_run(&$argv, &$argc){
|
function notifier_run(&$argv, &$argc){
|
||||||
global $a;
|
global $a;
|
||||||
|
|
||||||
require_once('include/datetime.php');
|
require_once 'include/datetime.php';
|
||||||
require_once('include/items.php');
|
require_once 'include/items.php';
|
||||||
require_once('include/bbcode.php');
|
require_once 'include/bbcode.php';
|
||||||
require_once('include/email.php');
|
require_once 'include/email.php';
|
||||||
|
|
||||||
if ($argc < 3) {
|
if ($argc < 3) {
|
||||||
return;
|
return;
|
||||||
|
@ -138,7 +139,7 @@ function notifier_run(&$argv, &$argc){
|
||||||
if (!$r) {
|
if (!$r) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
require_once('include/Contact.php');
|
require_once 'include/Contact.php';
|
||||||
foreach ($r as $contact) {
|
foreach ($r as $contact) {
|
||||||
terminate_friendship($user, $self, $contact);
|
terminate_friendship($user, $self, $contact);
|
||||||
}
|
}
|
||||||
|
@ -222,7 +223,7 @@ function notifier_run(&$argv, &$argc){
|
||||||
|
|
||||||
$slap = ostatus::salmon($target_item,$owner);
|
$slap = ostatus::salmon($target_item,$owner);
|
||||||
|
|
||||||
require_once('include/group.php');
|
require_once 'include/group.php';
|
||||||
|
|
||||||
$parent = $items[0];
|
$parent = $items[0];
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
|
||||||
define('REQUEST_TOKEN_DURATION', 300);
|
define('REQUEST_TOKEN_DURATION', 300);
|
||||||
define('ACCESS_TOKEN_DURATION', 31536000);
|
define('ACCESS_TOKEN_DURATION', 31536000);
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
* @file include/oembed.php
|
* @file include/oembed.php
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use \Friendica\ParseUrl;
|
use Friendica\App;
|
||||||
use \Friendica\Core\Config;
|
use Friendica\ParseUrl;
|
||||||
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
function oembed_replacecb($matches){
|
function oembed_replacecb($matches){
|
||||||
$embedurl=$matches[1];
|
$embedurl=$matches[1];
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
require_once('include/follow.php');
|
require_once('include/follow.php');
|
||||||
|
|
||||||
|
|
|
@ -3,20 +3,24 @@
|
||||||
* @file include/ostatus.php
|
* @file include/ostatus.php
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once("include/Contact.php");
|
use Friendica\App;
|
||||||
require_once("include/threads.php");
|
use Friendica\Core\Config;
|
||||||
require_once("include/html2bbcode.php");
|
use Friendica\Network\Probe;
|
||||||
require_once("include/bbcode.php");
|
|
||||||
require_once("include/items.php");
|
require_once 'include/Contact.php';
|
||||||
require_once("mod/share.php");
|
require_once 'include/threads.php';
|
||||||
require_once("include/enotify.php");
|
require_once 'include/html2bbcode.php';
|
||||||
require_once("include/socgraph.php");
|
require_once 'include/bbcode.php';
|
||||||
require_once("include/Photo.php");
|
require_once 'include/items.php';
|
||||||
require_once("include/Scrape.php");
|
require_once 'mod/share.php';
|
||||||
require_once("include/follow.php");
|
require_once 'include/enotify.php';
|
||||||
require_once("include/api.php");
|
require_once 'include/socgraph.php';
|
||||||
require_once("mod/proxy.php");
|
require_once 'include/Photo.php';
|
||||||
require_once("include/xml.php");
|
require_once 'include/probe.php';
|
||||||
|
require_once 'include/follow.php';
|
||||||
|
require_once 'include/api.php';
|
||||||
|
require_once 'mod/proxy.php';
|
||||||
|
require_once 'include/xml.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This class contain functions for the OStatus protocol
|
* @brief This class contain functions for the OStatus protocol
|
||||||
|
@ -27,42 +31,6 @@ class ostatus {
|
||||||
const OSTATUS_DEFAULT_POLL_TIMEFRAME = 1440; // given in minutes
|
const OSTATUS_DEFAULT_POLL_TIMEFRAME = 1440; // given in minutes
|
||||||
const OSTATUS_DEFAULT_POLL_TIMEFRAME_MENTIONS = 14400; // given in minutes
|
const OSTATUS_DEFAULT_POLL_TIMEFRAME_MENTIONS = 14400; // given in minutes
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Mix two paths together to possibly fix missing parts
|
|
||||||
*
|
|
||||||
* @param string $avatar Path to the avatar
|
|
||||||
* @param string $base Another path that is hopefully complete
|
|
||||||
*
|
|
||||||
* @return string fixed avatar path
|
|
||||||
*/
|
|
||||||
public static function fix_avatar($avatar, $base) {
|
|
||||||
$base_parts = parse_url($base);
|
|
||||||
|
|
||||||
// Remove all parts that could create a problem
|
|
||||||
unset($base_parts['path']);
|
|
||||||
unset($base_parts['query']);
|
|
||||||
unset($base_parts['fragment']);
|
|
||||||
|
|
||||||
$avatar_parts = parse_url($avatar);
|
|
||||||
|
|
||||||
// Now we mix them
|
|
||||||
$parts = array_merge($base_parts, $avatar_parts);
|
|
||||||
|
|
||||||
// And put them together again
|
|
||||||
$scheme = isset($parts['scheme']) ? $parts['scheme'] . '://' : '';
|
|
||||||
$host = isset($parts['host']) ? $parts['host'] : '';
|
|
||||||
$port = isset($parts['port']) ? ':' . $parts['port'] : '';
|
|
||||||
$path = isset($parts['path']) ? $parts['path'] : '';
|
|
||||||
$query = isset($parts['query']) ? '?' . $parts['query'] : '';
|
|
||||||
$fragment = isset($parts['fragment']) ? '#' . $parts['fragment'] : '';
|
|
||||||
|
|
||||||
$fixed = $scheme.$host.$port.$path.$query.$fragment;
|
|
||||||
|
|
||||||
logger('Base: '.$base.' - Avatar: '.$avatar.' - Fixed: '.$fixed, LOGGER_DATA);
|
|
||||||
|
|
||||||
return $fixed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Fetches author data
|
* @brief Fetches author data
|
||||||
*
|
*
|
||||||
|
@ -79,26 +47,44 @@ class ostatus {
|
||||||
$author = array();
|
$author = array();
|
||||||
$author["author-link"] = $xpath->evaluate('atom:author/atom:uri/text()', $context)->item(0)->nodeValue;
|
$author["author-link"] = $xpath->evaluate('atom:author/atom:uri/text()', $context)->item(0)->nodeValue;
|
||||||
$author["author-name"] = $xpath->evaluate('atom:author/atom:name/text()', $context)->item(0)->nodeValue;
|
$author["author-name"] = $xpath->evaluate('atom:author/atom:name/text()', $context)->item(0)->nodeValue;
|
||||||
|
$addr = $xpath->evaluate('atom:author/atom:email/text()', $context)->item(0)->nodeValue;
|
||||||
|
|
||||||
$aliaslink = $author["author-link"];
|
$aliaslink = $author["author-link"];
|
||||||
|
|
||||||
$alternate = $xpath->query("atom:author/atom:link[@rel='alternate']", $context)->item(0)->attributes;
|
$alternate = $xpath->query("atom:author/atom:link[@rel='alternate']", $context)->item(0)->attributes;
|
||||||
if (is_object($alternate)) {
|
if (is_object($alternate)) {
|
||||||
foreach($alternate AS $attributes) {
|
foreach ($alternate AS $attributes) {
|
||||||
if ($attributes->name == "href") {
|
if (($attributes->name == "href") AND ($attributes->textContent != "")) {
|
||||||
$author["author-link"] = $attributes->textContent;
|
$author["author-link"] = $attributes->textContent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$author["contact-id"] = $contact["id"];
|
||||||
|
|
||||||
|
if ($author["author-link"] != "") {
|
||||||
|
if ($aliaslink == "") {
|
||||||
|
$aliaslink = $author["author-link"];
|
||||||
|
}
|
||||||
|
|
||||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` IN ('%s', '%s') AND `network` != '%s'",
|
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` IN ('%s', '%s') AND `network` != '%s'",
|
||||||
intval($importer["uid"]), dbesc(normalise_link($author["author-link"])),
|
intval($importer["uid"]), dbesc(normalise_link($author["author-link"])),
|
||||||
dbesc(normalise_link($aliaslink)), dbesc(NETWORK_STATUSNET));
|
dbesc(normalise_link($aliaslink)), dbesc(NETWORK_STATUSNET));
|
||||||
|
|
||||||
if (dbm::is_result($r)) {
|
if (dbm::is_result($r)) {
|
||||||
$contact = $r[0];
|
$contact = $r[0];
|
||||||
$author["contact-id"] = $r[0]["id"];
|
$author["contact-id"] = $r[0]["id"];
|
||||||
} else {
|
$author["author-link"] = $r[0]["url"];
|
||||||
|
}
|
||||||
|
} elseif ($addr != "") {
|
||||||
|
// Should not happen
|
||||||
|
$contact = dba::fetch_first("SELECT * FROM `contact` WHERE `uid` = ? AND `addr` = ? AND `network` != ?",
|
||||||
|
$importer["uid"], $addr, NETWORK_STATUSNET);
|
||||||
|
|
||||||
|
if (dbm::is_result($contact)) {
|
||||||
$author["contact-id"] = $contact["id"];
|
$author["contact-id"] = $contact["id"];
|
||||||
|
$author["author-link"] = $contact["url"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$avatarlist = array();
|
$avatarlist = array();
|
||||||
|
@ -120,7 +106,7 @@ class ostatus {
|
||||||
}
|
}
|
||||||
if (count($avatarlist) > 0) {
|
if (count($avatarlist) > 0) {
|
||||||
krsort($avatarlist);
|
krsort($avatarlist);
|
||||||
$author["author-avatar"] = self::fix_avatar(current($avatarlist), $author["author-link"]);
|
$author["author-avatar"] = Probe::fixAvatar(current($avatarlist), $author["author-link"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$displayname = $xpath->evaluate('atom:author/poco:displayName/text()', $context)->item(0)->nodeValue;
|
$displayname = $xpath->evaluate('atom:author/poco:displayName/text()', $context)->item(0)->nodeValue;
|
||||||
|
@ -320,8 +306,10 @@ class ostatus {
|
||||||
|
|
||||||
if ($first_child == "feed") {
|
if ($first_child == "feed") {
|
||||||
$entries = $xpath->query('/atom:feed/atom:entry');
|
$entries = $xpath->query('/atom:feed/atom:entry');
|
||||||
|
$header["protocol"] = PROTOCOL_OSTATUS_FEED;
|
||||||
} else {
|
} else {
|
||||||
$entries = $xpath->query('/atom:entry');
|
$entries = $xpath->query('/atom:entry');
|
||||||
|
$header["protocol"] = PROTOCOL_OSTATUS_SALMON;
|
||||||
}
|
}
|
||||||
$conversation = "";
|
$conversation = "";
|
||||||
$conversationlist = array();
|
$conversationlist = array();
|
||||||
|
@ -378,7 +366,7 @@ class ostatus {
|
||||||
} elseif ($item["object-type"] == ACTIVITY_OBJ_QUESTION) {
|
} elseif ($item["object-type"] == ACTIVITY_OBJ_QUESTION) {
|
||||||
$item["title"] = $xpath->query('atom:title/text()', $entry)->item(0)->nodeValue;
|
$item["title"] = $xpath->query('atom:title/text()', $entry)->item(0)->nodeValue;
|
||||||
}
|
}
|
||||||
$item["object"] = $xml;
|
$item["source"] = $xml;
|
||||||
|
|
||||||
/// @TODO
|
/// @TODO
|
||||||
/// Delete a message
|
/// Delete a message
|
||||||
|
@ -426,6 +414,19 @@ class ostatus {
|
||||||
$item["created"] = $xpath->query('atom:published/text()', $entry)->item(0)->nodeValue;
|
$item["created"] = $xpath->query('atom:published/text()', $entry)->item(0)->nodeValue;
|
||||||
$item["edited"] = $xpath->query('atom:updated/text()', $entry)->item(0)->nodeValue;
|
$item["edited"] = $xpath->query('atom:updated/text()', $entry)->item(0)->nodeValue;
|
||||||
$conversation = $xpath->query('ostatus:conversation/text()', $entry)->item(0)->nodeValue;
|
$conversation = $xpath->query('ostatus:conversation/text()', $entry)->item(0)->nodeValue;
|
||||||
|
$item['conversation-uri'] = $conversation;
|
||||||
|
|
||||||
|
$conv = $xpath->query('ostatus:conversation', $entry);
|
||||||
|
if (is_object($conv->item(0))) {
|
||||||
|
foreach ($conv->item(0)->attributes AS $attributes) {
|
||||||
|
if ($attributes->name == "ref") {
|
||||||
|
$item['conversation-uri'] = $attributes->textContent;
|
||||||
|
}
|
||||||
|
if ($attributes->name == "href") {
|
||||||
|
$item['conversation-href'] = $attributes->textContent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$related = "";
|
$related = "";
|
||||||
|
|
||||||
|
@ -479,6 +480,10 @@ class ostatus {
|
||||||
break;
|
break;
|
||||||
case "ostatus:conversation":
|
case "ostatus:conversation":
|
||||||
$conversation = $attribute['href'];
|
$conversation = $attribute['href'];
|
||||||
|
$item['conversation-href'] = $conversation;
|
||||||
|
if (!isset($item['conversation-uri'])) {
|
||||||
|
$item['conversation-uri'] = $item['conversation-href'];
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "enclosure":
|
case "enclosure":
|
||||||
$enclosure = $attribute['href'];
|
$enclosure = $attribute['href'];
|
||||||
|
@ -905,6 +910,8 @@ class ostatus {
|
||||||
($item["verb"] == ACTIVITY_LIKE) OR ($conversation_url == "")) {
|
($item["verb"] == ACTIVITY_LIKE) OR ($conversation_url == "")) {
|
||||||
$item_stored = item_store($item, $all_threads);
|
$item_stored = item_store($item, $all_threads);
|
||||||
return $item_stored;
|
return $item_stored;
|
||||||
|
} elseif (count($item) > 0) {
|
||||||
|
$item = store_conversation($item);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the parent
|
// Get the parent
|
||||||
|
@ -1162,13 +1169,17 @@ class ostatus {
|
||||||
$arr["owner-name"] = $single_conv->actor->portablecontacts_net->displayName;
|
$arr["owner-name"] = $single_conv->actor->portablecontacts_net->displayName;
|
||||||
|
|
||||||
$arr["owner-link"] = $actor;
|
$arr["owner-link"] = $actor;
|
||||||
$arr["owner-avatar"] = self::fix_avatar($single_conv->actor->image->url, $arr["owner-link"]);
|
$arr["owner-avatar"] = Probe::fixAvatar($single_conv->actor->image->url, $arr["owner-link"]);
|
||||||
|
|
||||||
$arr["author-name"] = $arr["owner-name"];
|
$arr["author-name"] = $arr["owner-name"];
|
||||||
$arr["author-link"] = $arr["owner-link"];
|
$arr["author-link"] = $arr["owner-link"];
|
||||||
$arr["author-avatar"] = $arr["owner-avatar"];
|
$arr["author-avatar"] = $arr["owner-avatar"];
|
||||||
$arr["body"] = add_page_info_to_body(html2bbcode($single_conv->content));
|
$arr["body"] = add_page_info_to_body(html2bbcode($single_conv->content));
|
||||||
|
|
||||||
|
if (isset($single_conv->status_net->conversation)) {
|
||||||
|
$arr['conversation-uri'] = $single_conv->status_net->conversation;
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($single_conv->status_net->notice_info->source))
|
if (isset($single_conv->status_net->notice_info->source))
|
||||||
$arr["app"] = strip_tags($single_conv->status_net->notice_info->source);
|
$arr["app"] = strip_tags($single_conv->status_net->notice_info->source);
|
||||||
elseif (isset($single_conv->statusnet->notice_info->source))
|
elseif (isset($single_conv->statusnet->notice_info->source))
|
||||||
|
@ -1181,7 +1192,9 @@ class ostatus {
|
||||||
$arr["app"] = "OStatus";
|
$arr["app"] = "OStatus";
|
||||||
|
|
||||||
|
|
||||||
$arr["object"] = json_encode($single_conv);
|
$arr["source"] = json_encode($single_conv);
|
||||||
|
$arr["protocol"] = PROTOCOL_GS_CONVERSATION;
|
||||||
|
|
||||||
$arr["verb"] = $parent["verb"];
|
$arr["verb"] = $parent["verb"];
|
||||||
$arr["visible"] = $parent["visible"];
|
$arr["visible"] = $parent["visible"];
|
||||||
$arr["location"] = $single_conv->location->displayName;
|
$arr["location"] = $single_conv->location->displayName;
|
||||||
|
@ -1221,7 +1234,7 @@ class ostatus {
|
||||||
$arr["author-name"] = $single_conv->object->actor->contact->displayName;
|
$arr["author-name"] = $single_conv->object->actor->contact->displayName;
|
||||||
}
|
}
|
||||||
$arr["author-link"] = $single_conv->object->actor->url;
|
$arr["author-link"] = $single_conv->object->actor->url;
|
||||||
$arr["author-avatar"] = self::fix_avatar($single_conv->object->actor->image->url, $arr["author-link"]);
|
$arr["author-avatar"] = Probe::fixAvatar($single_conv->object->actor->image->url, $arr["author-link"]);
|
||||||
|
|
||||||
$arr["app"] = $single_conv->object->provider->displayName."#";
|
$arr["app"] = $single_conv->object->provider->displayName."#";
|
||||||
//$arr["verb"] = $single_conv->object->verb;
|
//$arr["verb"] = $single_conv->object->verb;
|
||||||
|
@ -1413,6 +1426,7 @@ class ostatus {
|
||||||
$root->setAttribute("xmlns:poco", NAMESPACE_POCO);
|
$root->setAttribute("xmlns:poco", NAMESPACE_POCO);
|
||||||
$root->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS);
|
$root->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS);
|
||||||
$root->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
|
$root->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
|
||||||
|
$root->setAttribute("xmlns:mastodon", NAMESPACE_MASTODON);
|
||||||
|
|
||||||
$attributes = array("uri" => "https://friendi.ca", "version" => FRIENDICA_VERSION."-".DB_UPDATE_VERSION);
|
$attributes = array("uri" => "https://friendi.ca", "version" => FRIENDICA_VERSION."-".DB_UPDATE_VERSION);
|
||||||
xml::add_element($doc, $root, "generator", FRIENDICA_PLATFORM, $attributes);
|
xml::add_element($doc, $root, "generator", FRIENDICA_PLATFORM, $attributes);
|
||||||
|
@ -1551,14 +1565,16 @@ class ostatus {
|
||||||
*/
|
*/
|
||||||
private function add_author($doc, $owner) {
|
private function add_author($doc, $owner) {
|
||||||
|
|
||||||
$r = q("SELECT `homepage` FROM `profile` WHERE `uid` = %d AND `is-default` LIMIT 1", intval($owner["uid"]));
|
$r = q("SELECT `homepage`, `publish` FROM `profile` WHERE `uid` = %d AND `is-default` LIMIT 1", intval($owner["uid"]));
|
||||||
if ($r)
|
if ($r)
|
||||||
$profile = $r[0];
|
$profile = $r[0];
|
||||||
|
|
||||||
$author = $doc->createElement("author");
|
$author = $doc->createElement("author");
|
||||||
|
xml::add_element($doc, $author, "id", $owner["url"]);
|
||||||
xml::add_element($doc, $author, "activity:object-type", ACTIVITY_OBJ_PERSON);
|
xml::add_element($doc, $author, "activity:object-type", ACTIVITY_OBJ_PERSON);
|
||||||
xml::add_element($doc, $author, "uri", $owner["url"]);
|
xml::add_element($doc, $author, "uri", $owner["url"]);
|
||||||
xml::add_element($doc, $author, "name", $owner["name"]);
|
xml::add_element($doc, $author, "name", $owner["nick"]);
|
||||||
|
xml::add_element($doc, $author, "email", $owner["addr"]);
|
||||||
xml::add_element($doc, $author, "summary", bbcode($owner["about"], false, false, 7));
|
xml::add_element($doc, $author, "summary", bbcode($owner["about"], false, false, 7));
|
||||||
|
|
||||||
$attributes = array("rel" => "alternate", "type" => "text/html", "href" => $owner["url"]);
|
$attributes = array("rel" => "alternate", "type" => "text/html", "href" => $owner["url"]);
|
||||||
|
@ -1605,6 +1621,9 @@ class ostatus {
|
||||||
xml::add_element($doc, $author, "statusnet:profile_info", "", array("local_id" => $owner["uid"]));
|
xml::add_element($doc, $author, "statusnet:profile_info", "", array("local_id" => $owner["uid"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($profile["publish"]) {
|
||||||
|
xml::add_element($doc, $author, "mastodon:scope", "public");
|
||||||
|
}
|
||||||
return $author;
|
return $author;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2000,6 +2019,7 @@ class ostatus {
|
||||||
$entry->setAttribute("xmlns:poco", NAMESPACE_POCO);
|
$entry->setAttribute("xmlns:poco", NAMESPACE_POCO);
|
||||||
$entry->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS);
|
$entry->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS);
|
||||||
$entry->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
|
$entry->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
|
||||||
|
$entry->setAttribute("xmlns:mastodon", NAMESPACE_MASTODON);
|
||||||
|
|
||||||
$author = self::add_author($doc, $owner);
|
$author = self::add_author($doc, $owner);
|
||||||
$entry->appendChild($author);
|
$entry->appendChild($author);
|
||||||
|
@ -2066,39 +2086,54 @@ class ostatus {
|
||||||
$parent = q("SELECT `guid`, `author-link`, `owner-link` FROM `item` WHERE `id` = %d", intval($item["parent"]));
|
$parent = q("SELECT `guid`, `author-link`, `owner-link` FROM `item` WHERE `id` = %d", intval($item["parent"]));
|
||||||
$parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']);
|
$parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']);
|
||||||
|
|
||||||
$attributes = array(
|
$thrparent = q("SELECT `guid`, `author-link`, `owner-link`, `plink` FROM `item` WHERE `uid` = %d AND `uri` = '%s'",
|
||||||
"ref" => $parent_item,
|
|
||||||
"type" => "text/html",
|
|
||||||
"href" => App::get_baseurl()."/display/".$parent[0]["guid"]);
|
|
||||||
xml::add_element($doc, $entry, "thr:in-reply-to", "", $attributes);
|
|
||||||
|
|
||||||
$attributes = array(
|
|
||||||
"rel" => "related",
|
|
||||||
"href" => App::get_baseurl()."/display/".$parent[0]["guid"]);
|
|
||||||
xml::add_element($doc, $entry, "link", "", $attributes);
|
|
||||||
|
|
||||||
$mentioned[$parent[0]["author-link"]] = $parent[0]["author-link"];
|
|
||||||
$mentioned[$parent[0]["owner-link"]] = $parent[0]["owner-link"];
|
|
||||||
|
|
||||||
$thrparent = q("SELECT `guid`, `author-link`, `owner-link` FROM `item` WHERE `uid` = %d AND `uri` = '%s'",
|
|
||||||
intval($owner["uid"]),
|
intval($owner["uid"]),
|
||||||
dbesc($parent_item));
|
dbesc($parent_item));
|
||||||
if ($thrparent) {
|
if ($thrparent) {
|
||||||
$mentioned[$thrparent[0]["author-link"]] = $thrparent[0]["author-link"];
|
$mentioned[$thrparent[0]["author-link"]] = $thrparent[0]["author-link"];
|
||||||
$mentioned[$thrparent[0]["owner-link"]] = $thrparent[0]["owner-link"];
|
$mentioned[$thrparent[0]["owner-link"]] = $thrparent[0]["owner-link"];
|
||||||
|
$parent_plink = $thrparent[0]["plink"];
|
||||||
|
} else {
|
||||||
|
$mentioned[$parent[0]["author-link"]] = $parent[0]["author-link"];
|
||||||
|
$mentioned[$parent[0]["owner-link"]] = $parent[0]["owner-link"];
|
||||||
|
$parent_plink = App::get_baseurl()."/display/".$parent[0]["guid"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$attributes = array(
|
||||||
|
"ref" => $parent_item,
|
||||||
|
"href" => $parent_plink);
|
||||||
|
xml::add_element($doc, $entry, "thr:in-reply-to", "", $attributes);
|
||||||
|
|
||||||
|
$attributes = array(
|
||||||
|
"rel" => "related",
|
||||||
|
"href" => $parent_plink);
|
||||||
|
xml::add_element($doc, $entry, "link", "", $attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intval($item["parent"]) > 0) {
|
if (intval($item["parent"]) > 0) {
|
||||||
$conversation = App::get_baseurl()."/display/".$owner["nick"]."/".$item["parent"];
|
$conversation_href = App::get_baseurl()."/display/".$owner["nick"]."/".$item["parent"];
|
||||||
xml::add_element($doc, $entry, "link", "", array("rel" => "ostatus:conversation", "href" => $conversation));
|
$conversation_uri = $conversation_href;
|
||||||
|
|
||||||
|
if (isset($parent_item)) {
|
||||||
|
$r = dba::fetch_first("SELECT `conversation-uri`, `conversation-href` FROM `conversation` WHERE `item-uri` = ?", $parent_item);
|
||||||
|
if (dbm::is_result($r)) {
|
||||||
|
if ($r['conversation-uri'] != '') {
|
||||||
|
$conversation_uri = $r['conversation-uri'];
|
||||||
|
}
|
||||||
|
if ($r['conversation-href'] != '') {
|
||||||
|
$conversation_href = $r['conversation-href'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
xml::add_element($doc, $entry, "link", "", array("rel" => "ostatus:conversation", "href" => $conversation_href));
|
||||||
|
|
||||||
$attributes = array(
|
$attributes = array(
|
||||||
"href" => $conversation,
|
"href" => $conversation_href,
|
||||||
"local_id" => $item["parent"],
|
"local_id" => $item["parent"],
|
||||||
"ref" => $conversation);
|
"ref" => $conversation_uri);
|
||||||
|
|
||||||
xml::add_element($doc, $entry, "ostatus:conversation", $conversation, $attributes);
|
xml::add_element($doc, $entry, "ostatus:conversation", $conversation_uri, $attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
$tags = item_getfeedtags($item);
|
$tags = item_getfeedtags($item);
|
||||||
|
@ -2136,6 +2171,7 @@ class ostatus {
|
||||||
xml::add_element($doc, $entry, "link", "", array("rel" => "mentioned",
|
xml::add_element($doc, $entry, "link", "", array("rel" => "mentioned",
|
||||||
"ostatus:object-type" => "http://activitystrea.ms/schema/1.0/collection",
|
"ostatus:object-type" => "http://activitystrea.ms/schema/1.0/collection",
|
||||||
"href" => "http://activityschema.org/collection/public"));
|
"href" => "http://activityschema.org/collection/public"));
|
||||||
|
xml::add_element($doc, $entry, "mastodon:scope", "public");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($tags))
|
if(count($tags))
|
||||||
|
@ -2165,7 +2201,7 @@ class ostatus {
|
||||||
/**
|
/**
|
||||||
* @brief Creates the XML feed for a given nickname
|
* @brief Creates the XML feed for a given nickname
|
||||||
*
|
*
|
||||||
* @param app $a The application class
|
* @param App $a The application class
|
||||||
* @param string $owner_nick Nickname of the feed owner
|
* @param string $owner_nick Nickname of the feed owner
|
||||||
* @param string $last_update Date of the last update
|
* @param string $last_update Date of the last update
|
||||||
*
|
*
|
||||||
|
@ -2227,6 +2263,9 @@ class ostatus {
|
||||||
$root = self::add_header($doc, $owner);
|
$root = self::add_header($doc, $owner);
|
||||||
|
|
||||||
foreach ($items AS $item) {
|
foreach ($items AS $item) {
|
||||||
|
if (Config::get('system', 'ostatus_debug')) {
|
||||||
|
$item['body'] .= '🍼';
|
||||||
|
}
|
||||||
$entry = self::entry($doc, $item, $owner);
|
$entry = self::entry($doc, $item, $owner);
|
||||||
$root->appendChild($entry);
|
$root->appendChild($entry);
|
||||||
}
|
}
|
||||||
|
@ -2247,6 +2286,10 @@ class ostatus {
|
||||||
$doc = new DOMDocument('1.0', 'utf-8');
|
$doc = new DOMDocument('1.0', 'utf-8');
|
||||||
$doc->formatOutput = true;
|
$doc->formatOutput = true;
|
||||||
|
|
||||||
|
if (Config::get('system', 'ostatus_debug')) {
|
||||||
|
$item['body'] .= '🐟';
|
||||||
|
}
|
||||||
|
|
||||||
$entry = self::entry($doc, $item, $owner, true);
|
$entry = self::entry($doc, $item, $owner, true);
|
||||||
|
|
||||||
$doc->appendChild($entry);
|
$doc->appendChild($entry);
|
||||||
|
@ -2254,4 +2297,3 @@ class ostatus {
|
||||||
return(trim($doc->saveXML()));
|
return(trim($doc->saveXML()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
require_once("include/dba.php");
|
require_once("include/dba.php");
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
* @brief Functions related to photo handling.
|
* @brief Functions related to photo handling.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use \Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
|
|
||||||
function getGps($exifCoord, $hemi) {
|
function getGps($exifCoord, $hemi) {
|
||||||
$degrees = count($exifCoord) > 0 ? gps2Num($exifCoord[0]) : 0;
|
$degrees = count($exifCoord) > 0 ? gps2Num($exifCoord[0]) : 0;
|
||||||
|
|
|
@ -38,4 +38,3 @@ class pidfile {
|
||||||
return(posix_kill(file_get_contents($this->_file), SIGTERM));
|
return(posix_kill(file_get_contents($this->_file), SIGTERM));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
* @file include/plaintext.php
|
* @file include/plaintext.php
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use \Friendica\ParseUrl;
|
use Friendica\App;
|
||||||
|
use Friendica\ParseUrl;
|
||||||
|
|
||||||
require_once("include/Photo.php");
|
require_once("include/Photo.php");
|
||||||
require_once("include/bbcode.php");
|
require_once("include/bbcode.php");
|
||||||
|
@ -431,4 +432,3 @@ function plaintext(App $a, $b, $limit = 0, $includedlinks = false, $htmlmode = 2
|
||||||
|
|
||||||
return($post);
|
return($post);
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
* @brief Some functions to handle addons and themes.
|
* @brief Some functions to handle addons and themes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief uninstalls an addon.
|
* @brief uninstalls an addon.
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
if (!file_exists("boot.php") AND (sizeof($_SERVER["argv"]) != 0)) {
|
if (!file_exists("boot.php") AND (sizeof($_SERVER["argv"]) != 0)) {
|
||||||
$directory = dirname($_SERVER["argv"][0]);
|
$directory = dirname($_SERVER["argv"][0]);
|
||||||
|
|
||||||
|
@ -10,15 +14,13 @@ if (!file_exists("boot.php") AND (sizeof($_SERVER["argv"]) != 0)) {
|
||||||
chdir($directory);
|
chdir($directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
|
||||||
|
|
||||||
require_once("boot.php");
|
require_once("boot.php");
|
||||||
|
|
||||||
function poller_run($argv, $argc){
|
function poller_run($argv, $argc){
|
||||||
global $a, $db;
|
global $a, $db;
|
||||||
|
|
||||||
if(is_null($a)) {
|
if (is_null($a)) {
|
||||||
$a = new App;
|
$a = new App(dirname(__DIR__));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_null($db)) {
|
if(is_null($db)) {
|
||||||
|
@ -41,6 +43,10 @@ function poller_run($argv, $argc){
|
||||||
|
|
||||||
$a->start_process();
|
$a->start_process();
|
||||||
|
|
||||||
|
if ($a->min_memory_reached()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (poller_max_connections_reached()) {
|
if (poller_max_connections_reached()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -67,6 +73,11 @@ function poller_run($argv, $argc){
|
||||||
|
|
||||||
while ($r = poller_worker_process()) {
|
while ($r = poller_worker_process()) {
|
||||||
|
|
||||||
|
// Check free memory
|
||||||
|
if ($a->min_memory_reached()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Count active workers and compare them with a maximum value that depends on the load
|
// Count active workers and compare them with a maximum value that depends on the load
|
||||||
if (poller_too_much_workers()) {
|
if (poller_too_much_workers()) {
|
||||||
return;
|
return;
|
||||||
|
@ -80,7 +91,6 @@ function poller_run($argv, $argc){
|
||||||
if (time() > ($starttime + 3600))
|
if (time() > ($starttime + 3600))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -678,4 +688,3 @@ if (array_search(__file__,get_included_files())===0){
|
||||||
|
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -258,5 +258,3 @@ function post_update_1206() {
|
||||||
logger("Done", LOGGER_DEBUG);
|
logger("Done", LOGGER_DEBUG);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -1,14 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
require_once('include/Probe.php');
|
|
||||||
|
|
||||||
/**
|
use Friendica\Network\Probe;
|
||||||
*
|
|
||||||
* Probe a network address to discover what kind of protocols we need to communicate with it.
|
|
||||||
*
|
|
||||||
* Warning: this function is a bit touchy and there are some subtle dependencies within the logic flow.
|
|
||||||
* Edit with care.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -18,16 +10,30 @@ require_once('include/Probe.php');
|
||||||
* of network.
|
* of network.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
define('PROBE_NORMAL', 0);
|
define('PROBE_NORMAL', 0);
|
||||||
define('PROBE_DIASPORA', 1);
|
define('PROBE_DIASPORA', 1);
|
||||||
|
|
||||||
function probe_url($url, $mode = PROBE_NORMAL, $level = 1) {
|
/**
|
||||||
|
* @brief Probes a network address to discover what kind of protocols we need to communicate with it.
|
||||||
|
*
|
||||||
|
* Warning: this function is a bit touchy and there are some subtle dependencies within the logic flow.
|
||||||
|
* Edit with care.
|
||||||
|
*
|
||||||
|
* @deprecated Use Friendica\Network\Probe instead
|
||||||
|
*
|
||||||
|
* @see Friendica\Network\Probe::uri()
|
||||||
|
*
|
||||||
|
* @param string $url Any URI
|
||||||
|
* @param int $mode One of the PROBE_* constants
|
||||||
|
* @return array Same data array returned by Friendica\Network\Probe::uri()
|
||||||
|
*/
|
||||||
|
function probe_url($url, $mode = PROBE_NORMAL) {
|
||||||
|
|
||||||
if ($mode == PROBE_DIASPORA)
|
if ($mode == PROBE_DIASPORA) {
|
||||||
$network = NETWORK_DIASPORA;
|
$network = NETWORK_DIASPORA;
|
||||||
else
|
} else {
|
||||||
$network = "";
|
$network = '';
|
||||||
|
}
|
||||||
|
|
||||||
$data = Probe::uri($url, $network);
|
$data = Probe::uri($url, $network);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
use \Friendica\Core\Config;
|
|
||||||
|
use Friendica\App;
|
||||||
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
require_once('include/items.php');
|
require_once('include/items.php');
|
||||||
require_once('include/ostatus.php');
|
require_once('include/ostatus.php');
|
||||||
|
@ -33,6 +35,9 @@ function handle_pubsubhubbub($id) {
|
||||||
else
|
else
|
||||||
$rr = $r[0];
|
$rr = $r[0];
|
||||||
|
|
||||||
|
/// @todo Check server status with poco_check_server()
|
||||||
|
// Before this can be done we need a way to safely detect the server url.
|
||||||
|
|
||||||
logger("Generate feed of user ".$rr['nickname']." to ".$rr['callback_url']." - last updated ".$rr['last_update'], LOGGER_DEBUG);
|
logger("Generate feed of user ".$rr['nickname']." to ".$rr['callback_url']." - last updated ".$rr['last_update'], LOGGER_DEBUG);
|
||||||
|
|
||||||
$params = ostatus::feed($a, $rr['nickname'], $rr['last_update']);
|
$params = ostatus::feed($a, $rr['nickname'], $rr['last_update']);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
require_once('include/queue_fn.php');
|
require_once('include/queue_fn.php');
|
||||||
require_once('include/dfrn.php');
|
require_once('include/dfrn.php');
|
||||||
|
|
|
@ -129,4 +129,3 @@ function removetofu($message)
|
||||||
|
|
||||||
return($message);
|
return($message);
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
|
||||||
function auto_redir(App $a, $contact_nick) {
|
function auto_redir(App $a, $contact_nick) {
|
||||||
|
|
||||||
// prevent looping
|
// prevent looping
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* @brief Removes orphaned data from deleted contacts
|
* @brief Removes orphaned data from deleted contacts
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
function remove_contact_run($argv, $argc) {
|
function remove_contact_run($argv, $argc) {
|
||||||
if ($argc != 2) {
|
if ($argc != 2) {
|
||||||
|
@ -14,19 +14,11 @@ function remove_contact_run($argv, $argc) {
|
||||||
$id = intval($argv[1]);
|
$id = intval($argv[1]);
|
||||||
|
|
||||||
// Only delete if the contact doesn't exist (anymore)
|
// Only delete if the contact doesn't exist (anymore)
|
||||||
$r = q("SELECT `id` FROM `contact` WHERE `id` = %d", intval($id));
|
$r = dba::select('contact', array('id'), array('id' => $id), array('limit' => 1));
|
||||||
if (dbm::is_result($r)) {
|
if (dbm::is_result($r)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
q("DELETE FROM `item` WHERE `contact-id` = %d", intval($id));
|
// Now we delete all the depending table entries
|
||||||
|
dba::delete('contact', array('id' => $id));
|
||||||
q("DELETE FROM `photo` WHERE `contact-id` = %d", intval($id));
|
|
||||||
|
|
||||||
q("DELETE FROM `mail` WHERE `contact-id` = %d", intval($id));
|
|
||||||
|
|
||||||
q("DELETE FROM `event` WHERE `cid` = %d", intval($id));
|
|
||||||
|
|
||||||
q("DELETE FROM `queue` WHERE `cid` = %d", intval($id));
|
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once('include/crypto.php');
|
use Friendica\Network\Probe;
|
||||||
require_once('include/Probe.php');
|
|
||||||
|
require_once 'include/crypto.php';
|
||||||
|
|
||||||
function get_salmon_key($uri, $keyhash) {
|
function get_salmon_key($uri, $keyhash) {
|
||||||
$ret = array();
|
$ret = array();
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Calculate the hash that is needed for the "Friendica" cookie
|
* @brief Calculate the hash that is needed for the "Friendica" cookie
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\App;
|
||||||
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
require_once("boot.php");
|
require_once("boot.php");
|
||||||
require_once("include/threads.php");
|
require_once("include/threads.php");
|
||||||
|
@ -9,7 +10,7 @@ function shadowupdate_run(&$argv, &$argc){
|
||||||
global $a, $db;
|
global $a, $db;
|
||||||
|
|
||||||
if (is_null($a)) {
|
if (is_null($a)) {
|
||||||
$a = new App;
|
$a = new App(dirname(__DIR__));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($db)) {
|
if (is_null($db)) {
|
||||||
|
|
|
@ -7,14 +7,16 @@
|
||||||
* @todo Detect if it is a forum
|
* @todo Detect if it is a forum
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\App;
|
||||||
|
use Friendica\Core\Config;
|
||||||
|
use Friendica\Network\Probe;
|
||||||
|
|
||||||
require_once('include/datetime.php');
|
require_once 'include/datetime.php';
|
||||||
require_once("include/Scrape.php");
|
require_once 'include/probe.php';
|
||||||
require_once("include/network.php");
|
require_once 'include/network.php';
|
||||||
require_once("include/html2bbcode.php");
|
require_once 'include/html2bbcode.php';
|
||||||
require_once("include/Contact.php");
|
require_once 'include/Contact.php';
|
||||||
require_once("include/Photo.php");
|
require_once 'include/Photo.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Fetch POCO data
|
* @brief Fetch POCO data
|
||||||
|
@ -1008,6 +1010,7 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
if (dbm::is_result($servers) AND ($orig_server_url == $server_url) AND
|
if (dbm::is_result($servers) AND ($orig_server_url == $server_url) AND
|
||||||
($serverret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
|
($serverret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
|
||||||
logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
|
logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
|
||||||
|
dba::p("UPDATE `gserver` SET `last_failure` = ? WHERE `nurl` = ?", datetime_convert(), normalise_link($server_url));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1022,6 +1025,7 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
// Quit if there is a timeout
|
// Quit if there is a timeout
|
||||||
if ($serverret['errno'] == CURLE_OPERATION_TIMEDOUT) {
|
if ($serverret['errno'] == CURLE_OPERATION_TIMEDOUT) {
|
||||||
logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
|
logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
|
||||||
|
dba::p("UPDATE `gserver` SET `last_failure` = ? WHERE `nurl` = ?", datetime_convert(), normalise_link($server_url));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1031,12 +1035,10 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
if (!$serverret["success"] OR ($serverret["body"] == "") OR (sizeof($xmlobj) == 0) OR !is_object($xmlobj)) {
|
if (!$serverret["success"] OR ($serverret["body"] == "") OR (sizeof($xmlobj) == 0) OR !is_object($xmlobj)) {
|
||||||
// Workaround for bad configured servers (known nginx problem)
|
// Workaround for bad configured servers (known nginx problem)
|
||||||
if (!in_array($serverret["debug"]["http_code"], array("403", "404"))) {
|
if (!in_array($serverret["debug"]["http_code"], array("403", "404"))) {
|
||||||
$last_failure = datetime_convert();
|
|
||||||
$failure = true;
|
$failure = true;
|
||||||
}
|
}
|
||||||
$possible_failure = true;
|
$possible_failure = true;
|
||||||
} elseif ($network == NETWORK_DIASPORA)
|
}
|
||||||
$last_contact = datetime_convert();
|
|
||||||
|
|
||||||
// If the server has no possible failure we reset the cached data
|
// If the server has no possible failure we reset the cached data
|
||||||
if (!$possible_failure) {
|
if (!$possible_failure) {
|
||||||
|
@ -1054,8 +1056,6 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
$data = json_decode($serverret["body"]);
|
$data = json_decode($serverret["body"]);
|
||||||
if (isset($data->totalResults)) {
|
if (isset($data->totalResults)) {
|
||||||
$poco = $server_url."/poco";
|
$poco = $server_url."/poco";
|
||||||
$last_contact = datetime_convert();
|
|
||||||
|
|
||||||
$server = poco_detect_poco_data($data);
|
$server = poco_detect_poco_data($data);
|
||||||
if ($server) {
|
if ($server) {
|
||||||
$platform = $server['platform'];
|
$platform = $server['platform'];
|
||||||
|
@ -1072,7 +1072,6 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
$serverret = z_fetch_url($server_url);
|
$serverret = z_fetch_url($server_url);
|
||||||
|
|
||||||
if (!$serverret["success"] OR ($serverret["body"] == "")) {
|
if (!$serverret["success"] OR ($serverret["body"] == "")) {
|
||||||
$last_failure = datetime_convert();
|
|
||||||
$failure = true;
|
$failure = true;
|
||||||
} else {
|
} else {
|
||||||
$server = poco_detect_server_type($serverret["body"]);
|
$server = poco_detect_server_type($serverret["body"]);
|
||||||
|
@ -1081,7 +1080,6 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
$network = $server['network'];
|
$network = $server['network'];
|
||||||
$version = $server['version'];
|
$version = $server['version'];
|
||||||
$site_name = $server['site_name'];
|
$site_name = $server['site_name'];
|
||||||
$last_contact = datetime_convert();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$lines = explode("\n",$serverret["header"]);
|
$lines = explode("\n",$serverret["header"]);
|
||||||
|
@ -1095,15 +1093,11 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
$network = NETWORK_DIASPORA;
|
$network = NETWORK_DIASPORA;
|
||||||
$versionparts = explode("-", $version);
|
$versionparts = explode("-", $version);
|
||||||
$version = $versionparts[0];
|
$version = $versionparts[0];
|
||||||
$last_contact = datetime_convert();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(stristr($line,'Server: Mastodon')) {
|
if(stristr($line,'Server: Mastodon')) {
|
||||||
$platform = "Mastodon";
|
$platform = "Mastodon";
|
||||||
$network = NETWORK_OSTATUS;
|
$network = NETWORK_OSTATUS;
|
||||||
// Mastodon doesn't reveal version numbers
|
|
||||||
$version = "";
|
|
||||||
$last_contact = datetime_convert();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1122,7 +1116,6 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
$version = str_replace(chr(239).chr(187).chr(191), "", $serverret["body"]);
|
$version = str_replace(chr(239).chr(187).chr(191), "", $serverret["body"]);
|
||||||
$version = trim($version, '"');
|
$version = trim($version, '"');
|
||||||
$network = NETWORK_OSTATUS;
|
$network = NETWORK_OSTATUS;
|
||||||
$last_contact = datetime_convert();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test for GNU Social
|
// Test for GNU Social
|
||||||
|
@ -1134,7 +1127,19 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
$version = str_replace(chr(239).chr(187).chr(191), "", $serverret["body"]);
|
$version = str_replace(chr(239).chr(187).chr(191), "", $serverret["body"]);
|
||||||
$version = trim($version, '"');
|
$version = trim($version, '"');
|
||||||
$network = NETWORK_OSTATUS;
|
$network = NETWORK_OSTATUS;
|
||||||
$last_contact = datetime_convert();
|
}
|
||||||
|
|
||||||
|
// Test for Mastodon
|
||||||
|
$serverret = z_fetch_url($server_url."/api/v1/instance");
|
||||||
|
if ($serverret["success"] AND ($serverret["body"] != '')) {
|
||||||
|
$data = json_decode($serverret["body"]);
|
||||||
|
if (isset($data->version)) {
|
||||||
|
$platform = "Mastodon";
|
||||||
|
$version = $data->version;
|
||||||
|
$site_name = $data->title;
|
||||||
|
$info = $data->description;
|
||||||
|
$network = NETWORK_OSTATUS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1144,8 +1149,6 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
if ($serverret["success"]) {
|
if ($serverret["success"]) {
|
||||||
$data = json_decode($serverret["body"]);
|
$data = json_decode($serverret["body"]);
|
||||||
if (isset($data->site->server)) {
|
if (isset($data->site->server)) {
|
||||||
$last_contact = datetime_convert();
|
|
||||||
|
|
||||||
if (isset($data->site->platform)) {
|
if (isset($data->site->platform)) {
|
||||||
$platform = $data->site->platform->PLATFORM_NAME;
|
$platform = $data->site->platform->PLATFORM_NAME;
|
||||||
$version = $data->site->platform->STD_VERSION;
|
$version = $data->site->platform->STD_VERSION;
|
||||||
|
@ -1192,7 +1195,6 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Query statistics.json. Optional package for Diaspora, Friendica and Redmatrix
|
// Query statistics.json. Optional package for Diaspora, Friendica and Redmatrix
|
||||||
if (!$failure) {
|
if (!$failure) {
|
||||||
$serverret = z_fetch_url($server_url."/statistics.json");
|
$serverret = z_fetch_url($server_url."/statistics.json");
|
||||||
|
@ -1220,9 +1222,6 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
} else {
|
} else {
|
||||||
$register_policy = REGISTER_CLOSED;
|
$register_policy = REGISTER_CLOSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($data->version))
|
|
||||||
$last_contact = datetime_convert();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1247,8 +1246,6 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
if (isset($server['site_name'])) {
|
if (isset($server['site_name'])) {
|
||||||
$site_name = $server['site_name'];
|
$site_name = $server['site_name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$last_contact = datetime_convert();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1264,7 +1261,6 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
$data = json_decode($serverret["body"]);
|
$data = json_decode($serverret["body"]);
|
||||||
|
|
||||||
if (isset($data->version)) {
|
if (isset($data->version)) {
|
||||||
$last_contact = datetime_convert();
|
|
||||||
$network = NETWORK_DFRN;
|
$network = NETWORK_DFRN;
|
||||||
|
|
||||||
$noscrape = $data->no_scrape_url;
|
$noscrape = $data->no_scrape_url;
|
||||||
|
@ -1290,13 +1286,14 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($possible_failure AND !$failure) {
|
if ($possible_failure AND !$failure) {
|
||||||
$last_failure = datetime_convert();
|
|
||||||
$failure = true;
|
$failure = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($failure) {
|
if ($failure) {
|
||||||
$last_contact = $orig_last_contact;
|
$last_contact = $orig_last_contact;
|
||||||
|
$last_failure = datetime_convert();
|
||||||
} else {
|
} else {
|
||||||
|
$last_contact = datetime_convert();
|
||||||
$last_failure = $orig_last_failure;
|
$last_failure = $orig_last_failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2345,4 +2342,3 @@ function poco_serverlist() {
|
||||||
}
|
}
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* @brief Posts items that wer spooled because they couldn't be posted.
|
* @brief Posts items that wer spooled because they couldn't be posted.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
require_once("include/items.php");
|
require_once("include/items.php");
|
||||||
|
|
||||||
|
@ -55,4 +55,3 @@ function spool_post_run($argv, $argc) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
|
||||||
function create_tags_from_item($itemid) {
|
function create_tags_from_item($itemid) {
|
||||||
$profile_base = App::get_baseurl();
|
$profile_base = App::get_baseurl();
|
||||||
$profile_data = parse_url($profile_base);
|
$profile_data = parse_url($profile_base);
|
||||||
|
@ -111,12 +114,11 @@ function create_tags_from_itemuri($itemuri, $uid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_items() {
|
function update_items() {
|
||||||
global $db;
|
|
||||||
|
|
||||||
$messages = $db->q("SELECT `oid`,`item`.`guid`, `item`.`created`, `item`.`received` FROM `term` INNER JOIN `item` ON `item`.`id`=`term`.`oid` WHERE `term`.`otype` = 1 AND `term`.`guid` = ''", true);
|
$messages = dba::p("SELECT `oid`,`item`.`guid`, `item`.`created`, `item`.`received` FROM `term` INNER JOIN `item` ON `item`.`id`=`term`.`oid` WHERE `term`.`otype` = 1 AND `term`.`guid` = ''");
|
||||||
|
|
||||||
logger("fetched messages: ".count($messages));
|
logger("fetched messages: ".dba::num_rows($messages));
|
||||||
while ($message = $db->qfetch()) {
|
while ($message = dba::fetch($messages)) {
|
||||||
|
|
||||||
if ($message["uid"] == 0) {
|
if ($message["uid"] == 0) {
|
||||||
$global = true;
|
$global = true;
|
||||||
|
@ -135,15 +137,14 @@ function update_items() {
|
||||||
intval($global), intval(TERM_OBJ_POST), intval($message["oid"]));
|
intval($global), intval(TERM_OBJ_POST), intval($message["oid"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->qclose();
|
dba::close($messages);
|
||||||
|
|
||||||
$messages = $db->q("SELECT `guid` FROM `item` WHERE `uid` = 0", true);
|
$messages = dba::p("SELECT `guid` FROM `item` WHERE `uid` = 0");
|
||||||
|
|
||||||
logger("fetched messages: ".count($messages));
|
logger("fetched messages: ".dba::num_rows($messages));
|
||||||
while ($message = $db->qfetch()) {
|
while ($message = dba::fetch(messages)) {
|
||||||
q("UPDATE `item` SET `global` = 1 WHERE `guid` = '%s'", dbesc($message["guid"]));
|
q("UPDATE `item` SET `global` = 1 WHERE `guid` = '%s'", dbesc($message["guid"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->qclose();
|
dba::close($messages);
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
|
||||||
require_once("include/template_processor.php");
|
require_once("include/template_processor.php");
|
||||||
require_once("include/friendica_smarty.php");
|
require_once("include/friendica_smarty.php");
|
||||||
require_once("include/Smilies.php");
|
require_once("include/Smilies.php");
|
||||||
require_once("include/map.php");
|
require_once("include/map.php");
|
||||||
require_once("mod/proxy.php");
|
require_once("mod/proxy.php");
|
||||||
|
|
||||||
|
|
||||||
if(! function_exists('replace_macros')) {
|
if(! function_exists('replace_macros')) {
|
||||||
/**
|
/**
|
||||||
* This is our template processor
|
* This is our template processor
|
||||||
|
@ -753,6 +754,72 @@ function logger($msg, $level = 0) {
|
||||||
$a->save_timestamp($stamp1, "file");
|
$a->save_timestamp($stamp1, "file");
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief An alternative logger for development.
|
||||||
|
* Works largely as logger() but allows developers
|
||||||
|
* to isolate particular elements they are targetting
|
||||||
|
* personally without background noise
|
||||||
|
*
|
||||||
|
* log levels:
|
||||||
|
* LOGGER_NORMAL (default)
|
||||||
|
* LOGGER_TRACE
|
||||||
|
* LOGGER_DEBUG
|
||||||
|
* LOGGER_DATA
|
||||||
|
* LOGGER_ALL
|
||||||
|
*
|
||||||
|
* @global App $a
|
||||||
|
* @global dba $db
|
||||||
|
* @global array $LOGGER_LEVELS
|
||||||
|
* @param string $msg
|
||||||
|
* @param int $level
|
||||||
|
*/
|
||||||
|
|
||||||
|
function dlogger($msg, $level = 0) {
|
||||||
|
$a = get_app();
|
||||||
|
global $db;
|
||||||
|
|
||||||
|
// turn off logger in install mode
|
||||||
|
if (
|
||||||
|
$a->module == 'install'
|
||||||
|
|| ! ($db && $db->connected)
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$logfile = get_config('system','dlogfile');
|
||||||
|
|
||||||
|
if (! $logfile) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($LOGGER_LEVELS) == 0) {
|
||||||
|
foreach (get_defined_constants() as $k => $v) {
|
||||||
|
if (substr($k, 0, 7) == "LOGGER_") {
|
||||||
|
$LOGGER_LEVELS[$v] = substr($k, 7, 7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$process_id = session_id();
|
||||||
|
|
||||||
|
if ($process_id == '') {
|
||||||
|
$process_id = get_app()->process_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$callers = debug_backtrace();
|
||||||
|
$logline = sprintf("%s@\t%s:\t%s:\t%s\t%s\t%s\n",
|
||||||
|
datetime_convert(),
|
||||||
|
$process_id,
|
||||||
|
basename($callers[0]['file']),
|
||||||
|
$callers[0]['line'],
|
||||||
|
$callers[1]['function'],
|
||||||
|
$msg
|
||||||
|
);
|
||||||
|
|
||||||
|
$stamp1 = microtime(true);
|
||||||
|
@file_put_contents($logfile, $logline, FILE_APPEND);
|
||||||
|
$a->save_timestamp($stamp1, "file");
|
||||||
|
}
|
||||||
|
|
||||||
if(! function_exists('activity_match')) {
|
if(! function_exists('activity_match')) {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
|
||||||
function add_thread($itemid, $onlyshadow = false) {
|
function add_thread($itemid, $onlyshadow = false) {
|
||||||
$items = q("SELECT `uid`, `created`, `edited`, `commented`, `received`, `changed`, `wall`, `private`, `pubmail`,
|
$items = q("SELECT `uid`, `created`, `edited`, `commented`, `received`, `changed`, `wall`, `private`, `pubmail`,
|
||||||
`moderated`, `visible`, `spam`, `starred`, `bookmark`, `contact-id`, `gcontact-id`,
|
`moderated`, `visible`, `spam`, `starred`, `bookmark`, `contact-id`, `gcontact-id`,
|
||||||
|
@ -251,19 +254,17 @@ function delete_thread($itemid, $itemuri = "") {
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_threads() {
|
function update_threads() {
|
||||||
global $db;
|
|
||||||
|
|
||||||
logger("update_threads: start");
|
logger("update_threads: start");
|
||||||
|
|
||||||
$messages = $db->q("SELECT `id` FROM `item` WHERE `id` = `parent`", true);
|
$messages = dba::p("SELECT `id` FROM `item` WHERE `id` = `parent`");
|
||||||
|
|
||||||
logger("update_threads: fetched messages: ".count($messages));
|
logger("update_threads: fetched messages: ".dba::num_rows($messages));
|
||||||
|
|
||||||
while ($message = $db->qfetch()) {
|
while ($message = dba::fetch($messages)) {
|
||||||
add_thread($message["id"]);
|
add_thread($message["id"]);
|
||||||
add_shadow_thread($message["id"]);
|
add_shadow_thread($message["id"]);
|
||||||
}
|
}
|
||||||
$db->qclose();
|
dba::close($messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_threads_mention() {
|
function update_threads_mention() {
|
||||||
|
@ -283,18 +284,15 @@ function update_threads_mention() {
|
||||||
|
|
||||||
|
|
||||||
function update_shadow_copy() {
|
function update_shadow_copy() {
|
||||||
global $db;
|
|
||||||
|
|
||||||
logger("start");
|
logger("start");
|
||||||
|
|
||||||
$messages = $db->q(sprintf("SELECT `iid` FROM `thread` WHERE `uid` != 0 AND `network` IN ('', '%s', '%s', '%s')
|
$messages = dba::p("SELECT `iid` FROM `thread` WHERE `uid` != 0 AND `network` IN ('', ?, ?, ?)
|
||||||
AND `visible` AND NOT `deleted` AND NOT `moderated` AND NOT `private` ORDER BY `created`",
|
AND `visible` AND NOT `deleted` AND NOT `moderated` AND NOT `private` ORDER BY `created`",
|
||||||
NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS), true);
|
NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS);
|
||||||
|
|
||||||
logger("fetched messages: ".count($messages));
|
logger("fetched messages: ".dba::num_rows($messages));
|
||||||
while ($message = $db->qfetch())
|
while ($message = dba::fetch($messages))
|
||||||
add_shadow_thread($message["iid"]);
|
add_shadow_thread($message["iid"]);
|
||||||
|
|
||||||
$db->qclose();
|
dba::close($messages);
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,19 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
use Friendica\App;
|
||||||
* import account file exported from mod/uexport
|
|
||||||
* args:
|
|
||||||
* $a App Friendica App Class
|
|
||||||
* $file Array array from $_FILES
|
|
||||||
*/
|
|
||||||
require_once("include/Photo.php");
|
require_once("include/Photo.php");
|
||||||
define("IMPORT_DEBUG", False);
|
define("IMPORT_DEBUG", False);
|
||||||
|
|
||||||
function last_insert_id() {
|
function last_insert_id() {
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
if (IMPORT_DEBUG)
|
if (IMPORT_DEBUG) {
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return $db->insert_id();
|
return $db->insert_id();
|
||||||
}
|
}
|
||||||
|
@ -60,8 +57,9 @@ function db_import_assoc($table, $arr) {
|
||||||
$vals = implode("','", array_map('dbesc', array_values($arr)));
|
$vals = implode("','", array_map('dbesc', array_values($arr)));
|
||||||
$query = "INSERT INTO `$table` (`$cols`) VALUES ('$vals')";
|
$query = "INSERT INTO `$table` (`$cols`) VALUES ('$vals')";
|
||||||
logger("uimport: $query", LOGGER_TRACE);
|
logger("uimport: $query", LOGGER_TRACE);
|
||||||
if (IMPORT_DEBUG)
|
if (IMPORT_DEBUG) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
return q($query);
|
return q($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +73,12 @@ function import_cleanup($newuid) {
|
||||||
q("DELETE FROM `pconfig` WHERE uid = %d", $newuid);
|
q("DELETE FROM `pconfig` WHERE uid = %d", $newuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Import account file exported from mod/uexport
|
||||||
|
*
|
||||||
|
* @param App $a Friendica App Class
|
||||||
|
* @param array $file array from $_FILES
|
||||||
|
*/
|
||||||
function import_account(App $a, $file) {
|
function import_account(App $a, $file) {
|
||||||
logger("Start user import from " . $file['tmp_name']);
|
logger("Start user import from " . $file['tmp_name']);
|
||||||
/*
|
/*
|
||||||
|
@ -99,6 +103,7 @@ function import_account(App $a, $file) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
* @TODO Old-lost code?
|
||||||
// this is not required as we remove columns in json not in current db schema
|
// this is not required as we remove columns in json not in current db schema
|
||||||
if ($account['schema'] != DB_UPDATE_VERSION) {
|
if ($account['schema'] != DB_UPDATE_VERSION) {
|
||||||
notice(t("Error! I can't import this file: DB schema version is not compatible."));
|
notice(t("Error! I can't import this file: DB schema version is not compatible."));
|
||||||
|
@ -137,11 +142,11 @@ function import_account(App $a, $file) {
|
||||||
unset($account['user']['account_expired']);
|
unset($account['user']['account_expired']);
|
||||||
unset($account['user']['account_expires_on']);
|
unset($account['user']['account_expires_on']);
|
||||||
unset($account['user']['expire_notification_sent']);
|
unset($account['user']['expire_notification_sent']);
|
||||||
|
|
||||||
foreach ($account['user'] as $k => &$v) {
|
foreach ($account['user'] as $k => &$v) {
|
||||||
$v = str_replace($oldbaseurl, $newbaseurl, $v);
|
$v = str_replace($oldbaseurl, $newbaseurl, $v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// import user
|
// import user
|
||||||
$r = db_import_assoc('user', $account['user']);
|
$r = db_import_assoc('user', $account['user']);
|
||||||
if ($r === false) {
|
if ($r === false) {
|
||||||
|
@ -160,9 +165,10 @@ function import_account(App $a, $file) {
|
||||||
foreach ($account['profile'] as &$profile) {
|
foreach ($account['profile'] as &$profile) {
|
||||||
foreach ($profile as $k => &$v) {
|
foreach ($profile as $k => &$v) {
|
||||||
$v = str_replace($oldbaseurl, $newbaseurl, $v);
|
$v = str_replace($oldbaseurl, $newbaseurl, $v);
|
||||||
foreach (array("profile", "avatar") as $k)
|
foreach (array("profile", "avatar") as $k) {
|
||||||
$v = str_replace($oldbaseurl . "/photo/" . $k . "/" . $olduid . ".jpg", $newbaseurl . "/photo/" . $k . "/" . $newuid . ".jpg", $v);
|
$v = str_replace($oldbaseurl . "/photo/" . $k . "/" . $olduid . ".jpg", $newbaseurl . "/photo/" . $k . "/" . $newuid . ".jpg", $v);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$profile['uid'] = $newuid;
|
$profile['uid'] = $newuid;
|
||||||
$r = db_import_assoc('profile', $profile);
|
$r = db_import_assoc('profile', $profile);
|
||||||
if ($r === false) {
|
if ($r === false) {
|
||||||
|
@ -178,15 +184,15 @@ function import_account(App $a, $file) {
|
||||||
if ($contact['uid'] == $olduid && $contact['self'] == '1') {
|
if ($contact['uid'] == $olduid && $contact['self'] == '1') {
|
||||||
foreach ($contact as $k => &$v) {
|
foreach ($contact as $k => &$v) {
|
||||||
$v = str_replace($oldbaseurl, $newbaseurl, $v);
|
$v = str_replace($oldbaseurl, $newbaseurl, $v);
|
||||||
foreach (array("profile", "avatar", "micro") as $k)
|
foreach (array("profile", "avatar", "micro") as $k) {
|
||||||
$v = str_replace($oldbaseurl . "/photo/" . $k . "/" . $olduid . ".jpg", $newbaseurl . "/photo/" . $k . "/" . $newuid . ".jpg", $v);
|
$v = str_replace($oldbaseurl . "/photo/" . $k . "/" . $olduid . ".jpg", $newbaseurl . "/photo/" . $k . "/" . $newuid . ".jpg", $v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ($contact['uid'] == $olduid && $contact['self'] == '0') {
|
if ($contact['uid'] == $olduid && $contact['self'] == '0') {
|
||||||
// set contacts 'avatar-date' to NULL_DATE to let poller to update urls
|
// set contacts 'avatar-date' to NULL_DATE to let poller to update urls
|
||||||
$contact["avatar-date"] = NULL_DATE;
|
$contact["avatar-date"] = NULL_DATE;
|
||||||
|
|
||||||
|
|
||||||
switch ($contact['network']) {
|
switch ($contact['network']) {
|
||||||
case NETWORK_DFRN:
|
case NETWORK_DFRN:
|
||||||
// send relocate message (below)
|
// send relocate message (below)
|
||||||
|
@ -255,10 +261,6 @@ function import_account(App $a, $file) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach ($account['photo'] as &$photo) {
|
foreach ($account['photo'] as &$photo) {
|
||||||
$photo['uid'] = $newuid;
|
$photo['uid'] = $newuid;
|
||||||
$photo['data'] = hex2bin($photo['data']);
|
$photo['data'] = hex2bin($photo['data']);
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
function update_gcontact_run(&$argv, &$argc) {
|
function update_gcontact_run(&$argv, &$argc) {
|
||||||
global $a;
|
global $a;
|
||||||
|
|
||||||
require_once 'include/Scrape.php';
|
require_once 'include/probe.php';
|
||||||
require_once 'include/socgraph.php';
|
require_once 'include/socgraph.php';
|
||||||
|
|
||||||
logger('update_gcontact: start');
|
logger('update_gcontact: start');
|
||||||
|
|
21
index.php
21
index.php
|
@ -13,12 +13,13 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\App;
|
||||||
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
require_once('boot.php');
|
require_once 'boot.php';
|
||||||
require_once('object/BaseObject.php');
|
require_once 'object/BaseObject.php';
|
||||||
|
|
||||||
$a = new App;
|
$a = new App(__DIR__);
|
||||||
BaseObject::set_app($a);
|
BaseObject::set_app($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
|
||||||
|
@ -73,7 +74,7 @@ if (!$install) {
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once("include/session.php");
|
require_once 'include/session.php';
|
||||||
load_hooks();
|
load_hooks();
|
||||||
call_hooks('init_1');
|
call_hooks('init_1');
|
||||||
|
|
||||||
|
@ -112,9 +113,11 @@ if (!$a->is_backend()) {
|
||||||
*/
|
*/
|
||||||
if (x($_SESSION,'authenticated') && !x($_SESSION,'language')) {
|
if (x($_SESSION,'authenticated') && !x($_SESSION,'language')) {
|
||||||
// we didn't loaded user data yet, but we need user language
|
// we didn't loaded user data yet, but we need user language
|
||||||
$r = q("SELECT language FROM user WHERE uid=%d", intval($_SESSION['uid']));
|
$r = dba::select('user', array('language'), array('uid' => $_SESSION['uid']), array('limit' => 1));
|
||||||
$_SESSION['language'] = $lang;
|
$_SESSION['language'] = $lang;
|
||||||
if (dbm::is_result($r)) $_SESSION['language'] = $r[0]['language'];
|
if (dbm::is_result($r)) {
|
||||||
|
$_SESSION['language'] = $r['language'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((x($_SESSION,'language')) && ($_SESSION['language'] !== $lang)) {
|
if ((x($_SESSION,'language')) && ($_SESSION['language'] !== $lang)) {
|
||||||
|
@ -174,6 +177,10 @@ if (! x($_SESSION,'sysmsg_info')) {
|
||||||
$_SESSION['sysmsg_info'] = array();
|
$_SESSION['sysmsg_info'] = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Array for informations about last received items
|
||||||
|
if (! x($_SESSION,'last_updated')) {
|
||||||
|
$_SESSION['last_updated'] = array();
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* check_config() is responsible for running update scripts. These automatically
|
* check_config() is responsible for running update scripts. These automatically
|
||||||
* update the DB schema whenever we push a new one out. It also checks to see if
|
* update the DB schema whenever we push a new one out. It also checks to see if
|
||||||
|
|
|
@ -78,22 +78,26 @@ function contact_format(item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function editor_replace(item) {
|
function editor_replace(item) {
|
||||||
if(typeof item.replace !== 'undefined') {
|
if (typeof item.replace !== 'undefined') {
|
||||||
return '$1$2' + item.replace;
|
return '$1$2' + item.replace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof item.addr !== 'undefined') {
|
||||||
|
return '$1$2' + item.addr + ' ';
|
||||||
|
}
|
||||||
|
|
||||||
// $2 ensures that prefix (@,@!) is preserved
|
// $2 ensures that prefix (@,@!) is preserved
|
||||||
var id = item.id;
|
var id = item.id;
|
||||||
|
|
||||||
// don't add the id if it is empty (the id empty eg. if there are unknow contacts in thread)
|
// don't add the id if it is empty (the id empty eg. if there are unknow contacts in thread)
|
||||||
if(id.length < 1)
|
if (id.length < 1) {
|
||||||
return '$1$2' + item.nick.replace(' ', '') + ' ';
|
return '$1$2' + item.nick.replace(' ', '') + ' ';
|
||||||
|
}
|
||||||
// 16 chars of hash should be enough. Full hash could be used if it can be done in a visually appealing way.
|
// 16 chars of hash should be enough. Full hash could be used if it can be done in a visually appealing way.
|
||||||
// 16 chars is also the minimum length in the backend (otherwise it's interpreted as a local id).
|
// 16 chars is also the minimum length in the backend (otherwise it's interpreted as a local id).
|
||||||
if(id.length > 16)
|
if (id.length > 16) {
|
||||||
id = item.id.substring(0,16);
|
id = item.id.substring(0,16);
|
||||||
|
}
|
||||||
return '$1$2' + item.nick.replace(' ', '') + '+' + id + ' ';
|
return '$1$2' + item.nick.replace(' ', '') + '+' + id + ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\App;
|
||||||
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
require_once("mod/hostxrd.php");
|
require_once("mod/hostxrd.php");
|
||||||
require_once("mod/nodeinfo.php");
|
require_once("mod/nodeinfo.php");
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once('include/Scrape.php');
|
use Friendica\App;
|
||||||
|
|
||||||
|
require_once 'include/probe.php';
|
||||||
|
|
||||||
function acctlink_init(App $a) {
|
function acctlink_init(App $a) {
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
/* ACL selector json backend */
|
/* ACL selector json backend */
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
|
||||||
require_once 'include/acl_selectors.php';
|
require_once 'include/acl_selectors.php';
|
||||||
|
|
||||||
function acl_init(App $a) {
|
function acl_init(App $a) {
|
||||||
|
|
103
mod/admin.php
103
mod/admin.php
|
@ -6,7 +6,8 @@
|
||||||
* @brief Friendica admin
|
* @brief Friendica admin
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use Friendica\App;
|
||||||
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
require_once("include/enotify.php");
|
require_once("include/enotify.php");
|
||||||
require_once("include/text.php");
|
require_once("include/text.php");
|
||||||
|
@ -109,6 +110,9 @@ function admin_post(App $a) {
|
||||||
case 'dbsync':
|
case 'dbsync':
|
||||||
admin_page_dbsync_post($a);
|
admin_page_dbsync_post($a);
|
||||||
break;
|
break;
|
||||||
|
case 'blocklist':
|
||||||
|
admin_page_blocklist_post($a);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,6 +170,7 @@ function admin_content(App $a) {
|
||||||
'features' => array("admin/features/", t("Additional features") , "features"),
|
'features' => array("admin/features/", t("Additional features") , "features"),
|
||||||
'dbsync' => array("admin/dbsync/", t('DB updates'), "dbsync"),
|
'dbsync' => array("admin/dbsync/", t('DB updates'), "dbsync"),
|
||||||
'queue' => array("admin/queue/", t('Inspect Queue'), "queue"),
|
'queue' => array("admin/queue/", t('Inspect Queue'), "queue"),
|
||||||
|
'blocklist' => array("admin/blocklist/", t('Server Blocklist'), "blocklist"),
|
||||||
'federation' => array("admin/federation/", t('Federation Statistics'), "federation"),
|
'federation' => array("admin/federation/", t('Federation Statistics'), "federation"),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -236,6 +241,9 @@ function admin_content(App $a) {
|
||||||
case 'federation':
|
case 'federation':
|
||||||
$o = admin_page_federation($a);
|
$o = admin_page_federation($a);
|
||||||
break;
|
break;
|
||||||
|
case 'blocklist':
|
||||||
|
$o = admin_page_blocklist($a);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
notice(t("Item not found."));
|
notice(t("Item not found."));
|
||||||
}
|
}
|
||||||
|
@ -252,6 +260,94 @@ function admin_content(App $a) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Subpage to modify the server wide block list via the admin panel.
|
||||||
|
*
|
||||||
|
* This function generates the subpage of the admin panel to allow the
|
||||||
|
* modification of the node wide block/black list to block entire
|
||||||
|
* remote servers from communication with this node. The page allows
|
||||||
|
* adding, removing and editing of entries from the blocklist.
|
||||||
|
*
|
||||||
|
* @param App $a
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function admin_page_blocklist(App $a) {
|
||||||
|
$blocklist = Config::get('system', 'blocklist');
|
||||||
|
$blocklistform = array();
|
||||||
|
if (is_array($blocklist)) {
|
||||||
|
foreach($blocklist as $id => $b) {
|
||||||
|
$blocklistform[] = array(
|
||||||
|
'domain' => array("domain[$id]", t('Blocked domain'), $b['domain'], '', t('The blocked domain'), 'required', '', ''),
|
||||||
|
'reason' => array("reason[$id]", t("Reason for the block"), $b['reason'], t('The reason why you blocked this domain.').'('.$b['domain'].')', 'required', '', ''),
|
||||||
|
'delete' => array("delete[$id]", t("Delete domain").' ('.$b['domain'].')', False , t("Check to delete this entry from the blocklist"))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$t = get_markup_template("admin_blocklist.tpl");
|
||||||
|
return replace_macros($t, array(
|
||||||
|
'$title' => t('Administration'),
|
||||||
|
'$page' => t('Server Blocklist'),
|
||||||
|
'$intro' => t('This page can be used to define a black list of servers from the federated network that are not allowed to interact with your node. For all entered domains you should also give a reason why you have blocked the remote server.'),
|
||||||
|
'$public' => t('The list of blocked servers will be made publically available on the /friendica page so that your users and people investigating communication problems can find the reason easily.'),
|
||||||
|
'$addtitle' => t('Add new entry to block list'),
|
||||||
|
'$newdomain' => array('newentry_domain', t('Server Domain'), '', t('The domain of the new server to add to the block list. Do not include the protocol.'), 'required', '', ''),
|
||||||
|
'$newreason' => array('newentry_reason', t('Block reason'), '', t('The reason why you blocked this domain.'), 'required', '', ''),
|
||||||
|
'$submit' => t('Add Entry'),
|
||||||
|
'$savechanges' => t('Save changes to the blocklist'),
|
||||||
|
'$currenttitle' => t('Current Entries in the Blocklist'),
|
||||||
|
'$thurl' => t('Blocked domain'),
|
||||||
|
'$threason' => t('Reason for the block'),
|
||||||
|
'$delentry' => t('Delete entry from blocklist'),
|
||||||
|
'$entries' => $blocklistform,
|
||||||
|
'$baseurl' => App::get_baseurl(true),
|
||||||
|
'$confirm_delete' => t('Delete entry from blocklist?'),
|
||||||
|
'$form_security_token' => get_form_security_token("admin_blocklist")
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Process send data from Admin Blocklist Page
|
||||||
|
*
|
||||||
|
* @param App $a
|
||||||
|
*/
|
||||||
|
function admin_page_blocklist_post(App $a) {
|
||||||
|
if (!x($_POST,"page_blocklist_save") && (!x($_POST['page_blocklist_edit']))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
check_form_security_token_redirectOnErr('/admin/blocklist', 'admin_blocklist');
|
||||||
|
|
||||||
|
if (x($_POST['page_blocklist_save'])) {
|
||||||
|
// Add new item to blocklist
|
||||||
|
$blocklist = get_config('system', 'blocklist');
|
||||||
|
$blocklist[] = array(
|
||||||
|
'domain' => notags(trim($_POST['newentry_domain'])),
|
||||||
|
'reason' => notags(trim($_POST['newentry_reason']))
|
||||||
|
);
|
||||||
|
Config::set('system', 'blocklist', $blocklist);
|
||||||
|
info(t('Server added to blocklist.').EOL);
|
||||||
|
} else {
|
||||||
|
// Edit the entries from blocklist
|
||||||
|
$blocklist = array();
|
||||||
|
foreach ($_POST['domain'] as $id => $domain) {
|
||||||
|
// Trimming whitespaces as well as any lingering slashes
|
||||||
|
$domain = notags(trim($domain, "\x00..\x1F/"));
|
||||||
|
$reason = notags(trim($_POST['reason'][$id]));
|
||||||
|
if (!x($_POST['delete'][$id])) {
|
||||||
|
$blocklist[] = array(
|
||||||
|
'domain' => $domain,
|
||||||
|
'reason' => $reason
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Config::set('system', 'blocklist', $blocklist);
|
||||||
|
info(t('Site blocklist updated.').EOL);
|
||||||
|
}
|
||||||
|
goaway('admin/blocklist');
|
||||||
|
|
||||||
|
return; // NOTREACHED
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Subpage with some stats about "the federation" network
|
* @brief Subpage with some stats about "the federation" network
|
||||||
*
|
*
|
||||||
|
@ -447,7 +543,7 @@ function admin_page_summary(App $a) {
|
||||||
$warningtext = array();
|
$warningtext = array();
|
||||||
if (dbm::is_result($r)) {
|
if (dbm::is_result($r)) {
|
||||||
$showwarning = true;
|
$showwarning = true;
|
||||||
$warningtext[] = sprintf(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 <tt>convert_innodb.sql</tt> in the <tt>/util</tt> directory of your Friendica installation.<br />'), 'https://dev.mysql.com/doc/refman/5.7/en/converting-tables-to-innodb.html');
|
$warningtext[] = sprintf(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 include/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');
|
||||||
}
|
}
|
||||||
// MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
|
// MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
|
||||||
if ((version_compare($db->server_info(), '5.7.4') >= 0) AND
|
if ((version_compare($db->server_info(), '5.7.4') >= 0) AND
|
||||||
|
@ -636,6 +732,7 @@ function admin_page_site_post(App $a) {
|
||||||
$timeout = ((x($_POST,'timeout')) ? intval(trim($_POST['timeout'])) : 60);
|
$timeout = ((x($_POST,'timeout')) ? intval(trim($_POST['timeout'])) : 60);
|
||||||
$maxloadavg = ((x($_POST,'maxloadavg')) ? intval(trim($_POST['maxloadavg'])) : 50);
|
$maxloadavg = ((x($_POST,'maxloadavg')) ? intval(trim($_POST['maxloadavg'])) : 50);
|
||||||
$maxloadavg_frontend = ((x($_POST,'maxloadavg_frontend')) ? intval(trim($_POST['maxloadavg_frontend'])) : 50);
|
$maxloadavg_frontend = ((x($_POST,'maxloadavg_frontend')) ? intval(trim($_POST['maxloadavg_frontend'])) : 50);
|
||||||
|
$min_memory = ((x($_POST,'min_memory')) ? intval(trim($_POST['min_memory'])) : 0);
|
||||||
$optimize_max_tablesize = ((x($_POST,'optimize_max_tablesize')) ? intval(trim($_POST['optimize_max_tablesize'])): 100);
|
$optimize_max_tablesize = ((x($_POST,'optimize_max_tablesize')) ? intval(trim($_POST['optimize_max_tablesize'])): 100);
|
||||||
$optimize_fragmentation = ((x($_POST,'optimize_fragmentation')) ? intval(trim($_POST['optimize_fragmentation'])): 30);
|
$optimize_fragmentation = ((x($_POST,'optimize_fragmentation')) ? intval(trim($_POST['optimize_fragmentation'])): 30);
|
||||||
$poco_completion = ((x($_POST,'poco_completion')) ? intval(trim($_POST['poco_completion'])) : false);
|
$poco_completion = ((x($_POST,'poco_completion')) ? intval(trim($_POST['poco_completion'])) : false);
|
||||||
|
@ -721,6 +818,7 @@ function admin_page_site_post(App $a) {
|
||||||
set_config('system','ssl_policy',$ssl_policy);
|
set_config('system','ssl_policy',$ssl_policy);
|
||||||
set_config('system','maxloadavg',$maxloadavg);
|
set_config('system','maxloadavg',$maxloadavg);
|
||||||
set_config('system','maxloadavg_frontend',$maxloadavg_frontend);
|
set_config('system','maxloadavg_frontend',$maxloadavg_frontend);
|
||||||
|
set_config('system','min_memory',$min_memory);
|
||||||
set_config('system','optimize_max_tablesize',$optimize_max_tablesize);
|
set_config('system','optimize_max_tablesize',$optimize_max_tablesize);
|
||||||
set_config('system','optimize_fragmentation',$optimize_fragmentation);
|
set_config('system','optimize_fragmentation',$optimize_fragmentation);
|
||||||
set_config('system','poco_completion',$poco_completion);
|
set_config('system','poco_completion',$poco_completion);
|
||||||
|
@ -1018,6 +1116,7 @@ function admin_page_site(App $a) {
|
||||||
'$timeout' => array('timeout', t("Network timeout"), (x(get_config('system','curl_timeout'))?get_config('system','curl_timeout'):60), t("Value is in seconds. Set to 0 for unlimited (not recommended).")),
|
'$timeout' => array('timeout', t("Network timeout"), (x(get_config('system','curl_timeout'))?get_config('system','curl_timeout'):60), t("Value is in seconds. Set to 0 for unlimited (not recommended).")),
|
||||||
'$maxloadavg' => array('maxloadavg', t("Maximum Load Average"), ((intval(get_config('system','maxloadavg')) > 0)?get_config('system','maxloadavg'):50), t("Maximum system load before delivery and poll processes are deferred - default 50.")),
|
'$maxloadavg' => array('maxloadavg', t("Maximum Load Average"), ((intval(get_config('system','maxloadavg')) > 0)?get_config('system','maxloadavg'):50), t("Maximum system load before delivery and poll processes are deferred - default 50.")),
|
||||||
'$maxloadavg_frontend' => array('maxloadavg_frontend', t("Maximum Load Average (Frontend)"), ((intval(get_config('system','maxloadavg_frontend')) > 0)?get_config('system','maxloadavg_frontend'):50), t("Maximum system load before the frontend quits service - default 50.")),
|
'$maxloadavg_frontend' => array('maxloadavg_frontend', t("Maximum Load Average (Frontend)"), ((intval(get_config('system','maxloadavg_frontend')) > 0)?get_config('system','maxloadavg_frontend'):50), t("Maximum system load before the frontend quits service - default 50.")),
|
||||||
|
'$min_memory' => array('min_memory', t("Minimal Memory"), ((intval(get_config('system','min_memory')) > 0)?get_config('system','min_memory'):0), t("Minimal free memory in MB for the poller. Needs access to /proc/meminfo - default 0 (deactivated).")),
|
||||||
'$optimize_max_tablesize'=> array('optimize_max_tablesize', t("Maximum table size for optimization"), $optimize_max_tablesize, t("Maximum table size (in MB) for the automatic optimization - default 100 MB. Enter -1 to disable it.")),
|
'$optimize_max_tablesize'=> array('optimize_max_tablesize', t("Maximum table size for optimization"), $optimize_max_tablesize, t("Maximum table size (in MB) for the automatic optimization - default 100 MB. Enter -1 to disable it.")),
|
||||||
'$optimize_fragmentation'=> array('optimize_fragmentation', t("Minimum level of fragmentation"), ((intval(get_config('system','optimize_fragmentation')) > 0)?get_config('system','optimize_fragmentation'):30), t("Minimum fragmenation level to start the automatic optimization - default value is 30%.")),
|
'$optimize_fragmentation'=> array('optimize_fragmentation', t("Minimum level of fragmentation"), ((intval(get_config('system','optimize_fragmentation')) > 0)?get_config('system','optimize_fragmentation'):30), t("Minimum fragmenation level to start the automatic optimization - default value is 30%.")),
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
|
||||||
require_once('include/socgraph.php');
|
require_once('include/socgraph.php');
|
||||||
require_once('include/Contact.php');
|
require_once('include/Contact.php');
|
||||||
require_once('include/contact_selectors.php');
|
require_once('include/contact_selectors.php');
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
|
||||||
function amcd_content(App $a) {
|
function amcd_content(App $a) {
|
||||||
//header("Content-type: text/json");
|
echo <<< JSON
|
||||||
echo <<< EOT
|
|
||||||
{
|
{
|
||||||
"version":1,
|
"version":1,
|
||||||
"sessionstatus":{
|
"sessionstatus":{
|
||||||
|
@ -44,6 +45,6 @@ echo <<< EOT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EOT;
|
JSON;
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
|
||||||
require_once('include/api.php');
|
require_once('include/api.php');
|
||||||
|
|
||||||
function oauth_get_client($request){
|
function oauth_get_client($request){
|
||||||
|
@ -106,8 +108,6 @@ function api_content(App $a) {
|
||||||
'$no' => t('No'),
|
'$no' => t('No'),
|
||||||
));
|
));
|
||||||
|
|
||||||
//echo "<pre>"; var_dump($app); killme();
|
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user