Merge branch 'develop' of https://github.com/friendica/friendica into develop
This commit is contained in:
commit
a97b540ebb
218 changed files with 11066 additions and 5869 deletions
|
@ -54,7 +54,7 @@ require_once "include/dba.php";
|
|||
|
||||
$a = new App(dirname(__DIR__));
|
||||
|
||||
if ($a->mode === App::MODE_NORMAL) {
|
||||
if ($a->getMode()->isNormal()) {
|
||||
$oAuth = new ExAuth();
|
||||
$oAuth->readStdin();
|
||||
}
|
Binary file not shown.
|
@ -34,7 +34,7 @@ require_once "include/dba.php";
|
|||
|
||||
$a = new App(dirname(__DIR__));
|
||||
|
||||
if ($a->isInstallMode()) {
|
||||
if ($a->getMode()->isInstall()) {
|
||||
die("Friendica isn't properly installed yet.\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ if (Config::get('system', 'maintenance', false, true)) {
|
|||
return;
|
||||
}
|
||||
|
||||
$a->set_baseurl(Config::get('system', 'url'));
|
||||
$a->setBaseURL(Config::get('system', 'url'));
|
||||
|
||||
Addon::loadHooks();
|
||||
|
||||
|
|
160
boot.php
160
boot.php
|
@ -41,7 +41,7 @@ define('FRIENDICA_PLATFORM', 'Friendica');
|
|||
define('FRIENDICA_CODENAME', 'The Tazmans Flax-lily');
|
||||
define('FRIENDICA_VERSION', '2018.12-dev');
|
||||
define('DFRN_PROTOCOL_VERSION', '2.23');
|
||||
define('DB_UPDATE_VERSION', 1283);
|
||||
define('DB_UPDATE_VERSION', 1285);
|
||||
define('NEW_UPDATE_ROUTINE_VERSION', 1170);
|
||||
|
||||
/**
|
||||
|
@ -475,44 +475,6 @@ function defaults() {
|
|||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the baseurl.
|
||||
*
|
||||
* @see System::baseUrl()
|
||||
*
|
||||
* @return string
|
||||
* @TODO Function is deprecated and only used in some addons
|
||||
*/
|
||||
function z_root()
|
||||
{
|
||||
return System::baseUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return absolut URL for given $path.
|
||||
*
|
||||
* @param string $path given path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function absurl($path)
|
||||
{
|
||||
if (strpos($path, '/') === 0) {
|
||||
return z_path() . $path;
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function to check if request was an AJAX (xmlhttprequest) request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function is_ajax()
|
||||
{
|
||||
return (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function to check if request was an AJAX (xmlhttprequest) request.
|
||||
*
|
||||
|
@ -556,7 +518,7 @@ function check_url(App $a)
|
|||
// and www.example.com vs example.com.
|
||||
// We will only change the url to an ip address if there is no existing setting
|
||||
|
||||
if (empty($url) || (!link_compare($url, System::baseUrl())) && (!preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $a->get_hostname()))) {
|
||||
if (empty($url) || (!link_compare($url, System::baseUrl())) && (!preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $a->getHostName()))) {
|
||||
Config::set('system', 'url', System::baseUrl());
|
||||
}
|
||||
|
||||
|
@ -673,62 +635,6 @@ function run_update_function($x, $prefix)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Synchronise addons:
|
||||
*
|
||||
* system.addon contains a comma-separated list of names
|
||||
* of addons which are used on this system.
|
||||
* Go through the database list of already installed addons, and if we have
|
||||
* an entry, but it isn't in the config list, call the uninstall procedure
|
||||
* and mark it uninstalled in the database (for now we'll remove it).
|
||||
* Then go through the config list and if we have a addon that isn't installed,
|
||||
* call the install procedure and add it to the database.
|
||||
*
|
||||
* @param object $a App
|
||||
*/
|
||||
function check_addons(App $a)
|
||||
{
|
||||
$r = q("SELECT * FROM `addon` WHERE `installed` = 1");
|
||||
if (DBA::isResult($r)) {
|
||||
$installed = $r;
|
||||
} else {
|
||||
$installed = [];
|
||||
}
|
||||
|
||||
$addons = Config::get('system', 'addon');
|
||||
$addons_arr = [];
|
||||
|
||||
if ($addons) {
|
||||
$addons_arr = explode(',', str_replace(' ', '', $addons));
|
||||
}
|
||||
|
||||
$a->addons = $addons_arr;
|
||||
|
||||
$installed_arr = [];
|
||||
|
||||
if (count($installed)) {
|
||||
foreach ($installed as $i) {
|
||||
if (!in_array($i['name'], $addons_arr)) {
|
||||
Addon::uninstall($i['name']);
|
||||
} else {
|
||||
$installed_arr[] = $i['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($addons_arr)) {
|
||||
foreach ($addons_arr as $p) {
|
||||
if (!in_array($p, $installed_arr)) {
|
||||
Addon::install($p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Addon::loadHooks();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Used to end the current process, after saving session state.
|
||||
* @deprecated
|
||||
|
@ -1031,27 +937,27 @@ function get_temppath()
|
|||
|
||||
$temppath = Config::get("system", "temppath");
|
||||
|
||||
if (($temppath != "") && App::directory_usable($temppath)) {
|
||||
if (($temppath != "") && App::isDirectoryUsable($temppath)) {
|
||||
// We have a temp path and it is usable
|
||||
return App::realpath($temppath);
|
||||
return App::getRealPath($temppath);
|
||||
}
|
||||
|
||||
// We don't have a working preconfigured temp path, so we take the system path.
|
||||
$temppath = sys_get_temp_dir();
|
||||
|
||||
// Check if it is usable
|
||||
if (($temppath != "") && App::directory_usable($temppath)) {
|
||||
if (($temppath != "") && App::isDirectoryUsable($temppath)) {
|
||||
// Always store the real path, not the path through symlinks
|
||||
$temppath = App::realpath($temppath);
|
||||
$temppath = App::getRealPath($temppath);
|
||||
|
||||
// To avoid any interferences with other systems we create our own directory
|
||||
$new_temppath = $temppath . "/" . $a->get_hostname();
|
||||
$new_temppath = $temppath . "/" . $a->getHostName();
|
||||
if (!is_dir($new_temppath)) {
|
||||
/// @TODO There is a mkdir()+chmod() upwards, maybe generalize this (+ configurable) into a function/method?
|
||||
mkdir($new_temppath);
|
||||
}
|
||||
|
||||
if (App::directory_usable($new_temppath)) {
|
||||
if (App::isDirectoryUsable($new_temppath)) {
|
||||
// The new path is usable, we are happy
|
||||
Config::set("system", "temppath", $new_temppath);
|
||||
return $new_temppath;
|
||||
|
@ -1133,8 +1039,8 @@ function get_itemcachepath()
|
|||
}
|
||||
|
||||
$itemcache = Config::get('system', 'itemcache');
|
||||
if (($itemcache != "") && App::directory_usable($itemcache)) {
|
||||
return App::realpath($itemcache);
|
||||
if (($itemcache != "") && App::isDirectoryUsable($itemcache)) {
|
||||
return App::getRealPath($itemcache);
|
||||
}
|
||||
|
||||
$temppath = get_temppath();
|
||||
|
@ -1145,7 +1051,7 @@ function get_itemcachepath()
|
|||
mkdir($itemcache);
|
||||
}
|
||||
|
||||
if (App::directory_usable($itemcache)) {
|
||||
if (App::isDirectoryUsable($itemcache)) {
|
||||
Config::set("system", "itemcache", $itemcache);
|
||||
return $itemcache;
|
||||
}
|
||||
|
@ -1161,7 +1067,7 @@ function get_itemcachepath()
|
|||
function get_spoolpath()
|
||||
{
|
||||
$spoolpath = Config::get('system', 'spoolpath');
|
||||
if (($spoolpath != "") && App::directory_usable($spoolpath)) {
|
||||
if (($spoolpath != "") && App::isDirectoryUsable($spoolpath)) {
|
||||
// We have a spool path and it is usable
|
||||
return $spoolpath;
|
||||
}
|
||||
|
@ -1176,7 +1082,7 @@ function get_spoolpath()
|
|||
mkdir($spoolpath);
|
||||
}
|
||||
|
||||
if (App::directory_usable($spoolpath)) {
|
||||
if (App::isDirectoryUsable($spoolpath)) {
|
||||
// The new path is usable, we are happy
|
||||
Config::set("system", "spoolpath", $spoolpath);
|
||||
return $spoolpath;
|
||||
|
@ -1231,46 +1137,6 @@ function validate_include(&$file)
|
|||
return $valid;
|
||||
}
|
||||
|
||||
function current_load()
|
||||
{
|
||||
if (!function_exists('sys_getloadavg')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$load_arr = sys_getloadavg();
|
||||
|
||||
if (!is_array($load_arr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return max($load_arr[0], $load_arr[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get c-style args
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function argc()
|
||||
{
|
||||
return get_app()->argc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the value of a argv key
|
||||
*
|
||||
* @param int $x argv key
|
||||
* @return string Value of the argv key
|
||||
*/
|
||||
function argv($x)
|
||||
{
|
||||
if (array_key_exists($x, get_app()->argv)) {
|
||||
return get_app()->argv[$x];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the data which is needed for infinite scroll
|
||||
*
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
"asika/simple-console": "^1.0",
|
||||
"divineomega/password_exposed": "^2.4",
|
||||
"ezyang/htmlpurifier": "~4.7.0",
|
||||
"friendica/json-ld": "^1.0",
|
||||
"league/html-to-markdown": "~4.8.0",
|
||||
"lightopenid/lightopenid": "dev-master",
|
||||
"michelf/php-markdown": "^1.7",
|
||||
|
@ -42,7 +43,7 @@
|
|||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/pear/Text_Highlighter"
|
||||
"url": "https://git.friendi.ca/friendica/php-json-ld"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
|
@ -74,7 +75,8 @@
|
|||
"phpunit/dbunit": "^2.0",
|
||||
"phpdocumentor/reflection-docblock": "^3.0.2",
|
||||
"phpunit/php-token-stream": "^1.4.2",
|
||||
"mikey179/vfsStream": "^1.6"
|
||||
"mikey179/vfsStream": "^1.6",
|
||||
"mockery/mockery": "^1.2"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "phpunit"
|
||||
|
|
764
composer.lock
generated
764
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -15,6 +15,34 @@
|
|||
"name": ["UNIQUE", "name"]
|
||||
}
|
||||
},
|
||||
"apcontact": {
|
||||
"comment": "ActivityPub compatible contacts - used in the ActivityPub implementation",
|
||||
"fields": {
|
||||
"url": {"type": "varbinary(255)", "not null": "1", "primary": "1", "comment": "URL of the contact"},
|
||||
"uuid": {"type": "varchar(255)", "comment": ""},
|
||||
"type": {"type": "varchar(20)", "not null": "1", "comment": ""},
|
||||
"following": {"type": "varchar(255)", "comment": ""},
|
||||
"followers": {"type": "varchar(255)", "comment": ""},
|
||||
"inbox": {"type": "varchar(255)", "not null": "1", "comment": ""},
|
||||
"outbox": {"type": "varchar(255)", "comment": ""},
|
||||
"sharedinbox": {"type": "varchar(255)", "comment": ""},
|
||||
"nick": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
|
||||
"name": {"type": "varchar(255)", "comment": ""},
|
||||
"about": {"type": "text", "comment": ""},
|
||||
"photo": {"type": "varchar(255)", "comment": ""},
|
||||
"addr": {"type": "varchar(255)", "comment": ""},
|
||||
"alias": {"type": "varchar(255)", "comment": ""},
|
||||
"pubkey": {"type": "text", "comment": ""},
|
||||
"baseurl": {"type": "varchar(255)", "comment": "baseurl of the ap contact"},
|
||||
"updated": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": ""}
|
||||
|
||||
},
|
||||
"indexes": {
|
||||
"PRIMARY": ["url"],
|
||||
"addr": ["addr(32)"],
|
||||
"url": ["followers(190)"]
|
||||
}
|
||||
},
|
||||
"attach": {
|
||||
"comment": "file attachments",
|
||||
"fields": {
|
||||
|
@ -164,6 +192,7 @@
|
|||
"hidden": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
|
||||
"archive": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
|
||||
"pending": {"type": "boolean", "not null": "1", "default": "1", "comment": ""},
|
||||
"deleted": {"type": "boolean", "not null": "1", "default": "0", "comment": "Contact has been deleted"},
|
||||
"rating": {"type": "tinyint", "not null": "1", "default": "0", "comment": ""},
|
||||
"reason": {"type": "text", "comment": ""},
|
||||
"closeness": {"type": "tinyint unsigned", "not null": "1", "default": "99", "comment": ""},
|
||||
|
@ -215,7 +244,7 @@
|
|||
"reply-to-uri": {"type": "varbinary(255)", "not null": "1", "default": "", "comment": "URI to which this item is a reply"},
|
||||
"conversation-uri": {"type": "varbinary(255)", "not null": "1", "default": "", "comment": "GNU Social conversation URI"},
|
||||
"conversation-href": {"type": "varbinary(255)", "not null": "1", "default": "", "comment": "GNU Social conversation link"},
|
||||
"protocol": {"type": "tinyint unsigned", "not null": "1", "default": "0", "comment": "The protocol of the item"},
|
||||
"protocol": {"type": "tinyint unsigned", "not null": "1", "default": "255", "comment": "The protocol of the item"},
|
||||
"source": {"type": "mediumtext", "comment": "Original source"},
|
||||
"received": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "Receiving date"}
|
||||
},
|
||||
|
|
31
database.sql
31
database.sql
|
@ -1,6 +1,6 @@
|
|||
-- ------------------------------------------
|
||||
-- Friendica 2018.12-dev (The Tazmans Flax-lily)
|
||||
-- DB_UPDATE_VERSION 1283
|
||||
-- DB_UPDATE_VERSION 1285
|
||||
-- ------------------------------------------
|
||||
|
||||
|
||||
|
@ -19,6 +19,32 @@ CREATE TABLE IF NOT EXISTS `addon` (
|
|||
UNIQUE INDEX `name` (`name`)
|
||||
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registered addons';
|
||||
|
||||
--
|
||||
-- TABLE apcontact
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS `apcontact` (
|
||||
`url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
|
||||
`uuid` varchar(255) COMMENT '',
|
||||
`type` varchar(20) NOT NULL COMMENT '',
|
||||
`following` varchar(255) COMMENT '',
|
||||
`followers` varchar(255) COMMENT '',
|
||||
`inbox` varchar(255) NOT NULL COMMENT '',
|
||||
`outbox` varchar(255) COMMENT '',
|
||||
`sharedinbox` varchar(255) COMMENT '',
|
||||
`nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||
`name` varchar(255) COMMENT '',
|
||||
`about` text COMMENT '',
|
||||
`photo` varchar(255) COMMENT '',
|
||||
`addr` varchar(255) COMMENT '',
|
||||
`alias` varchar(255) COMMENT '',
|
||||
`pubkey` text COMMENT '',
|
||||
`baseurl` varchar(255) COMMENT 'baseurl of the ap contact',
|
||||
`updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
|
||||
PRIMARY KEY(`url`),
|
||||
INDEX `addr` (`addr`(32)),
|
||||
INDEX `url` (`followers`(190))
|
||||
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
|
||||
|
||||
--
|
||||
-- TABLE attach
|
||||
--
|
||||
|
@ -163,6 +189,7 @@ CREATE TABLE IF NOT EXISTS `contact` (
|
|||
`hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
|
||||
`archive` boolean NOT NULL DEFAULT '0' COMMENT '',
|
||||
`pending` boolean NOT NULL DEFAULT '1' COMMENT '',
|
||||
`deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
|
||||
`rating` tinyint NOT NULL DEFAULT 0 COMMENT '',
|
||||
`reason` text COMMENT '',
|
||||
`closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT '',
|
||||
|
@ -212,7 +239,7 @@ CREATE TABLE IF NOT EXISTS `conversation` (
|
|||
`reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
|
||||
`conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
|
||||
`conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
|
||||
`protocol` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The protocol of the item',
|
||||
`protocol` tinyint unsigned NOT NULL DEFAULT 255 COMMENT 'The protocol of the item',
|
||||
`source` mediumtext COMMENT 'Original source',
|
||||
`received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date',
|
||||
PRIMARY KEY(`item-uri`),
|
||||
|
|
101
doc/Addons.md
101
doc/Addons.md
|
@ -67,55 +67,67 @@ $b can be called anything you like.
|
|||
This is information specific to the hook currently being processed, and generally contains information that is being immediately processed or acted on that you can use, display, or alter.
|
||||
Remember to declare it with `&` if you wish to alter it.
|
||||
|
||||
## JavaScript addon hooks
|
||||
## Global stylesheets
|
||||
|
||||
### PHP part
|
||||
|
||||
Make sure your JavaScript addon file (addon/*addon_name*/*addon_name*.js) is listed in the document response.
|
||||
|
||||
In your addon install function, add:
|
||||
If your addon requires adding a stylesheet on all pages of Friendica, add the following hook:
|
||||
|
||||
```php
|
||||
Addon::registerHook('template_vars', __FILE__, '<addon_name>_template_vars');
|
||||
```
|
||||
|
||||
In your addon uninstall function, add:
|
||||
|
||||
```php
|
||||
Addon::unregisterHook('template_vars', __FILE__, '<addon_name>_template_vars');
|
||||
```
|
||||
|
||||
Then, add your addon name to the *addon_hooks* template variable array:
|
||||
|
||||
```php
|
||||
function <addon_name>_template_vars($a, &$arr)
|
||||
function <addon>_install()
|
||||
{
|
||||
if (!array_key_exists('addon_hooks', $arr['vars']))
|
||||
{
|
||||
$arr['vars']['addon_hooks'] = array();
|
||||
}
|
||||
$arr['vars']['addon_hooks'][] = "<addon_name>";
|
||||
Addon::registerHook('head', __FILE__, '<addon>_head');
|
||||
...
|
||||
}
|
||||
|
||||
|
||||
function <addon>_head(App $a)
|
||||
{
|
||||
$a->registerStylesheet(__DIR__ . '/relative/path/to/addon/stylesheet.css');
|
||||
}
|
||||
```
|
||||
|
||||
### JavaScript part
|
||||
`__DIR__` is the folder path of your addon.
|
||||
|
||||
Register your addon hooks in file `addon/*addon_name*/*addon_name*.js`.
|
||||
## JavaScript
|
||||
|
||||
### Global scripts
|
||||
|
||||
If your addon requires adding a script on all pages of Friendica, add the following hook:
|
||||
|
||||
|
||||
```php
|
||||
function <addon>_install()
|
||||
{
|
||||
Addon::registerHook('footer', __FILE__, '<addon>_footer');
|
||||
...
|
||||
}
|
||||
|
||||
function <addon>_footer(App $a)
|
||||
{
|
||||
$a->registerFooterScript(__DIR__ . '/relative/path/to/addon/script.js');
|
||||
}
|
||||
```
|
||||
|
||||
`__DIR__` is the folder path of your addon.
|
||||
|
||||
### JavaScript hooks
|
||||
|
||||
The main Friendica script provides hooks via events dispatched on the `document` property.
|
||||
In your Javascript file included as described above, add your event listener like this:
|
||||
|
||||
```js
|
||||
Addon_registerHook(type, hookfnstr);
|
||||
document.addEventListener(name, callback);
|
||||
```
|
||||
|
||||
*type* is the name of the hook and corresponds to a known Friendica JavaScript hook.
|
||||
*hookfnstr* is the name of your JavaScript function to execute.
|
||||
- *name* is the name of the hook and corresponds to a known Friendica JavaScript hook.
|
||||
- *callback* is a JavaScript anonymous function to execute.
|
||||
|
||||
No arguments are provided to your JavaScript callback function. Example:
|
||||
More info about Javascript event listeners: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
|
||||
|
||||
```javascript
|
||||
function myhook_function() {
|
||||
#### Current JavaScript hooks
|
||||
|
||||
}
|
||||
```
|
||||
##### postprocess_liveupdate
|
||||
Called at the end of the live update process (XmlHttpRequest) and on a post preview.
|
||||
No additional data is provided.
|
||||
|
||||
## Modules
|
||||
|
||||
|
@ -260,6 +272,11 @@ Called after conversion of bbcode to HTML.
|
|||
Called after tag conversion of HTML to bbcode (e.g. remote message posting)
|
||||
`$b` is a string converted text
|
||||
|
||||
### head
|
||||
Called when building the `<head>` sections.
|
||||
Stylesheets should be registered using this hook.
|
||||
`$b` is an HTML string of the `<head>` tag.
|
||||
|
||||
### page_header
|
||||
Called after building the page navigation section.
|
||||
`$b` is a string HTML of nav region.
|
||||
|
@ -294,6 +311,11 @@ No hook data.
|
|||
Called after HTML content functions have completed.
|
||||
`$b` is (string) HTML of content div.
|
||||
|
||||
### footer
|
||||
Called after HTML content functions have completed.
|
||||
Deferred Javascript files should be registered using this hook.
|
||||
`$b` is (string) HTML of footer div/element.
|
||||
|
||||
### avatar_lookup
|
||||
Called when looking up the avatar. `$b` is an array:
|
||||
|
||||
|
@ -389,14 +411,9 @@ Hook data:
|
|||
visitor => array with the contact record of the visitor
|
||||
url => the query string
|
||||
|
||||
## Current JavaScript hooks
|
||||
|
||||
### postprocess_liveupdate
|
||||
Called at the end of the live update process (XmlHttpRequest)
|
||||
|
||||
## Complete list of hook callbacks
|
||||
|
||||
Here is a complete list of all hook callbacks with file locations (as of 01-Apr-2018). Please see the source for details of any hooks not documented above.
|
||||
Here is a complete list of all hook callbacks with file locations (as of 24-Sep-2018). Please see the source for details of any hooks not documented above.
|
||||
|
||||
### index.php
|
||||
|
||||
|
@ -571,6 +588,8 @@ Here is a complete list of all hook callbacks with file locations (as of 01-Apr-
|
|||
### src/App.php
|
||||
|
||||
Addon::callHooks('load_config');
|
||||
Addon::callHooks('head');
|
||||
Addon::callHooks('footer');
|
||||
|
||||
### src/Model/Item.php
|
||||
|
||||
|
@ -704,4 +723,4 @@ Here is a complete list of all hook callbacks with file locations (as of 01-Apr-
|
|||
|
||||
### view/js/main.js
|
||||
|
||||
callAddonHooks("postprocess_liveupdate");
|
||||
document.dispatchEvent(new Event('postprocess_liveupdate'));
|
||||
|
|
|
@ -164,6 +164,7 @@ if you don't use the option `--savedb` during installation, the DB credentials w
|
|||
This variables wont be used at normal Friendica runtime.
|
||||
Instead, they get saved into `config/local.ini.php`.
|
||||
|
||||
- `FRIENDICA_URL_PATH` The URL path of Friendica (f.e. '/friendica')
|
||||
- `FRIENDICA_PHP_PATH` The path of the PHP binary
|
||||
- `FRIENDICA_ADMIN_MAIL` The admin email address of Friendica (this email will be used for admin access)
|
||||
- `FRIENDICA_TZ` The timezone of Friendica
|
||||
|
@ -182,7 +183,8 @@ All options will be saved in the `config/local.ini.php` and are overruling the a
|
|||
- `-U|--dbuser <username>` The username of the mysql/mariadb database login (env `MYSQL_USER` or `MYSQL_USERNAME`)
|
||||
- `-P|--dbpass <password>` The password of the mysql/mariadb database login (env `MYSQL_PASSWORD`)
|
||||
- `-d|--dbdata <database>` The name of the mysql/mariadb database (env `MYSQL_DATABASE`)
|
||||
- `-b|--phppath <path>` The path of the PHP binary (env `FRIENDICA_PHP_PATH`)
|
||||
- `-u|--urlpath <url_path>` The URL path of Friendica - f.e. '/friendica' (env `FRIENDICA_URL_PATH`)
|
||||
- `-b|--phppath <php_path>` The path of the PHP binary (env `FRIENDICA_PHP_PATH`)
|
||||
- `-A|--admin <mail>` The admin email address of Friendica (env `FRIENDICA_ADMIN_MAIL`)
|
||||
- `-T|--tz <timezone>` The timezone of Friendica (env `FRIENDICA_TZ`)
|
||||
- `-L|--land <language>` The language of Friendica (env `FRIENDICA_LANG`)
|
||||
|
|
159
include/api.php
159
include/api.php
|
@ -819,7 +819,7 @@ function api_item_get_user(App $a, $item)
|
|||
$status_user["protected"] = defaults($item, 'private', 0);
|
||||
|
||||
if (defaults($item, 'thr-parent', '') == defaults($item, 'uri', '')) {
|
||||
$owner_user = api_get_user($a, defaults($item, 'author-id', null));
|
||||
$owner_user = api_get_user($a, defaults($item, 'owner-id', null));
|
||||
} else {
|
||||
$owner_user = $status_user;
|
||||
}
|
||||
|
@ -2351,7 +2351,7 @@ function api_format_messages($item, $recipient, $sender)
|
|||
// standard meta information
|
||||
$ret = [
|
||||
'id' => $item['id'],
|
||||
'sender_id' => $sender['id'] ,
|
||||
'sender_id' => $sender['id'],
|
||||
'text' => "",
|
||||
'recipient_id' => $recipient['id'],
|
||||
'created_at' => api_date(defaults($item, 'created', DateTimeFormat::utcNow())),
|
||||
|
@ -2732,7 +2732,7 @@ function api_contactlink_to_array($txt)
|
|||
* likes => int count,
|
||||
* dislikes => int count
|
||||
*/
|
||||
function api_format_items_activities(&$item, $type = "json")
|
||||
function api_format_items_activities($item, $type = "json")
|
||||
{
|
||||
$a = get_app();
|
||||
|
||||
|
@ -2747,13 +2747,13 @@ function api_format_items_activities(&$item, $type = "json")
|
|||
$condition = ['uid' => $item['uid'], 'thr-parent' => $item['uri']];
|
||||
$ret = Item::selectForUser($item['uid'], ['author-id', 'verb'], $condition);
|
||||
|
||||
while ($item = Item::fetch($ret)) {
|
||||
while ($parent_item = Item::fetch($ret)) {
|
||||
// not used as result should be structured like other user data
|
||||
//builtin_activity_puller($i, $activities);
|
||||
|
||||
// get user data and add it to the array of the activity
|
||||
$user = api_get_user($a, $item['author-id']);
|
||||
switch ($item['verb']) {
|
||||
$user = api_get_user($a, $parent_item['author-id']);
|
||||
switch ($parent_item['verb']) {
|
||||
case ACTIVITY_LIKE:
|
||||
$activities['like'][] = $user;
|
||||
break;
|
||||
|
@ -2893,7 +2893,7 @@ function api_format_items($r, $user_info, $filter_user = false, $type = "json")
|
|||
'in_reply_to_screen_name' => $in_reply_to['screen_name'],
|
||||
$geo => null,
|
||||
'favorited' => $item['starred'] ? true : false,
|
||||
'user' => $status_user ,
|
||||
'user' => $status_user,
|
||||
'friendica_owner' => $owner_user,
|
||||
'friendica_private' => $item['private'] == 1,
|
||||
//'entities' => NULL,
|
||||
|
@ -3344,7 +3344,7 @@ function api_statusnet_config($type)
|
|||
$a = get_app();
|
||||
|
||||
$name = Config::get('config', 'sitename');
|
||||
$server = $a->get_hostname();
|
||||
$server = $a->getHostName();
|
||||
$logo = System::baseUrl() . '/images/friendica-64.png';
|
||||
$email = Config::get('config', 'admin_email');
|
||||
$closed = intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? 'true' : 'false';
|
||||
|
@ -3401,7 +3401,7 @@ api_register_func('api/statusnet/version', 'api_statusnet_version', false);
|
|||
*/
|
||||
function api_ff_ids($type)
|
||||
{
|
||||
if (! api_user()) {
|
||||
if (!api_user()) {
|
||||
throw new ForbiddenException();
|
||||
}
|
||||
|
||||
|
@ -3629,6 +3629,84 @@ function api_direct_messages_destroy($type)
|
|||
/// @TODO move to top of file or somewhere better
|
||||
api_register_func('api/direct_messages/destroy', 'api_direct_messages_destroy', true, API_METHOD_DELETE);
|
||||
|
||||
/**
|
||||
* Unfollow Contact
|
||||
*
|
||||
* @brief unfollow contact
|
||||
*
|
||||
* @param string $type Known types are 'atom', 'rss', 'xml' and 'json'
|
||||
* @return string|array
|
||||
* @see https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/post-friendships-destroy.html
|
||||
*/
|
||||
function api_friendships_destroy($type)
|
||||
{
|
||||
$uid = api_user();
|
||||
|
||||
if ($uid === false) {
|
||||
throw new ForbiddenException();
|
||||
}
|
||||
|
||||
$contact_id = defaults($_REQUEST, 'user_id');
|
||||
|
||||
if (empty($contact_id)) {
|
||||
logger("No user_id specified", LOGGER_DEBUG);
|
||||
throw new BadRequestException("no user_id specified");
|
||||
}
|
||||
|
||||
// Get Contact by given id
|
||||
$contact = DBA::selectFirst('contact', ['url'], ['id' => $contact_id, 'uid' => 0, 'self' => false]);
|
||||
|
||||
if(!DBA::isResult($contact)) {
|
||||
logger("No contact found for ID" . $contact_id, LOGGER_DEBUG);
|
||||
throw new NotFoundException("no contact found to given ID");
|
||||
}
|
||||
|
||||
$url = $contact["url"];
|
||||
|
||||
$condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?)",
|
||||
$uid, Contact::SHARING, Contact::FRIEND, normalise_link($url),
|
||||
normalise_link($url), $url];
|
||||
$contact = DBA::selectFirst('contact', [], $condition);
|
||||
|
||||
if (!DBA::isResult($contact)) {
|
||||
logger("Not following Contact", LOGGER_DEBUG);
|
||||
throw new NotFoundException("Not following Contact");
|
||||
}
|
||||
|
||||
if (!in_array($contact['network'], Protocol::NATIVE_SUPPORT)) {
|
||||
logger("Not supported", LOGGER_DEBUG);
|
||||
throw new ExpectationFailedException("Not supported");
|
||||
}
|
||||
|
||||
$dissolve = ($contact['rel'] == Contact::SHARING);
|
||||
|
||||
$owner = User::getOwnerDataById($uid);
|
||||
if ($owner) {
|
||||
Contact::terminateFriendship($owner, $contact, $dissolve);
|
||||
}
|
||||
else {
|
||||
logger("No owner found", LOGGER_DEBUG);
|
||||
throw new NotFoundException("Error Processing Request");
|
||||
}
|
||||
|
||||
// Sharing-only contacts get deleted as there no relationship any more
|
||||
if ($dissolve) {
|
||||
Contact::remove($contact['id']);
|
||||
} else {
|
||||
DBA::update('contact', ['rel' => Contact::FOLLOWER], ['id' => $contact['id']]);
|
||||
}
|
||||
|
||||
// "uid" and "self" are only needed for some internal stuff, so remove it from here
|
||||
unset($contact["uid"]);
|
||||
unset($contact["self"]);
|
||||
|
||||
// Set screen_name since Twidere requests it
|
||||
$contact["screen_name"] = $contact["nick"];
|
||||
|
||||
return api_format_data("friendships-destroy", $type, ['user' => $contact]);
|
||||
}
|
||||
api_register_func('api/friendships/destroy', 'api_friendships_destroy', true, API_METHOD_POST);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $type Return type (atom, rss, xml, json)
|
||||
|
@ -4427,7 +4505,7 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $
|
|||
// create Photo instance with the data of the image
|
||||
$imagedata = @file_get_contents($src);
|
||||
$Image = new Image($imagedata, $filetype);
|
||||
if (! $Image->isValid()) {
|
||||
if (!$Image->isValid()) {
|
||||
throw new InternalServerErrorException("unable to process image data");
|
||||
}
|
||||
|
||||
|
@ -4437,7 +4515,7 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $
|
|||
|
||||
// check max length of images on server
|
||||
$max_length = Config::get('system', 'max_image_length');
|
||||
if (! $max_length) {
|
||||
if (!$max_length) {
|
||||
$max_length = MAX_IMAGE_LENGTH;
|
||||
}
|
||||
if ($max_length > 0) {
|
||||
|
@ -4455,13 +4533,13 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $
|
|||
logger("photo upload: starting new photo upload", LOGGER_DEBUG);
|
||||
|
||||
$r = Photo::store($Image, local_user(), $visitor, $hash, $filename, $album, 0, 0, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
|
||||
if (! $r) {
|
||||
if (!$r) {
|
||||
logger("photo upload: image upload with scale 0 (original size) failed");
|
||||
}
|
||||
if ($width > 640 || $height > 640) {
|
||||
$Image->scaleDown(640);
|
||||
$r = Photo::store($Image, local_user(), $visitor, $hash, $filename, $album, 1, 0, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
|
||||
if (! $r) {
|
||||
if (!$r) {
|
||||
logger("photo upload: image upload with scale 1 (640x640) failed");
|
||||
}
|
||||
}
|
||||
|
@ -4469,7 +4547,7 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $
|
|||
if ($width > 320 || $height > 320) {
|
||||
$Image->scaleDown(320);
|
||||
$r = Photo::store($Image, local_user(), $visitor, $hash, $filename, $album, 2, 0, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
|
||||
if (! $r) {
|
||||
if (!$r) {
|
||||
logger("photo upload: image upload with scale 2 (320x320) failed");
|
||||
}
|
||||
}
|
||||
|
@ -4481,7 +4559,7 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $
|
|||
if ($width > 175 || $height > 175) {
|
||||
$Image->scaleDown(175);
|
||||
$r = Photo::store($Image, local_user(), $visitor, $hash, $filename, $album, 4, $profile, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
|
||||
if (! $r) {
|
||||
if (!$r) {
|
||||
logger("photo upload: profile image upload with scale 4 (175x175) failed");
|
||||
}
|
||||
}
|
||||
|
@ -4489,7 +4567,7 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $
|
|||
if ($width > 80 || $height > 80) {
|
||||
$Image->scaleDown(80);
|
||||
$r = Photo::store($Image, local_user(), $visitor, $hash, $filename, $album, 5, $profile, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
|
||||
if (! $r) {
|
||||
if (!$r) {
|
||||
logger("photo upload: profile image upload with scale 5 (80x80) failed");
|
||||
}
|
||||
}
|
||||
|
@ -4497,7 +4575,7 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $
|
|||
if ($width > 48 || $height > 48) {
|
||||
$Image->scaleDown(48);
|
||||
$r = Photo::store($Image, local_user(), $visitor, $hash, $filename, $album, 6, $profile, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
|
||||
if (! $r) {
|
||||
if (!$r) {
|
||||
logger("photo upload: profile image upload with scale 6 (48x48) failed");
|
||||
}
|
||||
}
|
||||
|
@ -4534,7 +4612,7 @@ function post_photo_item($hash, $allow_cid, $deny_cid, $allow_gid, $deny_gid, $f
|
|||
$owner_record = DBA::selectFirst('contact', [], ['uid' => api_user(), 'self' => true]);
|
||||
|
||||
$arr = [];
|
||||
$arr['guid'] = System::createGUID(32);
|
||||
$arr['guid'] = System::createUUID();
|
||||
$arr['uid'] = intval(api_user());
|
||||
$arr['uri'] = $uri;
|
||||
$arr['parent-uri'] = $uri;
|
||||
|
@ -4749,77 +4827,86 @@ function api_share_as_retweet(&$item)
|
|||
{
|
||||
$body = trim($item["body"]);
|
||||
|
||||
if (Diaspora::isReshare($body, false)===false) {
|
||||
return false;
|
||||
if (Diaspora::isReshare($body, false) === false) {
|
||||
if ($item['author-id'] == $item['owner-id']) {
|
||||
return false;
|
||||
} else {
|
||||
// Reshares from OStatus, ActivityPub and Twitter
|
||||
$reshared_item = $item;
|
||||
$reshared_item['owner-id'] = $reshared_item['author-id'];
|
||||
$reshared_item['owner-link'] = $reshared_item['author-link'];
|
||||
$reshared_item['owner-name'] = $reshared_item['author-name'];
|
||||
$reshared_item['owner-avatar'] = $reshared_item['author-avatar'];
|
||||
return $reshared_item;
|
||||
}
|
||||
}
|
||||
|
||||
/// @TODO "$1" should maybe mean '$1' ?
|
||||
$attributes = preg_replace("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism", "$1", $body);
|
||||
/*
|
||||
* Skip if there is no shared message in there
|
||||
* we already checked this in diaspora::isReshare()
|
||||
* but better one more than one less...
|
||||
*/
|
||||
if ($body == $attributes) {
|
||||
* Skip if there is no shared message in there
|
||||
* we already checked this in diaspora::isReshare()
|
||||
* but better one more than one less...
|
||||
*/
|
||||
if (($body == $attributes) || empty($attributes)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// build the fake reshared item
|
||||
$reshared_item = $item;
|
||||
|
||||
$author = "";
|
||||
preg_match("/author='(.*?)'/ism", $attributes, $matches);
|
||||
if ($matches[1] != "") {
|
||||
if (!empty($matches[1])) {
|
||||
$author = html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
preg_match('/author="(.*?)"/ism', $attributes, $matches);
|
||||
if ($matches[1] != "") {
|
||||
if (!empty($matches[1])) {
|
||||
$author = $matches[1];
|
||||
}
|
||||
|
||||
$profile = "";
|
||||
preg_match("/profile='(.*?)'/ism", $attributes, $matches);
|
||||
if ($matches[1] != "") {
|
||||
if (!empty($matches[1])) {
|
||||
$profile = $matches[1];
|
||||
}
|
||||
|
||||
preg_match('/profile="(.*?)"/ism', $attributes, $matches);
|
||||
if ($matches[1] != "") {
|
||||
if (!empty($matches[1])) {
|
||||
$profile = $matches[1];
|
||||
}
|
||||
|
||||
$avatar = "";
|
||||
preg_match("/avatar='(.*?)'/ism", $attributes, $matches);
|
||||
if ($matches[1] != "") {
|
||||
if (!empty($matches[1])) {
|
||||
$avatar = $matches[1];
|
||||
}
|
||||
|
||||
preg_match('/avatar="(.*?)"/ism', $attributes, $matches);
|
||||
if ($matches[1] != "") {
|
||||
if (!empty($matches[1])) {
|
||||
$avatar = $matches[1];
|
||||
}
|
||||
|
||||
$link = "";
|
||||
preg_match("/link='(.*?)'/ism", $attributes, $matches);
|
||||
if ($matches[1] != "") {
|
||||
if (!empty($matches[1])) {
|
||||
$link = $matches[1];
|
||||
}
|
||||
|
||||
preg_match('/link="(.*?)"/ism', $attributes, $matches);
|
||||
if ($matches[1] != "") {
|
||||
if (!empty($matches[1])) {
|
||||
$link = $matches[1];
|
||||
}
|
||||
|
||||
$posted = "";
|
||||
preg_match("/posted='(.*?)'/ism", $attributes, $matches);
|
||||
if ($matches[1] != "") {
|
||||
if (!empty($matches[1])) {
|
||||
$posted = $matches[1];
|
||||
}
|
||||
|
||||
preg_match('/posted="(.*?)"/ism', $attributes, $matches);
|
||||
if ($matches[1] != "") {
|
||||
if (!empty($matches[1])) {
|
||||
$posted = $matches[1];
|
||||
}
|
||||
|
||||
|
|
|
@ -556,7 +556,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
|
|||
if (in_array($mode, ['community', 'contacts'])) {
|
||||
$writable = true;
|
||||
} else {
|
||||
$writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], [Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN]);
|
||||
$writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], [Protocol::ACTIVITYPUB, Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN]);
|
||||
}
|
||||
|
||||
if (!local_user()) {
|
||||
|
@ -657,7 +657,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
|
|||
'id' => ($preview ? 'P0' : $item['id']),
|
||||
'guid' => ($preview ? 'Q0' : $item['guid']),
|
||||
'network' => $item['network'],
|
||||
'network_name' => ContactSelector::networkToName($item['network'], $profile_link),
|
||||
'network_name' => ContactSelector::networkToName($item['network'], $item['author-link']),
|
||||
'linktitle' => L10n::t('View %s\'s profile @ %s', $profile_name, $item['author-link']),
|
||||
'profile_url' => $profile_link,
|
||||
'item_photo_menu' => item_photo_menu($item),
|
||||
|
@ -807,7 +807,7 @@ function conversation_add_children(array $parents, $block_authors, $order, $uid)
|
|||
|
||||
foreach ($items as $index => $item) {
|
||||
if ($item['uid'] == 0) {
|
||||
$items[$index]['writable'] = in_array($item['network'], [Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN]);
|
||||
$items[$index]['writable'] = in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -877,7 +877,7 @@ function item_photo_menu($item) {
|
|||
}
|
||||
|
||||
if ((($cid == 0) || ($rel == Contact::FOLLOWER)) &&
|
||||
in_array($item['network'], [Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA])) {
|
||||
in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA])) {
|
||||
$menu[L10n::t('Connect/Follow')] = 'follow?url=' . urlencode($item['author-link']);
|
||||
}
|
||||
} else {
|
||||
|
@ -1091,21 +1091,6 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
|
|||
'$delitems' => L10n::t("Delete item\x28s\x29?")
|
||||
]);
|
||||
|
||||
$tpl = get_markup_template('jot-end.tpl');
|
||||
$a->page['end'] .= replace_macros($tpl, [
|
||||
'$newpost' => 'true',
|
||||
'$baseurl' => System::baseUrl(true),
|
||||
'$geotag' => $geotag,
|
||||
'$nickname' => $x['nickname'],
|
||||
'$ispublic' => L10n::t('Visible to <strong>everybody</strong>'),
|
||||
'$linkurl' => L10n::t('Please enter a link URL:'),
|
||||
'$vidurl' => L10n::t("Please enter a video link/URL:"),
|
||||
'$audurl' => L10n::t("Please enter an audio link/URL:"),
|
||||
'$term' => L10n::t('Tag term:'),
|
||||
'$fileas' => L10n::t('Save to Folder:'),
|
||||
'$whereareu' => L10n::t('Where are you right now?')
|
||||
]);
|
||||
|
||||
$jotplugins = '';
|
||||
Addon::callHooks('jot_tool', $jotplugins);
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ function notification($params)
|
|||
}
|
||||
|
||||
$sender_name = $sitename;
|
||||
$hostname = $a->get_hostname();
|
||||
$hostname = $a->getHostName();
|
||||
if (strpos($hostname, ':')) {
|
||||
$hostname = substr($hostname, 0, strpos($hostname, ':'));
|
||||
}
|
||||
|
|
|
@ -316,9 +316,9 @@ function subscribe_to_hub($url, array $importer, array $contact, $hubmode = 'sub
|
|||
DBA::update('contact', ['hub-verify' => $verify_token], ['id' => $contact['id']]);
|
||||
}
|
||||
|
||||
Network::post($url, $params);
|
||||
$postResult = Network::post($url, $params);
|
||||
|
||||
logger('subscribe_to_hub: returns: ' . $a->get_curl_code(), LOGGER_DEBUG);
|
||||
logger('subscribe_to_hub: returns: ' . $postResult->getReturnCode(), LOGGER_DEBUG);
|
||||
|
||||
return;
|
||||
|
||||
|
@ -349,12 +349,12 @@ function drop_item($id)
|
|||
|
||||
// locate item to be deleted
|
||||
|
||||
$fields = ['id', 'uid', 'contact-id', 'deleted'];
|
||||
$fields = ['id', 'uid', 'guid', 'contact-id', 'deleted'];
|
||||
$item = Item::selectFirstForUser(local_user(), $fields, ['id' => $id]);
|
||||
|
||||
if (!DBA::isResult($item)) {
|
||||
notice(L10n::t('Item not found.') . EOL);
|
||||
goaway(System::baseUrl() . '/' . $_SESSION['return_url']);
|
||||
goaway('/network');
|
||||
}
|
||||
|
||||
if ($item['deleted']) {
|
||||
|
@ -401,17 +401,17 @@ function drop_item($id)
|
|||
}
|
||||
// Now check how the user responded to the confirmation query
|
||||
if (!empty($_REQUEST['canceled'])) {
|
||||
goaway(System::baseUrl() . '/' . $_SESSION['return_url']);
|
||||
goaway('/display/' . $item['guid']);
|
||||
}
|
||||
|
||||
// delete the item
|
||||
Item::deleteForUser(['id' => $item['id']], local_user());
|
||||
|
||||
goaway(System::baseUrl() . '/' . $_SESSION['return_url']);
|
||||
goaway('/network');
|
||||
//NOTREACHED
|
||||
} else {
|
||||
notice(L10n::t('Permission denied.') . EOL);
|
||||
goaway(System::baseUrl() . '/' . $_SESSION['return_url']);
|
||||
goaway('/display/' . $item['guid']);
|
||||
//NOTREACHED
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ function replace_macros($s, $r) {
|
|||
// pass $baseurl to all templates
|
||||
$r['$baseurl'] = System::baseUrl();
|
||||
|
||||
$t = $a->template_engine();
|
||||
$t = $a->getTemplateEngine();
|
||||
try {
|
||||
$output = $t->replaceMacros($s, $r);
|
||||
} catch (Exception $e) {
|
||||
|
@ -50,7 +50,7 @@ function replace_macros($s, $r) {
|
|||
killme();
|
||||
}
|
||||
|
||||
$a->save_timestamp($stamp1, "rendering");
|
||||
$a->saveTimestamp($stamp1, "rendering");
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
@ -473,7 +473,7 @@ function get_markup_template($s, $root = '') {
|
|||
$stamp1 = microtime(true);
|
||||
|
||||
$a = get_app();
|
||||
$t = $a->template_engine();
|
||||
$t = $a->getTemplateEngine();
|
||||
try {
|
||||
$template = $t->getTemplateFile($s, $root);
|
||||
} catch (Exception $e) {
|
||||
|
@ -481,7 +481,7 @@ function get_markup_template($s, $root = '') {
|
|||
killme();
|
||||
}
|
||||
|
||||
$a->save_timestamp($stamp1, "file");
|
||||
$a->saveTimestamp($stamp1, "file");
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
@ -574,7 +574,7 @@ function logger($msg, $level = LOGGER_INFO) {
|
|||
|
||||
$stamp1 = microtime(true);
|
||||
@file_put_contents($logfile, $logline, FILE_APPEND);
|
||||
$a->save_timestamp($stamp1, "file");
|
||||
$a->saveTimestamp($stamp1, "file");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -634,7 +634,7 @@ function dlogger($msg, $level = LOGGER_INFO) {
|
|||
|
||||
$stamp1 = microtime(true);
|
||||
@file_put_contents($logfile, $logline, FILE_APPEND);
|
||||
$a->save_timestamp($stamp1, "file");
|
||||
$a->saveTimestamp($stamp1, "file");
|
||||
}
|
||||
|
||||
|
||||
|
@ -1191,9 +1191,6 @@ function prepare_body(array &$item, $attach = false, $is_preview = false)
|
|||
$a->page['htmlhead'] .= replace_macros(get_markup_template('videos_head.tpl'), [
|
||||
'$baseurl' => System::baseUrl(),
|
||||
]);
|
||||
$a->page['end'] .= replace_macros(get_markup_template('videos_end.tpl'), [
|
||||
'$baseurl' => System::baseUrl(),
|
||||
]);
|
||||
}
|
||||
|
||||
$url_parts = explode('/', $the_url);
|
||||
|
@ -1417,7 +1414,7 @@ function get_plink($item) {
|
|||
];
|
||||
|
||||
if (x($item, 'plink')) {
|
||||
$ret["href"] = $a->remove_baseurl($item['plink']);
|
||||
$ret["href"] = $a->removeBaseURL($item['plink']);
|
||||
$ret["title"] = L10n::t('link to source');
|
||||
}
|
||||
|
||||
|
|
114
index.php
114
index.php
|
@ -23,11 +23,9 @@ use Friendica\Module\Login;
|
|||
|
||||
require_once 'boot.php';
|
||||
|
||||
$a = new App(__DIR__);
|
||||
|
||||
// We assume that the index.php is called by a frontend process
|
||||
// The value is set to "true" by default in boot.php
|
||||
$a->backend = false;
|
||||
$a = new App(__DIR__, false);
|
||||
|
||||
/**
|
||||
* Try to open the database;
|
||||
|
@ -36,7 +34,7 @@ $a->backend = false;
|
|||
require_once "include/dba.php";
|
||||
|
||||
// Missing DB connection: ERROR
|
||||
if ($a->mode & App::MODE_LOCALCONFIGPRESENT && !($a->mode & App::MODE_DBAVAILABLE)) {
|
||||
if ($a->getMode()->has(App\Mode::LOCALCONFIGPRESENT) && !$a->getMode()->has(App\Mode::DBAVAILABLE)) {
|
||||
System::httpExit(500, ['title' => 'Error 500 - Internal Server Error', 'description' => 'Apologies but the website is unavailable at the moment.']);
|
||||
}
|
||||
|
||||
|
@ -48,8 +46,12 @@ if ($a->isMaxProcessesReached() || $a->isMaxLoadReached()) {
|
|||
System::httpExit(503, ['title' => 'Error 503 - Service Temporarily Unavailable', 'description' => 'System is currently overloaded. Please try again later.']);
|
||||
}
|
||||
|
||||
if (!$a->isInstallMode()) {
|
||||
if (Config::get('system', 'force_ssl') && ($a->get_scheme() == "http")
|
||||
if (strstr($a->query_string, '.well-known/host-meta') && ($a->query_string != '.well-known/host-meta')) {
|
||||
System::httpExit(404);
|
||||
}
|
||||
|
||||
if (!$a->getMode()->isInstall()) {
|
||||
if (Config::get('system', 'force_ssl') && ($a->getScheme() == "http")
|
||||
&& (intval(Config::get('system', 'ssl_policy')) == SSL_POLICY_FULL)
|
||||
&& (substr(System::baseUrl(), 0, 8) == "https://")
|
||||
&& ($_SERVER['REQUEST_METHOD'] == 'GET')) {
|
||||
|
@ -78,10 +80,10 @@ L10n::loadTranslationTable($lang);
|
|||
*/
|
||||
|
||||
// Exclude the backend processes from the session management
|
||||
if (!$a->is_backend()) {
|
||||
if (!$a->isBackend()) {
|
||||
$stamp1 = microtime(true);
|
||||
session_start();
|
||||
$a->save_timestamp($stamp1, "parser");
|
||||
$a->saveTimestamp($stamp1, "parser");
|
||||
} else {
|
||||
$_SESSION = [];
|
||||
Worker::executeIfIdle();
|
||||
|
@ -91,7 +93,7 @@ if (!$a->is_backend()) {
|
|||
* Language was set earlier, but we can over-ride it in the session.
|
||||
* We have to do it here because the session was just now opened.
|
||||
*/
|
||||
if (x($_SESSION, 'authenticated') && !x($_SESSION, 'language')) {
|
||||
if (!empty($_SESSION['authenticated']) && empty($_SESSION['language'])) {
|
||||
$_SESSION['language'] = $lang;
|
||||
// we haven't loaded user data yet, but we need user language
|
||||
if (!empty($_SESSION['uid'])) {
|
||||
|
@ -102,12 +104,12 @@ if (x($_SESSION, 'authenticated') && !x($_SESSION, 'language')) {
|
|||
}
|
||||
}
|
||||
|
||||
if (x($_SESSION, 'language') && ($_SESSION['language'] !== $lang)) {
|
||||
if (!empty($_SESSION['language']) && $_SESSION['language'] !== $lang) {
|
||||
$lang = $_SESSION['language'];
|
||||
L10n::loadTranslationTable($lang);
|
||||
}
|
||||
|
||||
if (!empty($_GET['zrl']) && $a->mode == App::MODE_NORMAL) {
|
||||
if (!empty($_GET['zrl']) && $a->getMode()->isNormal()) {
|
||||
$a->query_string = Profile::stripZrls($a->query_string);
|
||||
if (!local_user()) {
|
||||
// Only continue when the given profile link seems valid
|
||||
|
@ -125,12 +127,12 @@ if (!empty($_GET['zrl']) && $a->mode == App::MODE_NORMAL) {
|
|||
logger("Invalid ZRL parameter " . $_GET['zrl'], LOGGER_DEBUG);
|
||||
header('HTTP/1.1 403 Forbidden');
|
||||
echo "<h1>403 Forbidden</h1>";
|
||||
killme();
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((x($_GET,'owt')) && $a->mode == App::MODE_NORMAL) {
|
||||
if (!empty($_GET['owt']) && $a->getMode()->isNormal()) {
|
||||
$token = $_GET['owt'];
|
||||
$a->query_string = Profile::stripQueryParam($a->query_string, 'owt');
|
||||
Profile::openWebAuthInit($token);
|
||||
|
@ -149,14 +151,10 @@ if ((x($_GET,'owt')) && $a->mode == App::MODE_NORMAL) {
|
|||
|
||||
Login::sessionAuth();
|
||||
|
||||
if (! x($_SESSION, 'authenticated')) {
|
||||
if (empty($_SESSION['authenticated'])) {
|
||||
header('X-Account-Management-Status: none');
|
||||
}
|
||||
|
||||
/* set up page['htmlhead'] and page['end'] for the modules to use */
|
||||
$a->page['htmlhead'] = '';
|
||||
$a->page['end'] = '';
|
||||
|
||||
$_SESSION['sysmsg'] = defaults($_SESSION, 'sysmsg' , []);
|
||||
$_SESSION['sysmsg_info'] = defaults($_SESSION, 'sysmsg_info' , []);
|
||||
$_SESSION['last_updated'] = defaults($_SESSION, 'last_updated', []);
|
||||
|
@ -169,14 +167,14 @@ $_SESSION['last_updated'] = defaults($_SESSION, 'last_updated', []);
|
|||
|
||||
// in install mode, any url loads install module
|
||||
// but we need "view" module for stylesheet
|
||||
if ($a->isInstallMode() && $a->module!="view") {
|
||||
if ($a->getMode()->isInstall() && $a->module != 'view') {
|
||||
$a->module = 'install';
|
||||
} elseif (!($a->mode & App::MODE_MAINTENANCEDISABLED) && $a->module != "view") {
|
||||
} elseif (!$a->getMode()->has(App\Mode::MAINTENANCEDISABLED) && $a->module != 'view') {
|
||||
$a->module = 'maintenance';
|
||||
} else {
|
||||
check_url($a);
|
||||
check_db(false);
|
||||
check_addons($a);
|
||||
Addon::check();
|
||||
}
|
||||
|
||||
Nav::setSelected('nothing');
|
||||
|
@ -295,11 +293,11 @@ if (strlen($a->module)) {
|
|||
|
||||
if (! $a->module_loaded) {
|
||||
// Stupid browser tried to pre-fetch our Javascript img template. Don't log the event or return anything - just quietly exit.
|
||||
if ((x($_SERVER, 'QUERY_STRING')) && preg_match('/{[0-9]}/', $_SERVER['QUERY_STRING']) !== 0) {
|
||||
if (!empty($_SERVER['QUERY_STRING']) && preg_match('/{[0-9]}/', $_SERVER['QUERY_STRING']) !== 0) {
|
||||
killme();
|
||||
}
|
||||
|
||||
if ((x($_SERVER, 'QUERY_STRING')) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && isset($dreamhost_error_hack)) {
|
||||
if (!empty($_SERVER['QUERY_STRING']) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && isset($dreamhost_error_hack)) {
|
||||
logger('index.php: dreamhost_error_hack invoked. Original URI =' . $_SERVER['REQUEST_URI']);
|
||||
goaway(System::baseUrl() . $_SERVER['REQUEST_URI']);
|
||||
}
|
||||
|
@ -307,11 +305,9 @@ if (strlen($a->module)) {
|
|||
logger('index.php: page not found: ' . $_SERVER['REQUEST_URI'] . ' ADDRESS: ' . $_SERVER['REMOTE_ADDR'] . ' QUERY: ' . $_SERVER['QUERY_STRING'], LOGGER_DEBUG);
|
||||
header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . L10n::t('Not Found'));
|
||||
$tpl = get_markup_template("404.tpl");
|
||||
$a->page['content'] = replace_macros(
|
||||
$tpl,
|
||||
[
|
||||
'$message' => L10n::t('Page not found.')]
|
||||
);
|
||||
$a->page['content'] = replace_macros($tpl, [
|
||||
'$message' => L10n::t('Page not found.')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -326,11 +322,7 @@ if (file_exists($theme_info_file)) {
|
|||
|
||||
/* initialise content region */
|
||||
|
||||
if (! x($a->page, 'content')) {
|
||||
$a->page['content'] = '';
|
||||
}
|
||||
|
||||
if ($a->mode == App::MODE_NORMAL) {
|
||||
if ($a->getMode()->isNormal()) {
|
||||
Addon::callHooks('page_content_top', $a->page['content']);
|
||||
}
|
||||
|
||||
|
@ -342,15 +334,21 @@ if ($a->module_loaded) {
|
|||
$a->page['page_title'] = $a->module;
|
||||
$placeholder = '';
|
||||
|
||||
Addon::callHooks($a->module . '_mod_init', $placeholder);
|
||||
|
||||
if ($a->module_class) {
|
||||
Addon::callHooks($a->module . '_mod_init', $placeholder);
|
||||
call_user_func([$a->module_class, 'init']);
|
||||
} else if (function_exists($a->module . '_init')) {
|
||||
Addon::callHooks($a->module . '_mod_init', $placeholder);
|
||||
$func = $a->module . '_init';
|
||||
$func($a);
|
||||
}
|
||||
|
||||
// "rawContent" is especially meant for technical endpoints.
|
||||
// This endpoint doesn't need any theme initialization or other comparable stuff.
|
||||
if (!$a->error && $a->module_class) {
|
||||
call_user_func([$a->module_class, 'rawContent']);
|
||||
}
|
||||
|
||||
if (function_exists(str_replace('-', '_', $a->getCurrentTheme()) . '_init')) {
|
||||
$func = str_replace('-', '_', $a->getCurrentTheme()) . '_init';
|
||||
$func($a);
|
||||
|
@ -405,24 +403,13 @@ if ($a->module_loaded) {
|
|||
* theme choices made by the modules can take effect.
|
||||
*/
|
||||
|
||||
$a->init_pagehead();
|
||||
$a->initHead();
|
||||
|
||||
/*
|
||||
* Build the page ending -- this is stuff that goes right before
|
||||
* the closing </body> tag
|
||||
*/
|
||||
$a->init_page_end();
|
||||
|
||||
// If you're just visiting, let javascript take you home
|
||||
if (x($_SESSION, 'visitor_home')) {
|
||||
$homebase = $_SESSION['visitor_home'];
|
||||
} elseif (local_user()) {
|
||||
$homebase = 'profile/' . $a->user['nickname'];
|
||||
}
|
||||
|
||||
if (isset($homebase)) {
|
||||
$a->page['content'] .= '<script>var homebase="' . $homebase . '" ; </script>';
|
||||
}
|
||||
$a->initFooter();
|
||||
|
||||
/*
|
||||
* now that we've been through the module content, see if the page reported
|
||||
|
@ -444,36 +431,9 @@ if ($a->module != 'install' && $a->module != 'maintenance') {
|
|||
Nav::build($a);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a "toggle mobile" link if we're using a mobile device
|
||||
*/
|
||||
if ($a->is_mobile || $a->is_tablet) {
|
||||
if (isset($_SESSION['show-mobile']) && !$_SESSION['show-mobile']) {
|
||||
$link = 'toggle_mobile?address=' . curPageURL();
|
||||
} else {
|
||||
$link = 'toggle_mobile?off=1&address=' . curPageURL();
|
||||
}
|
||||
$a->page['footer'] = replace_macros(
|
||||
get_markup_template("toggle_mobile_footer.tpl"),
|
||||
[
|
||||
'$toggle_link' => $link,
|
||||
'$toggle_text' => L10n::t('toggle mobile')]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the page - now that we have all the components
|
||||
*/
|
||||
|
||||
if (!$a->theme['stylesheet']) {
|
||||
$stylesheet = $a->getCurrentThemeStylesheetPath();
|
||||
} else {
|
||||
$stylesheet = $a->theme['stylesheet'];
|
||||
}
|
||||
|
||||
$a->page['htmlhead'] = str_replace('{{$stylesheet}}', $stylesheet, $a->page['htmlhead']);
|
||||
//$a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array('$stylesheet' => $stylesheet));
|
||||
|
||||
if (isset($_GET["mode"]) && (($_GET["mode"] == "raw") || ($_GET["mode"] == "minimal"))) {
|
||||
$doc = new DOMDocument();
|
||||
|
||||
|
@ -502,7 +462,7 @@ if (isset($_GET["mode"]) && ($_GET["mode"] == "raw")) {
|
|||
|
||||
echo substr($target->saveHTML(), 6, -8);
|
||||
|
||||
killme();
|
||||
exit();
|
||||
}
|
||||
|
||||
$page = $a->page;
|
||||
|
@ -540,5 +500,3 @@ if (empty($template)) {
|
|||
|
||||
/// @TODO Looks unsafe (remote-inclusion), is maybe not but Theme::getPathForFile() uses file_exists() but does not escape anything
|
||||
require_once $template;
|
||||
|
||||
killme();
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Network\Probe;
|
||||
|
||||
function acctlink_init()
|
||||
{
|
||||
if (x($_GET, 'addr')) {
|
||||
$addr = trim($_GET['addr']);
|
||||
$res = Probe::uri($addr);
|
||||
if ($res['url']) {
|
||||
goaway($res['url']);
|
||||
killme();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -83,8 +83,9 @@ function acl_content(App $a)
|
|||
WHERE `uid` = %d AND NOT `self`
|
||||
AND NOT `blocked` AND NOT `pending` AND NOT `archive`
|
||||
AND `success_update` >= `failure_update`
|
||||
AND `network` IN ('%s', '%s') $sql_extra2",
|
||||
AND `network` IN ('%s', '%s', '%s') $sql_extra2",
|
||||
intval(local_user()),
|
||||
DBA::escape(Protocol::ACTIVITYPUB),
|
||||
DBA::escape(Protocol::DFRN),
|
||||
DBA::escape(Protocol::DIASPORA)
|
||||
);
|
||||
|
@ -169,10 +170,11 @@ function acl_content(App $a)
|
|||
} elseif ($type == 'm') {
|
||||
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr` FROM `contact`
|
||||
WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive`
|
||||
AND `success_update` >= `failure_update` AND `network` IN ('%s', '%s')
|
||||
AND `success_update` >= `failure_update` AND `network` IN ('%s', '%s', '%s')
|
||||
$sql_extra2
|
||||
ORDER BY `name` ASC ",
|
||||
intval(local_user()),
|
||||
DBA::escape(Protocol::ACTIVITYPUB),
|
||||
DBA::escape(Protocol::DFRN),
|
||||
DBA::escape(Protocol::DIASPORA)
|
||||
);
|
||||
|
|
|
@ -77,7 +77,7 @@ function admin_post(App $a)
|
|||
break;
|
||||
case 'themes':
|
||||
if ($a->argc < 2) {
|
||||
if (is_ajax()) {
|
||||
if ($a->isAjax()) {
|
||||
return;
|
||||
}
|
||||
goaway('admin/');
|
||||
|
@ -107,7 +107,7 @@ function admin_post(App $a)
|
|||
}
|
||||
|
||||
info(L10n::t('Theme settings updated.'));
|
||||
if (is_ajax()) {
|
||||
if ($a->isAjax()) {
|
||||
return;
|
||||
}
|
||||
$return_path = 'admin/themes/' . $theme;
|
||||
|
@ -286,7 +286,7 @@ function admin_content(App $a)
|
|||
$o = admin_page_summary($a);
|
||||
}
|
||||
|
||||
if (is_ajax()) {
|
||||
if ($a->isAjax()) {
|
||||
echo $o;
|
||||
killme();
|
||||
return '';
|
||||
|
@ -475,8 +475,8 @@ function admin_page_contactblock(App $a)
|
|||
|
||||
$total = DBA::count('contact', $condition);
|
||||
|
||||
$a->set_pager_total($total);
|
||||
$a->set_pager_itemspage(30);
|
||||
$a->setPagerTotal($total);
|
||||
$a->setPagerItemsPage(30);
|
||||
|
||||
$statement = DBA::select('contact', [], $condition, ['limit' => [$a->pager['start'], $a->pager['itemspage']]]);
|
||||
|
||||
|
@ -866,15 +866,15 @@ function admin_page_summary(App $a)
|
|||
// Legacy config file warning
|
||||
if (file_exists('.htconfig.php')) {
|
||||
$showwarning = true;
|
||||
$warningtext[] = L10n::t('Friendica\'s configuration now is stored in config/local.ini.php, please copy config/local-sample.ini.php and move your config from <code>.htconfig.php</code>. See <a href="%s">the Config help page</a> for help with the transition.', $a->get_baseurl() . '/help/Config');
|
||||
$warningtext[] = L10n::t('Friendica\'s configuration now is stored in config/local.ini.php, please copy config/local-sample.ini.php and move your config from <code>.htconfig.php</code>. See <a href="%s">the Config help page</a> for help with the transition.', $a->getBaseURL() . '/help/Config');
|
||||
}
|
||||
|
||||
// Check server vitality
|
||||
if (!admin_page_server_vital()) {
|
||||
$showwarning = true;
|
||||
$well_known = $a->get_baseurl() . '/.well-known/host-meta';
|
||||
$well_known = $a->getBaseURL() . '/.well-known/host-meta';
|
||||
$warningtext[] = L10n::t('<a href="%s">%s</a> is not reachable on your system. This is a severe configuration issue that prevents server to server communication. See <a href="%s">the installation page</a> for help.',
|
||||
$well_known, $well_known, $a->get_baseurl() . '/help/Install');
|
||||
$well_known, $well_known, $a->getBaseURL() . '/help/Install');
|
||||
}
|
||||
|
||||
$r = q("SELECT `page-flags`, COUNT(`uid`) AS `count` FROM `user` GROUP BY `page-flags`");
|
||||
|
@ -1012,7 +1012,7 @@ function admin_page_site_post(App $a)
|
|||
// update config
|
||||
Config::set('system', 'hostname', parse_url($new_url, PHP_URL_HOST));
|
||||
Config::set('system', 'url', $new_url);
|
||||
$a->set_baseurl($new_url);
|
||||
$a->setBaseURL($new_url);
|
||||
|
||||
// send relocate
|
||||
$users = q("SELECT `uid` FROM `user` WHERE `account_removed` = 0 AND `account_expired` = 0");
|
||||
|
@ -1124,7 +1124,7 @@ function admin_page_site_post(App $a)
|
|||
Worker::add(PRIORITY_LOW, 'Directory');
|
||||
}
|
||||
|
||||
if ($a->get_path() != "") {
|
||||
if ($a->getURLPath() != "") {
|
||||
$diaspora_enabled = false;
|
||||
}
|
||||
if ($ssl_policy != intval(Config::get('system', 'ssl_policy'))) {
|
||||
|
@ -1261,7 +1261,7 @@ function admin_page_site_post(App $a)
|
|||
Config::set('system', 'dbclean-expire-unclaimed', $dbclean_unclaimed);
|
||||
|
||||
if ($itemcache != '') {
|
||||
$itemcache = App::realpath($itemcache);
|
||||
$itemcache = App::getRealPath($itemcache);
|
||||
}
|
||||
|
||||
Config::set('system', 'itemcache', $itemcache);
|
||||
|
@ -1269,13 +1269,13 @@ function admin_page_site_post(App $a)
|
|||
Config::set('system', 'max_comments', $max_comments);
|
||||
|
||||
if ($temppath != '') {
|
||||
$temppath = App::realpath($temppath);
|
||||
$temppath = App::getRealPath($temppath);
|
||||
}
|
||||
|
||||
Config::set('system', 'temppath', $temppath);
|
||||
|
||||
if ($basepath != '') {
|
||||
$basepath = App::realpath($basepath);
|
||||
$basepath = App::getRealPath($basepath);
|
||||
}
|
||||
|
||||
Config::set('system', 'basepath', $basepath);
|
||||
|
@ -1419,9 +1419,9 @@ function admin_page_site(App $a)
|
|||
];
|
||||
|
||||
if (empty(Config::get('config', 'hostname'))) {
|
||||
Config::set('config', 'hostname', $a->get_hostname());
|
||||
Config::set('config', 'hostname', $a->getHostName());
|
||||
}
|
||||
$diaspora_able = ($a->get_path() == "");
|
||||
$diaspora_able = ($a->getURLPath() == "");
|
||||
|
||||
$optimize_max_tablesize = Config::get('system', 'optimize_max_tablesize', -1);
|
||||
|
||||
|
@ -1488,7 +1488,7 @@ function admin_page_site(App $a)
|
|||
'$community_page_style' => ['community_page_style', L10n::t("Community pages for visitors"), Config::get('system','community_page_style'), L10n::t("Which community pages should be available for visitors. Local users always see both pages."), $community_page_style_choices],
|
||||
'$max_author_posts_community_page' => ['max_author_posts_community_page', L10n::t("Posts per user on community page"), Config::get('system','max_author_posts_community_page'), L10n::t("The maximum number of posts per user on the community page. \x28Not valid for 'Global Community'\x29")],
|
||||
'$ostatus_disabled' => ['ostatus_disabled', L10n::t("Enable OStatus support"), !Config::get('system','ostatus_disabled'), L10n::t("Provide built-in OStatus \x28StatusNet, GNU Social etc.\x29 compatibility. All communications in OStatus are public, so privacy warnings will be occasionally displayed.")],
|
||||
'$ostatus_full_threads' => ['ostatus_full_threads', L10n::t("Only import OStatus threads from our contacts"), Config::get('system','ostatus_full_threads'), L10n::t("Normally we import every content from our OStatus contacts. With this option we only store threads that are started by a contact that is known on our system.")],
|
||||
'$ostatus_full_threads' => ['ostatus_full_threads', L10n::t("Only import OStatus/ActivityPub threads from our contacts"), Config::get('system','ostatus_full_threads'), L10n::t("Normally we import every content from our OStatus and ActivityPub contacts. With this option we only store threads that are started by a contact that is known on our system.")],
|
||||
'$ostatus_not_able' => L10n::t("OStatus support can only be enabled if threading is enabled."),
|
||||
'$diaspora_able' => $diaspora_able,
|
||||
'$diaspora_not_able' => L10n::t("Diaspora support can't be enabled because Friendica was installed into a sub directory."),
|
||||
|
@ -1801,8 +1801,8 @@ function admin_page_users(App $a)
|
|||
/* get users */
|
||||
$total = q("SELECT COUNT(*) AS `total` FROM `user` WHERE 1");
|
||||
if (count($total)) {
|
||||
$a->set_pager_total($total[0]['total']);
|
||||
$a->set_pager_itemspage(100);
|
||||
$a->setPagerTotal($total[0]['total']);
|
||||
$a->setPagerItemsPage(100);
|
||||
}
|
||||
|
||||
/* ordering */
|
||||
|
@ -2536,7 +2536,7 @@ function admin_page_features_post(App $a)
|
|||
*/
|
||||
function admin_page_features(App $a)
|
||||
{
|
||||
if ((argc() > 1) && (argv(1) === 'features')) {
|
||||
if (($a->argc > 1) && ($a->getArgumentValue(1) === 'features')) {
|
||||
$arr = [];
|
||||
$features = Feature::get(false);
|
||||
|
||||
|
@ -2567,6 +2567,5 @@ function admin_page_features(App $a)
|
|||
function admin_page_server_vital()
|
||||
{
|
||||
// Fetch the host-meta to check if this really is a vital server
|
||||
$serverret = Network::curl(System::baseUrl() . '/.well-known/host-meta');
|
||||
return $serverret["success"];
|
||||
return Network::curl(System::baseUrl() . '/.well-known/host-meta')->isSuccess();
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ function allfriends_content(App $a)
|
|||
|
||||
$total = GContact::countAllFriends(local_user(), $cid);
|
||||
|
||||
$a->set_pager_total($total);
|
||||
$a->setPagerTotal($total);
|
||||
|
||||
$r = GContact::allFriends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']);
|
||||
if (!DBA::isResult($r)) {
|
||||
|
|
|
@ -114,6 +114,17 @@ function babel_content()
|
|||
'content' => visible_whitespace($bbcode)
|
||||
];
|
||||
|
||||
$html2 = Text\BBCode::convert($bbcode);
|
||||
$results[] = [
|
||||
'title' => L10n::t('HTML::toBBCode => BBCode::convert'),
|
||||
'content' => $html2
|
||||
];
|
||||
|
||||
$results[] = [
|
||||
'title' => L10n::t('HTML::toBBCode => BBCode::convert (raw HTML)'),
|
||||
'content' => htmlspecialchars($html2)
|
||||
];
|
||||
|
||||
$markdown = Text\HTML::toMarkdown($html);
|
||||
$results[] = [
|
||||
'title' => L10n::t('HTML::toMarkdown'),
|
||||
|
|
|
@ -94,11 +94,6 @@ function cal_content(App $a)
|
|||
'$i18n' => $i18n,
|
||||
]);
|
||||
|
||||
$etpl = get_markup_template('event_end.tpl');
|
||||
$a->page['end'] .= replace_macros($etpl, [
|
||||
'$baseurl' => System::baseUrl(),
|
||||
]);
|
||||
|
||||
$mode = 'view';
|
||||
$y = 0;
|
||||
$m = 0;
|
||||
|
|
|
@ -88,7 +88,7 @@ function common_content(App $a)
|
|||
}
|
||||
|
||||
if ($t > 0) {
|
||||
$a->set_pager_total($t);
|
||||
$a->setPagerTotal($t);
|
||||
} else {
|
||||
notice(L10n::t('No contacts in common.') . EOL);
|
||||
return $o;
|
||||
|
|
|
@ -153,7 +153,7 @@ function community_content(App $a, $update = 0)
|
|||
$itemspage_network = $a->force_max_items;
|
||||
}
|
||||
|
||||
$a->set_pager_itemspage($itemspage_network);
|
||||
$a->setPagerItemsPage($itemspage_network);
|
||||
|
||||
$r = community_getitems($a->pager['start'], $a->pager['itemspage'], $content, $accounttype);
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ use Friendica\Network\Probe;
|
|||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Proxy as ProxyUtils;
|
||||
use Friendica\Core\ACL;
|
||||
use Friendica\Module\Login;
|
||||
|
||||
function contacts_init(App $a)
|
||||
{
|
||||
|
@ -117,12 +118,6 @@ function contacts_init(App $a)
|
|||
'$baseurl' => System::baseUrl(true),
|
||||
'$base' => $base
|
||||
]);
|
||||
|
||||
$tpl = get_markup_template("contacts-end.tpl");
|
||||
$a->page['end'] .= replace_macros($tpl, [
|
||||
'$baseurl' => System::baseUrl(true),
|
||||
'$base' => $base
|
||||
]);
|
||||
}
|
||||
|
||||
function contacts_batch_actions(App $a)
|
||||
|
@ -168,11 +163,7 @@ function contacts_batch_actions(App $a)
|
|||
info(L10n::tt("%d contact edited.", "%d contacts edited.", $count_actions));
|
||||
}
|
||||
|
||||
if (x($_SESSION, 'return_url')) {
|
||||
goaway('' . $_SESSION['return_url']);
|
||||
} else {
|
||||
goaway('contacts');
|
||||
}
|
||||
goaway('contacts');
|
||||
}
|
||||
|
||||
function contacts_post(App $a)
|
||||
|
@ -385,7 +376,7 @@ function contacts_content(App $a, $update = 0)
|
|||
|
||||
if (!local_user()) {
|
||||
notice(L10n::t('Permission denied.') . EOL);
|
||||
return;
|
||||
return Login::form();
|
||||
}
|
||||
|
||||
if ($a->argc == 3) {
|
||||
|
@ -476,20 +467,13 @@ function contacts_content(App $a, $update = 0)
|
|||
}
|
||||
// Now check how the user responded to the confirmation query
|
||||
if (x($_REQUEST, 'canceled')) {
|
||||
if (x($_SESSION, 'return_url')) {
|
||||
goaway('' . $_SESSION['return_url']);
|
||||
} else {
|
||||
goaway('contacts');
|
||||
}
|
||||
goaway('contacts');
|
||||
}
|
||||
|
||||
_contact_drop($orig_record);
|
||||
info(L10n::t('Contact has been removed.') . EOL);
|
||||
if (x($_SESSION, 'return_url')) {
|
||||
goaway('' . $_SESSION['return_url']);
|
||||
} else {
|
||||
goaway('contacts');
|
||||
}
|
||||
|
||||
goaway('contacts');
|
||||
return; // NOTREACHED
|
||||
}
|
||||
if ($cmd === 'posts') {
|
||||
|
@ -509,9 +493,6 @@ function contacts_content(App $a, $update = 0)
|
|||
$a->page['htmlhead'] .= replace_macros(get_markup_template('contact_head.tpl'), [
|
||||
'$baseurl' => System::baseUrl(true),
|
||||
]);
|
||||
$a->page['end'] .= replace_macros(get_markup_template('contact_end.tpl'), [
|
||||
'$baseurl' => System::baseUrl(true),
|
||||
]);
|
||||
|
||||
$contact['blocked'] = Contact::isBlockedByUser($contact['id'], local_user());
|
||||
$contact['readonly'] = Contact::isIgnoredByUser($contact['id'], local_user());
|
||||
|
@ -542,7 +523,7 @@ function contacts_content(App $a, $update = 0)
|
|||
$relation_text = '';
|
||||
}
|
||||
|
||||
if (!in_array($contact['network'], [Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA])) {
|
||||
if (!in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA])) {
|
||||
$relation_text = "";
|
||||
}
|
||||
|
||||
|
@ -655,15 +636,15 @@ function contacts_content(App $a, $update = 0)
|
|||
'$follow_text' => $follow_text,
|
||||
'$profile_select' => $profile_select,
|
||||
'$contact_id' => $contact['id'],
|
||||
'$block_text' => (($contact['blocked']) ? L10n::t('Unblock') : L10n::t('Block') ),
|
||||
'$ignore_text' => (($contact['readonly']) ? L10n::t('Unignore') : L10n::t('Ignore') ),
|
||||
'$insecure' => (($contact['network'] !== Protocol::DFRN && $contact['network'] !== Protocol::MAIL && $contact['network'] !== Protocol::DIASPORA) ? $insecure : ''),
|
||||
'$block_text' => ($contact['blocked'] ? L10n::t('Unblock') : L10n::t('Block')),
|
||||
'$ignore_text' => ($contact['readonly'] ? L10n::t('Unignore') : L10n::t('Ignore')),
|
||||
'$insecure' => (in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::MAIL, Protocol::DIASPORA]) ? '' : $insecure),
|
||||
'$info' => $contact['info'],
|
||||
'$cinfo' => ['info', '', $contact['info'], ''],
|
||||
'$blocked' => (($contact['blocked']) ? L10n::t('Currently blocked') : ''),
|
||||
'$ignored' => (($contact['readonly']) ? L10n::t('Currently ignored') : ''),
|
||||
'$archived' => (($contact['archive']) ? L10n::t('Currently archived') : ''),
|
||||
'$pending' => (($contact['pending']) ? L10n::t('Awaiting connection acknowledge') : ''),
|
||||
'$blocked' => ($contact['blocked'] ? L10n::t('Currently blocked') : ''),
|
||||
'$ignored' => ($contact['readonly'] ? L10n::t('Currently ignored') : ''),
|
||||
'$archived' => ($contact['archive'] ? L10n::t('Currently archived') : ''),
|
||||
'$pending' => ($contact['pending'] ? L10n::t('Awaiting connection acknowledge') : ''),
|
||||
'$hidden' => ['hidden', L10n::t('Hide this contact from others'), ($contact['hidden'] == 1), L10n::t('Replies/likes to your public posts <strong>may</strong> still be visible')],
|
||||
'$notify' => ['notify', L10n::t('Notification for new posts'), ($contact['notify_new_posts'] == 1), L10n::t('Send a notification of every new post of this contact')],
|
||||
'$fetch_further_information' => $fetch_further_information,
|
||||
|
@ -812,7 +793,7 @@ function contacts_content(App $a, $update = 0)
|
|||
intval($_SESSION['uid'])
|
||||
);
|
||||
if (DBA::isResult($r)) {
|
||||
$a->set_pager_total($r[0]['total']);
|
||||
$a->setPagerTotal($r[0]['total']);
|
||||
$total = $r[0]['total'];
|
||||
}
|
||||
|
||||
|
@ -975,7 +956,7 @@ function contact_conversations(App $a, $contact_id, $update)
|
|||
$profiledata = Contact::getDetailsByURL($contact["url"]);
|
||||
|
||||
if (local_user()) {
|
||||
if (in_array($profiledata["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
|
||||
if (in_array($profiledata["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
|
||||
$profiledata["remoteconnect"] = System::baseUrl()."/follow?url=".urlencode($profiledata["url"]);
|
||||
}
|
||||
}
|
||||
|
@ -999,7 +980,7 @@ function contact_posts(App $a, $contact_id)
|
|||
$profiledata = Contact::getDetailsByURL($contact["url"]);
|
||||
|
||||
if (local_user()) {
|
||||
if (in_array($profiledata["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
|
||||
if (in_array($profiledata["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
|
||||
$profiledata["remoteconnect"] = System::baseUrl()."/follow?url=".urlencode($profiledata["url"]);
|
||||
}
|
||||
}
|
||||
|
@ -1080,7 +1061,7 @@ function _contact_detail_for_template(array $rr)
|
|||
*/
|
||||
function contact_actions($contact)
|
||||
{
|
||||
$poll_enabled = in_array($contact['network'], [Protocol::DFRN, Protocol::OSTATUS, Protocol::FEED, Protocol::MAIL]);
|
||||
$poll_enabled = in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::FEED, Protocol::MAIL]);
|
||||
$contact_actions = [];
|
||||
|
||||
// Provide friend suggestion only for Friendica contacts
|
||||
|
@ -1105,7 +1086,7 @@ function contact_actions($contact)
|
|||
}
|
||||
|
||||
$contact_actions['block'] = [
|
||||
'label' => (intval($contact['blocked']) ? L10n::t('Unblock') : L10n::t('Block') ),
|
||||
'label' => (intval($contact['blocked']) ? L10n::t('Unblock') : L10n::t('Block')),
|
||||
'url' => 'contacts/' . $contact['id'] . '/block',
|
||||
'title' => L10n::t('Toggle Blocked status'),
|
||||
'sel' => (intval($contact['blocked']) ? 'active' : ''),
|
||||
|
@ -1113,7 +1094,7 @@ function contact_actions($contact)
|
|||
];
|
||||
|
||||
$contact_actions['ignore'] = [
|
||||
'label' => (intval($contact['readonly']) ? L10n::t('Unignore') : L10n::t('Ignore') ),
|
||||
'label' => (intval($contact['readonly']) ? L10n::t('Unignore') : L10n::t('Ignore')),
|
||||
'url' => 'contacts/' . $contact['id'] . '/ignore',
|
||||
'title' => L10n::t('Toggle Ignored status'),
|
||||
'sel' => (intval($contact['readonly']) ? 'active' : ''),
|
||||
|
@ -1122,7 +1103,7 @@ function contact_actions($contact)
|
|||
|
||||
if ($contact['uid'] != 0) {
|
||||
$contact_actions['archive'] = [
|
||||
'label' => (intval($contact['archive']) ? L10n::t('Unarchive') : L10n::t('Archive') ),
|
||||
'label' => (intval($contact['archive']) ? L10n::t('Unarchive') : L10n::t('Archive')),
|
||||
'url' => 'contacts/' . $contact['id'] . '/archive',
|
||||
'title' => L10n::t('Toggle Archive status'),
|
||||
'sel' => (intval($contact['archive']) ? 'active' : ''),
|
||||
|
|
|
@ -133,7 +133,7 @@ function crepair_content(App $a)
|
|||
$remote_self_options = ['0' => L10n::t('No mirroring'), '2' => L10n::t('Mirror as my own posting')];
|
||||
}
|
||||
|
||||
$update_profile = in_array($contact['network'], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]);
|
||||
$update_profile = in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]);
|
||||
|
||||
$tab_str = contacts_tab($a, $contact, 5);
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ use Friendica\Model\Group;
|
|||
use Friendica\Model\User;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Protocol\Diaspora;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Util\Crypto;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Network;
|
||||
|
@ -220,7 +221,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
|
|||
*
|
||||
*/
|
||||
|
||||
$res = Network::post($dfrn_confirm, $params, null, $redirects, 120);
|
||||
$res = Network::post($dfrn_confirm, $params, null, $redirects, 120)->getBody();
|
||||
|
||||
logger(' Confirm: received data: ' . $res, LOGGER_DATA);
|
||||
|
||||
|
@ -335,10 +336,17 @@ function dfrn_confirm_post(App $a, $handsfree = null)
|
|||
intval($contact_id)
|
||||
);
|
||||
} else {
|
||||
if ($network == Protocol::ACTIVITYPUB) {
|
||||
ActivityPub\Transmitter::sendContactAccept($contact['url'], $contact['hub-verify'], $uid);
|
||||
$pending = true;
|
||||
} else {
|
||||
$pending = false;
|
||||
}
|
||||
|
||||
// $network !== Protocol::DFRN
|
||||
$network = defaults($contact, 'network', Protocol::OSTATUS);
|
||||
|
||||
$arr = Probe::uri($contact['url']);
|
||||
$arr = Probe::uri($contact['url'], $network);
|
||||
|
||||
$notify = defaults($contact, 'notify' , $arr['notify']);
|
||||
$poll = defaults($contact, 'poll' , $arr['poll']);
|
||||
|
@ -348,7 +356,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
|
|||
$new_relation = $contact['rel'];
|
||||
$writable = $contact['writable'];
|
||||
|
||||
if ($network === Protocol::DIASPORA) {
|
||||
if (in_array($network, [Protocol::DIASPORA, Protocol::ACTIVITYPUB])) {
|
||||
if ($duplex) {
|
||||
$new_relation = Contact::FRIEND;
|
||||
} else {
|
||||
|
@ -362,30 +370,12 @@ function dfrn_confirm_post(App $a, $handsfree = null)
|
|||
|
||||
DBA::delete('intro', ['id' => $intro_id]);
|
||||
|
||||
$r = q("UPDATE `contact` SET `name-date` = '%s',
|
||||
`uri-date` = '%s',
|
||||
`addr` = '%s',
|
||||
`notify` = '%s',
|
||||
`poll` = '%s',
|
||||
`blocked` = 0,
|
||||
`pending` = 0,
|
||||
`network` = '%s',
|
||||
`writable` = %d,
|
||||
`hidden` = %d,
|
||||
`rel` = %d
|
||||
WHERE `id` = %d
|
||||
",
|
||||
DBA::escape(DateTimeFormat::utcNow()),
|
||||
DBA::escape(DateTimeFormat::utcNow()),
|
||||
DBA::escape($addr),
|
||||
DBA::escape($notify),
|
||||
DBA::escape($poll),
|
||||
DBA::escape($network),
|
||||
intval($writable),
|
||||
intval($hidden),
|
||||
intval($new_relation),
|
||||
intval($contact_id)
|
||||
);
|
||||
$fields = ['name-date' => DateTimeFormat::utcNow(),
|
||||
'uri-date' => DateTimeFormat::utcNow(), 'addr' => $addr,
|
||||
'notify' => $notify, 'poll' => $poll, 'blocked' => false,
|
||||
'pending' => $pending, 'network' => $network,
|
||||
'writable' => $writable, 'hidden' => $hidden, 'rel' => $new_relation];
|
||||
DBA::update('contact', $fields, ['id' => $contact_id]);
|
||||
}
|
||||
|
||||
if (!DBA::isResult($r)) {
|
||||
|
@ -403,6 +393,10 @@ function dfrn_confirm_post(App $a, $handsfree = null)
|
|||
|
||||
Group::addMember(User::getDefaultGroup($uid, $contact["network"]), $contact['id']);
|
||||
|
||||
if ($network == Protocol::ACTIVITYPUB && $duplex) {
|
||||
ActivityPub\Transmitter::sendActivity('Follow', $contact['url'], $uid);
|
||||
}
|
||||
|
||||
// Let's send our user to the contact editor in case they want to
|
||||
// do anything special with this new friend.
|
||||
if ($handsfree === null) {
|
||||
|
|
|
@ -502,7 +502,7 @@ function dfrn_poll_content(App $a)
|
|||
'dfrn_version' => DFRN_PROTOCOL_VERSION,
|
||||
'challenge' => $challenge,
|
||||
'sec' => $sec
|
||||
]);
|
||||
])->getBody();
|
||||
}
|
||||
|
||||
$profile = ((DBA::isResult($r) && $r[0]['nickname']) ? $r[0]['nickname'] : $nickname);
|
||||
|
|
|
@ -451,10 +451,10 @@ function dfrn_request_post(App $a)
|
|||
// Diaspora needs the uri in the format user@domain.tld
|
||||
// Diaspora will support the remote subscription in a future version
|
||||
if ($network == Protocol::DIASPORA) {
|
||||
$uri = $nickname . '@' . $a->get_hostname();
|
||||
$uri = $nickname . '@' . $a->getHostName();
|
||||
|
||||
if ($a->get_path()) {
|
||||
$uri .= '/' . $a->get_path();
|
||||
if ($a->getURLPath()) {
|
||||
$uri .= '/' . $a->getURLPath();
|
||||
}
|
||||
|
||||
$uri = urlencode($uri);
|
||||
|
@ -609,7 +609,7 @@ function dfrn_request_content(App $a)
|
|||
} elseif (x($_GET, 'address') && ($_GET['address'] != "")) {
|
||||
$myaddr = $_GET['address'];
|
||||
} elseif (local_user()) {
|
||||
if (strlen($a->urlpath)) {
|
||||
if (strlen($a->getURLPath())) {
|
||||
$myaddr = System::baseUrl() . '/profile/' . $a->user['nickname'];
|
||||
} else {
|
||||
$myaddr = $a->user['nickname'] . '@' . substr(System::baseUrl(), strpos(System::baseUrl(), '://') + 3);
|
||||
|
|
|
@ -16,7 +16,7 @@ use Friendica\Util\Proxy as ProxyUtils;
|
|||
|
||||
function directory_init(App $a)
|
||||
{
|
||||
$a->set_pager_itemspage(60);
|
||||
$a->setPagerItemsPage(60);
|
||||
|
||||
if (local_user()) {
|
||||
$a->page['aside'] .= Widget::findPeople();
|
||||
|
@ -87,7 +87,7 @@ function directory_content(App $a)
|
|||
LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
|
||||
WHERE `is-default` $publish AND NOT `user`.`blocked` AND NOT `user`.`account_removed` $sql_extra");
|
||||
if (DBA::isResult($cnt)) {
|
||||
$a->set_pager_total($cnt['total']);
|
||||
$a->setPagerTotal($cnt['total']);
|
||||
}
|
||||
|
||||
$order = " ORDER BY `name` ASC ";
|
||||
|
|
|
@ -54,7 +54,7 @@ function dirfind_content(App $a, $prefix = "") {
|
|||
if ((valid_email($search) && Network::isEmailDomainValid($search)) ||
|
||||
(substr(normalise_link($search), 0, 7) == "http://")) {
|
||||
$user_data = Probe::uri($search);
|
||||
$discover_user = (in_array($user_data["network"], [Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA]));
|
||||
$discover_user = (in_array($user_data["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,8 +188,8 @@ function dirfind_content(App $a, $prefix = "") {
|
|||
}
|
||||
|
||||
if ($j->total) {
|
||||
$a->set_pager_total($j->total);
|
||||
$a->set_pager_itemspage($j->items_page);
|
||||
$a->setPagerTotal($j->total);
|
||||
$a->setPagerItemsPage($j->items_page);
|
||||
}
|
||||
|
||||
if (!empty($j->results)) {
|
||||
|
|
|
@ -17,6 +17,7 @@ use Friendica\Model\Group;
|
|||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Protocol\DFRN;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
|
||||
function display_init(App $a)
|
||||
{
|
||||
|
@ -43,7 +44,7 @@ function display_init(App $a)
|
|||
|
||||
$item = null;
|
||||
|
||||
$fields = ['id', 'parent', 'author-id', 'body', 'uid'];
|
||||
$fields = ['id', 'parent', 'author-id', 'body', 'uid', 'guid'];
|
||||
|
||||
// If there is only one parameter, then check if this parameter could be a guid
|
||||
if ($a->argc == 2) {
|
||||
|
@ -76,6 +77,10 @@ function display_init(App $a)
|
|||
displayShowFeed($item["id"], false);
|
||||
}
|
||||
|
||||
if (ActivityPub::isRequest()) {
|
||||
goaway(str_replace('display/', 'objects/', $a->query_string));
|
||||
}
|
||||
|
||||
if ($item["id"] != $item["parent"]) {
|
||||
$item = Item::selectFirstForUser(local_user(), $fields, ['id' => $item["parent"]]);
|
||||
}
|
||||
|
@ -360,7 +365,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
|
|||
$title = trim(HTML::toPlaintext(BBCode::convert($item["title"], false), 0, true));
|
||||
$author_name = $item["author-name"];
|
||||
|
||||
$image = $a->remove_baseurl($item["author-avatar"]);
|
||||
$image = $a->removeBaseURL($item["author-avatar"]);
|
||||
|
||||
if ($title == "") {
|
||||
$title = $author_name;
|
||||
|
|
|
@ -57,15 +57,6 @@ function editpost_content(App $a)
|
|||
'$nickname' => $a->user['nickname']
|
||||
]);
|
||||
|
||||
$tpl = get_markup_template('jot-end.tpl');
|
||||
$a->page['end'] .= replace_macros($tpl, [
|
||||
'$baseurl' => System::baseUrl(),
|
||||
'$ispublic' => ' ', // L10n::t('Visible to <strong>everybody</strong>'),
|
||||
'$geotag' => $geotag,
|
||||
'$nickname' => $a->user['nickname']
|
||||
]);
|
||||
|
||||
|
||||
$tpl = get_markup_template("jot.tpl");
|
||||
|
||||
if (strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])) {
|
||||
|
|
|
@ -17,6 +17,7 @@ use Friendica\Model\Item;
|
|||
use Friendica\Model\Profile;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Temporal;
|
||||
use Friendica\Module\Login;
|
||||
|
||||
require_once 'include/items.php';
|
||||
|
||||
|
@ -186,14 +187,14 @@ function events_post(App $a)
|
|||
Worker::add(PRIORITY_HIGH, "Notifier", "event", $item_id);
|
||||
}
|
||||
|
||||
goaway($_SESSION['return_url']);
|
||||
goaway('/events');
|
||||
}
|
||||
|
||||
function events_content(App $a)
|
||||
{
|
||||
if (!local_user()) {
|
||||
notice(L10n::t('Permission denied.') . EOL);
|
||||
return;
|
||||
return Login::form();
|
||||
}
|
||||
|
||||
if ($a->argc == 1) {
|
||||
|
@ -231,11 +232,6 @@ function events_content(App $a)
|
|||
'$i18n' => $i18n,
|
||||
]);
|
||||
|
||||
$etpl = get_markup_template('event_end.tpl');
|
||||
$a->page['end'] .= replace_macros($etpl, [
|
||||
'$baseurl' => System::baseUrl(),
|
||||
]);
|
||||
|
||||
$o = '';
|
||||
$tabs = '';
|
||||
// tabs
|
||||
|
|
|
@ -32,8 +32,7 @@ function feedtest_content(App $a)
|
|||
|
||||
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id]);
|
||||
|
||||
$ret = Network::curl($contact['poll']);
|
||||
$xml = $ret['body'];
|
||||
$xml = Network::fetchUrl($contact['poll']);
|
||||
|
||||
$dummy = null;
|
||||
$import_result = Feed::import($xml, $importer, $contact, $dummy, true);
|
||||
|
|
|
@ -25,9 +25,7 @@ function filerm_content(App $a) {
|
|||
file_tag_unsave_file(local_user(),$item_id,$term, $category);
|
||||
}
|
||||
|
||||
if (x($_SESSION,'return_url')) {
|
||||
goaway(System::baseUrl() . '/' . $_SESSION['return_url']);
|
||||
}
|
||||
//goaway('/network');
|
||||
|
||||
killme();
|
||||
}
|
||||
|
|
|
@ -20,12 +20,12 @@ function follow_post(App $a)
|
|||
}
|
||||
|
||||
if (isset($_REQUEST['cancel'])) {
|
||||
goaway($_SESSION['return_url']);
|
||||
goaway('contacts');
|
||||
}
|
||||
|
||||
$uid = local_user();
|
||||
$url = notags(trim($_REQUEST['url']));
|
||||
$return_url = $_SESSION['return_url'];
|
||||
$return_url = 'contacts';
|
||||
|
||||
// Makes the connection request for friendica contacts easier
|
||||
// This is just a precaution if maybe this page is called somewhere directly via POST
|
||||
|
@ -39,7 +39,7 @@ function follow_post(App $a)
|
|||
}
|
||||
goaway($return_url);
|
||||
} elseif ($result['cid']) {
|
||||
goaway(System::baseUrl() . '/contacts/' . $result['cid']);
|
||||
goaway('contacts/' . $result['cid']);
|
||||
}
|
||||
|
||||
info(L10n::t('The contact could not be added.'));
|
||||
|
@ -50,9 +50,11 @@ function follow_post(App $a)
|
|||
|
||||
function follow_content(App $a)
|
||||
{
|
||||
$return_url = 'contacts';
|
||||
|
||||
if (!local_user()) {
|
||||
notice(L10n::t('Permission denied.'));
|
||||
goaway($_SESSION['return_url']);
|
||||
goaway($return_url);
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
|
@ -116,7 +118,7 @@ function follow_content(App $a)
|
|||
|
||||
if (!$r) {
|
||||
notice(L10n::t('Permission denied.'));
|
||||
goaway($_SESSION['return_url']);
|
||||
goaway($return_url);
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ function fsuggest_post(App $a)
|
|||
|
||||
$hash = random_string();
|
||||
|
||||
$note = escape_tags(trim($_POST['note']));
|
||||
$note = escape_tags(trim(defaults($_POST, 'note', '')));
|
||||
|
||||
if ($new_contact) {
|
||||
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
|
|
|
@ -50,7 +50,7 @@ function hcard_init(App $a)
|
|||
|
||||
$a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . (($a->profile['net-publish']) ? 'true' : 'false') . '" />' . "\r\n" ;
|
||||
$a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/dfrn_poll/' . $which .'" />' . "\r\n" ;
|
||||
$uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . (($a->urlpath) ? '/' . $a->urlpath : ''));
|
||||
$uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->getHostName() . (($a->getURLPath()) ? '/' . $a->getURLPath() : ''));
|
||||
$a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . System::baseUrl() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
|
||||
header('Link: <' . System::baseUrl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
|
||||
|
||||
|
|
|
@ -36,12 +36,12 @@ function help_content(App $a)
|
|||
$path = '';
|
||||
// looping through the argv keys bigger than 0 to build
|
||||
// a path relative to /help
|
||||
for ($x = 1; $x < argc(); $x ++) {
|
||||
for ($x = 1; $x < $a->argc; $x ++) {
|
||||
if (strlen($path)) {
|
||||
$path .= '/';
|
||||
}
|
||||
|
||||
$path .= argv($x);
|
||||
$path .= $a->getArgumentValue($x);
|
||||
}
|
||||
$title = basename($path);
|
||||
$filename = $path;
|
||||
|
|
|
@ -38,8 +38,8 @@ function home_content(App $a) {
|
|||
$customhome = false;
|
||||
$defaultheader = '<h1>' . (Config::get('config', 'sitename') ? L10n::t('Welcome to %s', Config::get('config', 'sitename')) : '') . '</h1>';
|
||||
|
||||
$homefilepath = $a->basepath . "/home.html";
|
||||
$cssfilepath = $a->basepath . "/home.css";
|
||||
$homefilepath = $a->getBasePath() . "/home.html";
|
||||
$cssfilepath = $a->getBasePath() . "/home.css";
|
||||
if (file_exists($homefilepath)) {
|
||||
$customhome = $homefilepath;
|
||||
if (file_exists($cssfilepath)) {
|
||||
|
|
|
@ -23,7 +23,7 @@ function hostxrd_init(App $a)
|
|||
|
||||
$tpl = get_markup_template('xrd_host.tpl');
|
||||
echo replace_macros($tpl, [
|
||||
'$zhost' => $a->get_hostname(),
|
||||
'$zhost' => $a->getHostName(),
|
||||
'$zroot' => System::baseUrl(),
|
||||
'$domain' => System::baseUrl(),
|
||||
'$bigkey' => Salmon::salmonKey(Config::get('system', 'site_pubkey'))]
|
||||
|
|
|
@ -8,6 +8,7 @@ use Friendica\Core\Install;
|
|||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBStructure;
|
||||
use Friendica\Util\Temporal;
|
||||
|
||||
$install_wizard_pass = 1;
|
||||
|
@ -42,7 +43,6 @@ function install_post(App $a) {
|
|||
return;
|
||||
break; // just in case return don't return :)
|
||||
case 3:
|
||||
$urlpath = $a->get_path();
|
||||
$dbhost = notags(trim($_POST['dbhost']));
|
||||
$dbuser = notags(trim($_POST['dbuser']));
|
||||
$dbpass = notags(trim($_POST['dbpass']));
|
||||
|
@ -57,7 +57,7 @@ function install_post(App $a) {
|
|||
return;
|
||||
break;
|
||||
case 4:
|
||||
$urlpath = $a->get_path();
|
||||
$urlpath = $a->getURLPath();
|
||||
$dbhost = notags(trim($_POST['dbhost']));
|
||||
$dbuser = notags(trim($_POST['dbuser']));
|
||||
$dbpass = notags(trim($_POST['dbpass']));
|
||||
|
@ -70,14 +70,16 @@ function install_post(App $a) {
|
|||
// connect to db
|
||||
DBA::connect($dbhost, $dbuser, $dbpass, $dbdata);
|
||||
|
||||
$errors = Install::createConfig($urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $phpath, $timezone, $language, $adminmail);
|
||||
$install = new Install();
|
||||
|
||||
if ($errors) {
|
||||
$a->data['db_failed'] = $errors;
|
||||
$errors = $install->createConfig($phpath, $urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $timezone, $language, $adminmail, $a->getBasePath());
|
||||
|
||||
if ($errors !== true) {
|
||||
$a->data['data'] = $errors;
|
||||
return;
|
||||
}
|
||||
|
||||
$errors = Install::installDatabaseStructure();
|
||||
$errors = DBStructure::update(false, true, true);
|
||||
|
||||
if ($errors) {
|
||||
$a->data['db_failed'] = $errors;
|
||||
|
@ -97,8 +99,6 @@ function install_content(App $a) {
|
|||
$wizard_status = "";
|
||||
$install_title = L10n::t('Friendica Communications Server - Setup');
|
||||
|
||||
|
||||
|
||||
if (x($a->data, 'db_conn_failed')) {
|
||||
$install_wizard_pass = 2;
|
||||
$wizard_status = L10n::t('Could not connect to database.');
|
||||
|
@ -125,13 +125,8 @@ function install_content(App $a) {
|
|||
if (DBA::$connected) {
|
||||
$r = q("SELECT COUNT(*) as `total` FROM `user`");
|
||||
if (DBA::isResult($r) && $r[0]['total']) {
|
||||
$tpl = get_markup_template('install.tpl');
|
||||
return replace_macros($tpl, [
|
||||
'$title' => $install_title,
|
||||
'$pass' => '',
|
||||
'$status' => L10n::t('Database already in use.'),
|
||||
'$text' => '',
|
||||
]);
|
||||
$install_wizard_pass = 2;
|
||||
$wizard_status = L10n::t('Database already in use.');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,19 +148,21 @@ function install_content(App $a) {
|
|||
|
||||
$phpath = defaults($_POST, 'phpath', 'php');
|
||||
|
||||
list($checks, $checkspassed) = Install::check($phpath);
|
||||
$install = new Install($phpath);
|
||||
|
||||
$status = $install->checkAll($a->getBasePath(), $a->getBaseURL());
|
||||
|
||||
$tpl = get_markup_template('install_checks.tpl');
|
||||
$o .= replace_macros($tpl, [
|
||||
'$title' => $install_title,
|
||||
'$pass' => L10n::t('System check'),
|
||||
'$checks' => $checks,
|
||||
'$passed' => $checkspassed,
|
||||
'$checks' => $install->getChecks(),
|
||||
'$passed' => $status,
|
||||
'$see_install' => L10n::t('Please see the file "INSTALL.txt".'),
|
||||
'$next' => L10n::t('Next'),
|
||||
'$reload' => L10n::t('Check again'),
|
||||
'$phpath' => $phpath,
|
||||
'$baseurl' => System::baseUrl(),
|
||||
'$baseurl' => $a->getBaseURL(),
|
||||
]);
|
||||
return $o;
|
||||
}; break;
|
||||
|
@ -197,7 +194,7 @@ function install_content(App $a) {
|
|||
|
||||
'$lbl_10' => L10n::t('Please select a default timezone for your website'),
|
||||
|
||||
'$baseurl' => System::baseUrl(),
|
||||
'$baseurl' => $a->getBaseURL(),
|
||||
|
||||
'$phpath' => $phpath,
|
||||
|
||||
|
@ -235,9 +232,7 @@ function install_content(App $a) {
|
|||
|
||||
'$timezone' => Temporal::getTimezoneField('timezone', L10n::t('Please select a default timezone for your website'), $timezone, ''),
|
||||
'$language' => ['language', L10n::t('System Language:'), 'en', L10n::t('Set the default language for your Friendica installation interface and to send emails.'), $lang_choices],
|
||||
'$baseurl' => System::baseUrl(),
|
||||
|
||||
|
||||
'$baseurl' => $a->getBaseURL(),
|
||||
|
||||
'$submit' => L10n::t('Submit'),
|
||||
|
||||
|
|
30
mod/item.php
30
mod/item.php
|
@ -159,7 +159,7 @@ function item_post(App $a) {
|
|||
}
|
||||
|
||||
// Allow commenting if it is an answer to a public post
|
||||
$allow_comment = local_user() && ($profile_uid == 0) && $parent && in_array($parent_item['network'], [Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN]);
|
||||
$allow_comment = local_user() && ($profile_uid == 0) && $parent && in_array($parent_item['network'], [Protocol::ACTIVITYPUB, Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN]);
|
||||
|
||||
// Now check that valid personal details have been provided
|
||||
if (!can_write_wall($profile_uid) && !$allow_comment) {
|
||||
|
@ -240,7 +240,7 @@ function item_post(App $a) {
|
|||
$emailcc = notags(trim(defaults($_REQUEST, 'emailcc' , '')));
|
||||
$body = escape_tags(trim(defaults($_REQUEST, 'body' , '')));
|
||||
$network = notags(trim(defaults($_REQUEST, 'network' , Protocol::DFRN)));
|
||||
$guid = System::createGUID(32);
|
||||
$guid = System::createUUID();
|
||||
|
||||
$postopts = defaults($_REQUEST, 'postopts', '');
|
||||
|
||||
|
@ -343,20 +343,11 @@ function item_post(App $a) {
|
|||
|
||||
$tags = get_tags($body);
|
||||
|
||||
// Add a tag if the parent contact is from OStatus (This will notify them during delivery)
|
||||
if ($parent) {
|
||||
if ($thr_parent_contact['network'] == Protocol::OSTATUS) {
|
||||
$contact = '@[url=' . $thr_parent_contact['url'] . ']' . $thr_parent_contact['nick'] . '[/url]';
|
||||
if (!stripos(implode($tags), '[url=' . $thr_parent_contact['url'] . ']')) {
|
||||
$tags[] = $contact;
|
||||
}
|
||||
}
|
||||
|
||||
if ($parent_contact['network'] == Protocol::OSTATUS) {
|
||||
$contact = '@[url=' . $parent_contact['url'] . ']' . $parent_contact['nick'] . '[/url]';
|
||||
if (!stripos(implode($tags), '[url=' . $parent_contact['url'] . ']')) {
|
||||
$tags[] = $contact;
|
||||
}
|
||||
// Add a tag if the parent contact is from ActivityPub or OStatus (This will notify them)
|
||||
if ($parent && in_array($thr_parent_contact['network'], [Protocol::OSTATUS, Protocol::ACTIVITYPUB])) {
|
||||
$contact = '@[url=' . $thr_parent_contact['url'] . ']' . $thr_parent_contact['nick'] . '[/url]';
|
||||
if (!stripos(implode($tags), '[url=' . $thr_parent_contact['url'] . ']')) {
|
||||
$tags[] = $contact;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -885,13 +876,13 @@ function item_content(App $a)
|
|||
$o = '';
|
||||
|
||||
if (($a->argc == 3) && ($a->argv[1] === 'drop') && intval($a->argv[2])) {
|
||||
if (is_ajax()) {
|
||||
if ($a->isAjax()) {
|
||||
$o = Item::deleteForUser(['id' => $a->argv[2]], local_user());
|
||||
} else {
|
||||
$o = drop_item($a->argv[2]);
|
||||
}
|
||||
|
||||
if (is_ajax()) {
|
||||
if ($a->isAjax()) {
|
||||
// ajax return: [<item id>, 0 (no perm) | <owner id>]
|
||||
echo json_encode([intval($a->argv[2]), intval($o)]);
|
||||
killme();
|
||||
|
@ -1026,8 +1017,7 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n
|
|||
$alias = $contact["alias"];
|
||||
$newname = $contact["nick"];
|
||||
|
||||
if (($newname == "") || (($contact["network"] != Protocol::OSTATUS) && ($contact["network"] != Protocol::TWITTER)
|
||||
&& ($contact["network"] != Protocol::STATUSNET))) {
|
||||
if (($newname == "") || !in_array($contact["network"], [Protocol::ACTIVITYPUB, Protocol::OSTATUS, Protocol::TWITTER, Protocol::STATUSNET])) {
|
||||
$newname = $contact["name"];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,16 +59,16 @@ function match_content(App $a)
|
|||
}
|
||||
|
||||
if (strlen(Config::get('system', 'directory'))) {
|
||||
$x = Network::post(get_server().'/msearch', $params);
|
||||
$x = Network::post(get_server().'/msearch', $params)->getBody();
|
||||
} else {
|
||||
$x = Network::post(System::baseUrl() . '/msearch', $params);
|
||||
$x = Network::post(System::baseUrl() . '/msearch', $params)->getBody();
|
||||
}
|
||||
|
||||
$j = json_decode($x);
|
||||
|
||||
if ($j->total) {
|
||||
$a->set_pager_total($j->total);
|
||||
$a->set_pager_itemspage($j->items_page);
|
||||
$a->setPagerTotal($j->total);
|
||||
$a->setPagerItemsPage($j->items_page);
|
||||
}
|
||||
|
||||
if (count($j->results)) {
|
||||
|
|
|
@ -16,6 +16,7 @@ use Friendica\Model\Mail;
|
|||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Proxy as ProxyUtils;
|
||||
use Friendica\Util\Temporal;
|
||||
use Friendica\Module\Login;
|
||||
|
||||
require_once 'include/conversation.php';
|
||||
|
||||
|
@ -46,12 +47,6 @@ function message_init(App $a)
|
|||
'$baseurl' => System::baseUrl(true),
|
||||
'$base' => $base
|
||||
]);
|
||||
|
||||
$end_tpl = get_markup_template('message-end.tpl');
|
||||
$a->page['end'] .= replace_macros($end_tpl, [
|
||||
'$baseurl' => System::baseUrl(true),
|
||||
'$base' => $base
|
||||
]);
|
||||
}
|
||||
|
||||
function message_post(App $a)
|
||||
|
@ -103,7 +98,7 @@ function message_content(App $a)
|
|||
|
||||
if (!local_user()) {
|
||||
notice(L10n::t('Permission denied.') . EOL);
|
||||
return;
|
||||
return Login::form();
|
||||
}
|
||||
|
||||
$myprofile = System::baseUrl() . '/profile/' . $a->user['nickname'];
|
||||
|
@ -160,17 +155,28 @@ function message_content(App $a)
|
|||
|
||||
// Now check how the user responded to the confirmation query
|
||||
if (!empty($_REQUEST['canceled'])) {
|
||||
goaway($_SESSION['return_url']);
|
||||
goaway('/message');
|
||||
}
|
||||
|
||||
$cmd = $a->argv[1];
|
||||
if ($cmd === 'drop') {
|
||||
$message = DBA::selectFirst('mail', ['convid'], ['id' => $a->argv[2], 'uid' => local_user()]);
|
||||
if(!DBA::isResult($message)){
|
||||
info(L10n::t('Conversation not found.') . EOL);
|
||||
goaway('/message');
|
||||
}
|
||||
|
||||
if (DBA::delete('mail', ['id' => $a->argv[2], 'uid' => local_user()])) {
|
||||
info(L10n::t('Message deleted.') . EOL);
|
||||
}
|
||||
|
||||
//goaway(System::baseUrl(true) . '/message' );
|
||||
goaway($_SESSION['return_url']);
|
||||
$conversation = DBA::selectFirst('mail', ['id'], ['convid' => $message['convid'], 'uid' => local_user()]);
|
||||
if(!DBA::isResult($conversation)){
|
||||
info(L10n::t('Conversation removed.') . EOL);
|
||||
goaway('/message');
|
||||
}
|
||||
|
||||
goaway('/message/' . $conversation['id'] );
|
||||
} else {
|
||||
$r = q("SELECT `parent-uri`,`convid` FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
intval($a->argv[2]),
|
||||
|
@ -184,8 +190,7 @@ function message_content(App $a)
|
|||
info(L10n::t('Conversation removed.') . EOL);
|
||||
}
|
||||
}
|
||||
//goaway(System::baseUrl(true) . '/message' );
|
||||
goaway($_SESSION['return_url']);
|
||||
goaway('/message' );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,13 +204,6 @@ function message_content(App $a)
|
|||
'$linkurl' => L10n::t('Please enter a link URL:')
|
||||
]);
|
||||
|
||||
$tpl = get_markup_template('msg-end.tpl');
|
||||
$a->page['end'] .= replace_macros($tpl, [
|
||||
'$baseurl' => System::baseUrl(true),
|
||||
'$nickname' => $a->user['nickname'],
|
||||
'$linkurl' => L10n::t('Please enter a link URL:')
|
||||
]);
|
||||
|
||||
$preselect = isset($a->argv[2]) ? [$a->argv[2]] : [];
|
||||
|
||||
$prename = $preurl = $preid = '';
|
||||
|
@ -281,7 +279,7 @@ function message_content(App $a)
|
|||
);
|
||||
|
||||
if (DBA::isResult($r)) {
|
||||
$a->set_pager_total($r[0]['total']);
|
||||
$a->setPagerTotal($r[0]['total']);
|
||||
}
|
||||
|
||||
$r = get_messages(local_user(), $a->pager['start'], $a->pager['itemspage']);
|
||||
|
@ -344,13 +342,6 @@ function message_content(App $a)
|
|||
'$linkurl' => L10n::t('Please enter a link URL:')
|
||||
]);
|
||||
|
||||
$tpl = get_markup_template('msg-end.tpl');
|
||||
$a->page['end'] .= replace_macros($tpl, [
|
||||
'$baseurl' => System::baseUrl(true),
|
||||
'$nickname' => $a->user['nickname'],
|
||||
'$linkurl' => L10n::t('Please enter a link URL:')
|
||||
]);
|
||||
|
||||
$mails = [];
|
||||
$seen = 0;
|
||||
$unknown = false;
|
||||
|
|
|
@ -302,7 +302,7 @@ function networkPager($a, $update)
|
|||
$itemspage_network = $a->force_max_items;
|
||||
}
|
||||
|
||||
$a->set_pager_itemspage($itemspage_network);
|
||||
$a->setPagerItemsPage($itemspage_network);
|
||||
|
||||
return sprintf(" LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
|
||||
}
|
||||
|
@ -721,7 +721,7 @@ function networkThreadedView(App $a, $update, $parent)
|
|||
if ($last_received != '') {
|
||||
$last_date = $last_received;
|
||||
$sql_range .= sprintf(" AND $sql_table.`received` < '%s'", DBA::escape($last_received));
|
||||
$a->set_pager_page(1);
|
||||
$a->setPagerPage(1);
|
||||
$pager_sql = sprintf(" LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
|
||||
}
|
||||
break;
|
||||
|
@ -729,7 +729,7 @@ function networkThreadedView(App $a, $update, $parent)
|
|||
if ($last_commented != '') {
|
||||
$last_date = $last_commented;
|
||||
$sql_range .= sprintf(" AND $sql_table.`commented` < '%s'", DBA::escape($last_commented));
|
||||
$a->set_pager_page(1);
|
||||
$a->setPagerPage(1);
|
||||
$pager_sql = sprintf(" LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
|
||||
}
|
||||
break;
|
||||
|
@ -737,14 +737,14 @@ function networkThreadedView(App $a, $update, $parent)
|
|||
if ($last_created != '') {
|
||||
$last_date = $last_created;
|
||||
$sql_range .= sprintf(" AND $sql_table.`created` < '%s'", DBA::escape($last_created));
|
||||
$a->set_pager_page(1);
|
||||
$a->setPagerPage(1);
|
||||
$pager_sql = sprintf(" LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
|
||||
}
|
||||
break;
|
||||
case 'id':
|
||||
if (($last_id > 0) && ($sql_table == '`thread`')) {
|
||||
$sql_range .= sprintf(" AND $sql_table.`iid` < '%s'", DBA::escape($last_id));
|
||||
$a->set_pager_page(1);
|
||||
$a->setPagerPage(1);
|
||||
$pager_sql = sprintf(" LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
|
||||
}
|
||||
break;
|
||||
|
@ -810,7 +810,7 @@ function networkThreadedView(App $a, $update, $parent)
|
|||
}
|
||||
|
||||
// Only show it when unfiltered (no groups, no networks, ...)
|
||||
if (in_array($nets, ['', Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]) && (strlen($sql_extra . $sql_extra2 . $sql_extra3) == 0)) {
|
||||
if (in_array($nets, ['', Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]) && (strlen($sql_extra . $sql_extra2 . $sql_extra3) == 0)) {
|
||||
if (DBA::isResult($r)) {
|
||||
$top_limit = current($r)['order_date'];
|
||||
$bottom_limit = end($r)['order_date'];
|
||||
|
|
|
@ -215,7 +215,7 @@ function nodeinfo_cron() {
|
|||
logger('local_comments: ' . $local_comments, LOGGER_DEBUG);
|
||||
|
||||
// Now trying to register
|
||||
$url = 'http://the-federation.info/register/'.$a->get_hostname();
|
||||
$url = 'http://the-federation.info/register/'.$a->getHostName();
|
||||
logger('registering url: '.$url, LOGGER_DEBUG);
|
||||
$ret = Network::fetchUrl($url);
|
||||
logger('registering answer: '.$ret, LOGGER_DEBUG);
|
||||
|
|
|
@ -61,7 +61,7 @@ function notes_content(App $a, $update = false)
|
|||
$condition = ['uid' => local_user(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => GRAVITY_PARENT,
|
||||
'wall' => false, 'contact-id'=> $a->contact['id']];
|
||||
|
||||
$a->set_pager_itemspage(40);
|
||||
$a->setPagerItemsPage(40);
|
||||
|
||||
$params = ['order' => ['created' => true],
|
||||
'limit' => [$a->pager['start'], $a->pager['itemspage']]];
|
||||
|
|
|
@ -12,6 +12,7 @@ use Friendica\Core\NotificationsManager;
|
|||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Module\Login;
|
||||
|
||||
function notifications_post(App $a)
|
||||
{
|
||||
|
@ -65,7 +66,7 @@ function notifications_content(App $a)
|
|||
{
|
||||
if (!local_user()) {
|
||||
notice(L10n::t('Permission denied.') . EOL);
|
||||
return;
|
||||
return Login::form();
|
||||
}
|
||||
|
||||
$page = defaults($_REQUEST, 'page', 1);
|
||||
|
@ -119,7 +120,7 @@ function notifications_content(App $a)
|
|||
}
|
||||
|
||||
// Set the pager
|
||||
$a->set_pager_itemspage($perpage);
|
||||
$a->setPagerItemsPage($perpage);
|
||||
|
||||
// Add additional informations (needed for json output)
|
||||
$notifs['items_page'] = $a->pager['itemspage'];
|
||||
|
|
|
@ -27,7 +27,7 @@ function notify_init(App $a)
|
|||
$nm->setSeen($note);
|
||||
|
||||
// The friendica client has problems with the GUID. this is some workaround
|
||||
if ($a->is_friendica_app()) {
|
||||
if ($a->isFriendicaApp()) {
|
||||
require_once("include/items.php");
|
||||
$urldata = parse_url($note['link']);
|
||||
$guid = basename($urldata["path"]);
|
||||
|
|
|
@ -19,7 +19,7 @@ function openid_content(App $a) {
|
|||
|
||||
if((x($_GET,'openid_mode')) && (x($_SESSION,'openid'))) {
|
||||
|
||||
$openid = new LightOpenID($a->get_hostname());
|
||||
$openid = new LightOpenID($a->getHostName());
|
||||
|
||||
if($openid->validate()) {
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ function opensearch_content(App $a) {
|
|||
|
||||
$o = replace_macros($tpl, [
|
||||
'$baseurl' => System::baseUrl(),
|
||||
'$nodename' => $a->get_hostname(),
|
||||
'$nodename' => $a->getHostName(),
|
||||
]);
|
||||
|
||||
echo $o;
|
||||
|
|
|
@ -15,7 +15,7 @@ function ostatus_subscribe_content(App $a) {
|
|||
|
||||
if (! local_user()) {
|
||||
notice(L10n::t('Permission denied.') . EOL);
|
||||
goaway($_SESSION['return_url']);
|
||||
goaway('/ostatus_subscribe');
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
|
@ -44,14 +44,14 @@ function ostatus_subscribe_content(App $a) {
|
|||
$api = $contact["baseurl"]."/api/";
|
||||
|
||||
// Fetching friends
|
||||
$data = Network::curl($api."statuses/friends.json?screen_name=".$contact["nick"]);
|
||||
$curlResult = Network::curl($api."statuses/friends.json?screen_name=".$contact["nick"]);
|
||||
|
||||
if (!$data["success"]) {
|
||||
if (!$curlResult->isSuccess()) {
|
||||
PConfig::delete($uid, "ostatus", "legacy_contact");
|
||||
return $o.L10n::t("Couldn't fetch friends for contact.");
|
||||
}
|
||||
|
||||
PConfig::set($uid, "ostatus", "legacy_friends", $data["body"]);
|
||||
PConfig::set($uid, "ostatus", "legacy_friends", $curlResult->getBody());
|
||||
}
|
||||
|
||||
$friends = json_decode(PConfig::get($uid, "ostatus", "legacy_friends"));
|
||||
|
@ -72,8 +72,8 @@ function ostatus_subscribe_content(App $a) {
|
|||
|
||||
$o .= "<p>".$counter."/".$total.": ".$url;
|
||||
|
||||
$data = Probe::uri($url);
|
||||
if ($data["network"] == Protocol::OSTATUS) {
|
||||
$curlResult = Probe::uri($url);
|
||||
if ($curlResult["network"] == Protocol::OSTATUS) {
|
||||
$result = Contact::createFromProbe($uid, $url, true, Protocol::OSTATUS);
|
||||
if ($result["success"]) {
|
||||
$o .= " - ".L10n::t("success");
|
||||
|
|
|
@ -60,12 +60,12 @@ function parse_url_content(App $a)
|
|||
// the URL with the corresponding BBCode media tag
|
||||
$redirects = 0;
|
||||
// Fetch the header of the URL
|
||||
$result = Network::curl($url, false, $redirects, ['novalidate' => true, 'nobody' => true]);
|
||||
$curlResponse = Network::curl($url, false, $redirects, ['novalidate' => true, 'nobody' => true]);
|
||||
|
||||
if ($result['success']) {
|
||||
if ($curlResponse->isSuccess()) {
|
||||
// Convert the header fields into an array
|
||||
$hdrs = [];
|
||||
$h = explode("\n", $result['header']);
|
||||
$h = explode("\n", $curlResponse->getHeader());
|
||||
foreach ($h as $l) {
|
||||
$header = array_map('trim', explode(':', trim($l), 2));
|
||||
if (count($header) == 2) {
|
||||
|
|
|
@ -192,7 +192,7 @@ function photo_init(App $a)
|
|||
// If the photo is public and there is an existing photo directory store the photo there
|
||||
if ($public and $file != '') {
|
||||
// If the photo path isn't there, try to create it
|
||||
$basepath = $a->get_basepath();
|
||||
$basepath = $a->getBasePath();
|
||||
if (!is_dir($basepath . "/photo")) {
|
||||
if (is_writable($basepath)) {
|
||||
mkdir($basepath . "/photo");
|
||||
|
|
|
@ -472,7 +472,7 @@ function photos_post(App $a)
|
|||
$uri = Item::newURI($page_owner_uid);
|
||||
|
||||
$arr = [];
|
||||
$arr['guid'] = System::createGUID(32);
|
||||
$arr['guid'] = System::createUUID();
|
||||
$arr['uid'] = $page_owner_uid;
|
||||
$arr['uri'] = $uri;
|
||||
$arr['parent-uri'] = $uri;
|
||||
|
@ -651,7 +651,7 @@ function photos_post(App $a)
|
|||
$uri = Item::newURI($page_owner_uid);
|
||||
|
||||
$arr = [];
|
||||
$arr['guid'] = System::createGUID(32);
|
||||
$arr['guid'] = System::createUUID();
|
||||
$arr['uid'] = $page_owner_uid;
|
||||
$arr['uri'] = $uri;
|
||||
$arr['parent-uri'] = $uri;
|
||||
|
@ -889,7 +889,7 @@ function photos_post(App $a)
|
|||
$arr['coord'] = $lat . ' ' . $lon;
|
||||
}
|
||||
|
||||
$arr['guid'] = System::createGUID(32);
|
||||
$arr['guid'] = System::createUUID();
|
||||
$arr['uid'] = $page_owner_uid;
|
||||
$arr['uri'] = $uri;
|
||||
$arr['parent-uri'] = $uri;
|
||||
|
@ -1143,8 +1143,8 @@ function photos_content(App $a)
|
|||
DBA::escape($album)
|
||||
);
|
||||
if (DBA::isResult($r)) {
|
||||
$a->set_pager_total(count($r));
|
||||
$a->set_pager_itemspage(20);
|
||||
$a->setPagerTotal(count($r));
|
||||
$a->setPagerItemsPage(20);
|
||||
}
|
||||
|
||||
/// @TODO I have seen this many times, maybe generalize it script-wide and encapsulate it?
|
||||
|
@ -1393,7 +1393,7 @@ function photos_content(App $a)
|
|||
$link_item = Item::selectFirst([], ['id' => $linked_items[0]['id']]);
|
||||
|
||||
$condition = ["`parent` = ? AND `parent` != `id`", $link_item['parent']];
|
||||
$a->set_pager_total(DBA::count('item', $condition));
|
||||
$a->setPagerTotal(DBA::count('item', $condition));
|
||||
|
||||
$params = ['order' => ['id'], 'limit' => [$a->pager['start'], $a->pager['itemspage']]];
|
||||
$result = Item::selectForUser($link_item['uid'], Item::ITEM_FIELDLIST, $condition, $params);
|
||||
|
@ -1655,8 +1655,8 @@ function photos_content(App $a)
|
|||
);
|
||||
|
||||
if (DBA::isResult($r)) {
|
||||
$a->set_pager_total(count($r));
|
||||
$a->set_pager_itemspage(20);
|
||||
$a->setPagerTotal(count($r));
|
||||
$a->setPagerItemsPage(20);
|
||||
}
|
||||
|
||||
$r = q("SELECT `resource-id`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`filename`) AS `filename`,
|
||||
|
|
|
@ -350,7 +350,7 @@ function ping_init(App $a)
|
|||
$regularnotifications = (!empty($_GET['uid']) && !empty($_GET['_']));
|
||||
|
||||
foreach ($notifs as $notif) {
|
||||
if ($a->is_friendica_app() || !$regularnotifications) {
|
||||
if ($a->isFriendicaApp() || !$regularnotifications) {
|
||||
$notif['message'] = str_replace("{0}", $notif['name'], $notif['message']);
|
||||
}
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ function poke_init(App $a)
|
|||
|
||||
$arr = [];
|
||||
|
||||
$arr['guid'] = System::createGUID(32);
|
||||
$arr['guid'] = System::createUUID();
|
||||
$arr['uid'] = $uid;
|
||||
$arr['uri'] = $uri;
|
||||
$arr['parent-uri'] = (!empty($parent_uri) ? $parent_uri : $uri);
|
||||
|
|
|
@ -20,6 +20,7 @@ use Friendica\Model\Profile;
|
|||
use Friendica\Module\Login;
|
||||
use Friendica\Protocol\DFRN;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
|
||||
function profile_init(App $a)
|
||||
{
|
||||
|
@ -49,6 +50,16 @@ function profile_init(App $a)
|
|||
DFRN::autoRedir($a, $which);
|
||||
}
|
||||
|
||||
if (ActivityPub::isRequest()) {
|
||||
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $which]);
|
||||
if (DBA::isResult($user)) {
|
||||
$data = ActivityPub\Transmitter::getProfile($user['uid']);
|
||||
echo json_encode($data);
|
||||
header('Content-Type: application/activity+json');
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
Profile::load($a, $which, $profile);
|
||||
|
||||
$blocked = !local_user() && !remote_user() && Config::get('system', 'block_public');
|
||||
|
@ -80,7 +91,7 @@ function profile_init(App $a)
|
|||
$a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/feed/' . $which . '/" title="' . L10n::t('%s\'s posts', $a->profile['username']) . '"/>' . "\r\n";
|
||||
$a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/feed/' . $which . '/comments" title="' . L10n::t('%s\'s comments', $a->profile['username']) . '"/>' . "\r\n";
|
||||
$a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/feed/' . $which . '/activity" title="' . L10n::t('%s\'s timeline', $a->profile['username']) . '"/>' . "\r\n";
|
||||
$uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . ($a->urlpath ? '/' . $a->urlpath : ''));
|
||||
$uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->getHostName() . ($a->getURLPath() ? '/' . $a->getURLPath() : ''));
|
||||
$a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . System::baseUrl() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
|
||||
header('Link: <' . System::baseUrl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
|
||||
|
||||
|
@ -296,7 +307,7 @@ function profile_content(App $a, $update = 0)
|
|||
$itemspage_network = $a->force_max_items;
|
||||
}
|
||||
|
||||
$a->set_pager_itemspage($itemspage_network);
|
||||
$a->setPagerItemsPage($itemspage_network);
|
||||
|
||||
$pager_sql = sprintf(" LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
|
||||
|
||||
|
|
|
@ -317,7 +317,6 @@ function profile_photo_crop_ui_head(App $a, Image $image)
|
|||
}
|
||||
|
||||
$a->page['htmlhead'] .= replace_macros(get_markup_template("crophead.tpl"), []);
|
||||
$a->page['end'] .= replace_macros(get_markup_template("cropend.tpl"), []);
|
||||
|
||||
$imagecrop = [
|
||||
'hash' => $hash,
|
||||
|
|
|
@ -20,6 +20,7 @@ use Friendica\Model\Profile;
|
|||
use Friendica\Network\Probe;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Temporal;
|
||||
use Friendica\Module\Login;
|
||||
|
||||
function profiles_init(App $a) {
|
||||
|
||||
|
@ -509,7 +510,7 @@ function profiles_content(App $a) {
|
|||
|
||||
if (! local_user()) {
|
||||
notice(L10n::t('Permission denied.') . EOL);
|
||||
return;
|
||||
return Login::form();
|
||||
}
|
||||
|
||||
$o = '';
|
||||
|
@ -527,9 +528,6 @@ function profiles_content(App $a) {
|
|||
$a->page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), [
|
||||
'$baseurl' => System::baseUrl(true),
|
||||
]);
|
||||
$a->page['end'] .= replace_macros(get_markup_template('profed_end.tpl'), [
|
||||
'$baseurl' => System::baseUrl(true),
|
||||
]);
|
||||
|
||||
$opt_tpl = get_markup_template("profile-hide-friends.tpl");
|
||||
$hide_friends = replace_macros($opt_tpl,[
|
||||
|
@ -618,10 +616,10 @@ function profiles_content(App $a) {
|
|||
'$country_name' => ['country_name', L10n::t('Country:'), $r[0]['country-name']],
|
||||
'$age' => ((intval($r[0]['dob'])) ? '(' . L10n::t('Age: ') . Temporal::getAgeByTimezone($r[0]['dob'],$a->user['timezone'],$a->user['timezone']) . ')' : ''),
|
||||
'$gender' => ContactSelector::gender($r[0]['gender']),
|
||||
'$marital' => ContactSelector::maritalStatus($r[0]['marital']),
|
||||
'$marital' => ['selector' => ContactSelector::maritalStatus($r[0]['marital']), 'value' => $r[0]['marital']],
|
||||
'$with' => ['with', L10n::t("Who: \x28if applicable\x29"), strip_tags($r[0]['with']), L10n::t('Examples: cathy123, Cathy Williams, cathy@example.com')],
|
||||
'$howlong' => ['howlong', L10n::t('Since [date]:'), ($r[0]['howlong'] <= NULL_DATE ? '' : DateTimeFormat::local($r[0]['howlong']))],
|
||||
'$sexual' => ContactSelector::sexualPreference($r[0]['sexual']),
|
||||
'$sexual' => ['selector' => ContactSelector::sexualPreference($r[0]['sexual']), 'value' => $r[0]['sexual']],
|
||||
'$about' => ['about', L10n::t('Tell us about yourself...'), $r[0]['about']],
|
||||
'$xmpp' => ['xmpp', L10n::t("XMPP \x28Jabber\x29 address:"), $r[0]['xmpp'], L10n::t("The XMPP address will be propagated to your contacts so that they can follow you.")],
|
||||
'$homepage' => ['homepage', L10n::t('Homepage URL:'), $r[0]['homepage']],
|
||||
|
@ -669,7 +667,7 @@ function profiles_content(App $a) {
|
|||
$profiles = '';
|
||||
foreach ($r as $rr) {
|
||||
$profiles .= replace_macros($tpl, [
|
||||
'$photo' => $a->remove_baseurl($rr['thumb']),
|
||||
'$photo' => $a->removeBaseURL($rr['thumb']),
|
||||
'$id' => $rr['id'],
|
||||
'$alt' => L10n::t('Profile Image'),
|
||||
'$profile_name' => $rr['profile-name'],
|
||||
|
|
|
@ -104,8 +104,9 @@ function pubsubhubbub_init(App $a) {
|
|||
// we don't actually enforce the lease time because GNU
|
||||
// Social/StatusNet doesn't honour it (yet)
|
||||
|
||||
$body = Network::fetchUrl($hub_callback . "?" . $params);
|
||||
$ret = $a->get_curl_code();
|
||||
$fetchResult = Network::fetchUrlFull($hub_callback . "?" . $params);
|
||||
$body = $fetchResult->getBody();
|
||||
$ret = $fetchResult->getReturnCode();
|
||||
|
||||
// give up if the HTTP return code wasn't a success (2xx)
|
||||
if ($ret < 200 || $ret > 299) {
|
||||
|
|
|
@ -57,7 +57,7 @@ function redir_init(App $a) {
|
|||
}
|
||||
|
||||
if (remote_user()) {
|
||||
$host = substr(System::baseUrl() . ($a->urlpath ? '/' . $a->urlpath : ''), strpos(System::baseUrl(), '://') + 3);
|
||||
$host = substr(System::baseUrl() . ($a->getURLPath() ? '/' . $a->getURLPath() : ''), strpos(System::baseUrl(), '://') + 3);
|
||||
$remotehost = substr($contact['addr'], strpos($contact['addr'], '@') + 1);
|
||||
|
||||
// On a local instance we have to check if the local user has already authenticated
|
||||
|
|
|
@ -274,7 +274,7 @@ function register_content(App $a)
|
|||
'$passwords' => $passwords,
|
||||
'$password1' => ['password1', L10n::t('New Password:'), '', L10n::t('Leave empty for an auto generated password.')],
|
||||
'$password2' => ['confirm', L10n::t('Confirm:'), '', ''],
|
||||
'$nickdesc' => L10n::t('Choose a profile nickname. This must begin with a text character. Your profile address on this site will then be \'<strong>nickname@%s</strong>\'.', $a->get_hostname()),
|
||||
'$nickdesc' => L10n::t('Choose a profile nickname. This must begin with a text character. Your profile address on this site will then be \'<strong>nickname@%s</strong>\'.', $a->getHostName()),
|
||||
'$nicklabel' => L10n::t('Choose a nickname: '),
|
||||
'$photo' => $photo,
|
||||
'$publish' => $profile_publish,
|
||||
|
@ -283,7 +283,7 @@ function register_content(App $a)
|
|||
'$email' => $email,
|
||||
'$nickname' => $nickname,
|
||||
'$license' => $license,
|
||||
'$sitename' => $a->get_hostname(),
|
||||
'$sitename' => $a->getHostName(),
|
||||
'$importh' => L10n::t('Import'),
|
||||
'$importt' => L10n::t('Import your profile to this friendica instance'),
|
||||
'$showtoslink' => Config::get('system', 'tosdisplay'),
|
||||
|
|
|
@ -14,7 +14,7 @@ function repair_ostatus_content(App $a) {
|
|||
|
||||
if (! local_user()) {
|
||||
notice(L10n::t('Permission denied.') . EOL);
|
||||
goaway($_SESSION['return_url']);
|
||||
goaway('/ostatus_repair');
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ use Friendica\Model\User;
|
|||
use Friendica\Protocol\Email;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Temporal;
|
||||
use Friendica\Module\Login;
|
||||
|
||||
function get_theme_config_file($theme)
|
||||
{
|
||||
|
@ -546,7 +547,7 @@ function settings_post(App $a)
|
|||
if ($openid != $a->user['openid'] || (strlen($openid) && (!strlen($openidserver)))) {
|
||||
if (Network::isUrlValid($openid)) {
|
||||
logger('updating openidserver');
|
||||
$open_id_obj = new LightOpenID($a->get_hostname());
|
||||
$open_id_obj = new LightOpenID($a->getHostName());
|
||||
$open_id_obj->identity = $openid;
|
||||
$openidserver = $open_id_obj->discover($open_id_obj->identity);
|
||||
} else {
|
||||
|
@ -658,7 +659,7 @@ function settings_content(App $a)
|
|||
|
||||
if (!local_user()) {
|
||||
//notice(L10n::t('Permission denied.') . EOL);
|
||||
return;
|
||||
return Login::form();
|
||||
}
|
||||
|
||||
if (x($_SESSION, 'submanage') && intval($_SESSION['submanage'])) {
|
||||
|
@ -982,11 +983,6 @@ function settings_content(App $a)
|
|||
'$theme_config' => $theme_config,
|
||||
]);
|
||||
|
||||
$tpl = get_markup_template('settings/display_end.tpl');
|
||||
$a->page['end'] .= replace_macros($tpl, [
|
||||
'$theme' => ['theme', L10n::t('Display Theme:'), $theme_selected, '', $themes]
|
||||
]);
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
|
@ -1140,8 +1136,8 @@ function settings_content(App $a)
|
|||
$tpl_addr = get_markup_template('settings/nick_set.tpl');
|
||||
|
||||
$prof_addr = replace_macros($tpl_addr,[
|
||||
'$desc' => L10n::t("Your Identity Address is <strong>'%s'</strong> or '%s'.", $nickname . '@' . $a->get_hostname() . $a->get_path(), System::baseUrl() . '/profile/' . $nickname),
|
||||
'$basepath' => $a->get_hostname()
|
||||
'$desc' => L10n::t("Your Identity Address is <strong>'%s'</strong> or '%s'.", $nickname . '@' . $a->getHostName() . $a->getURLPath(), System::baseUrl() . '/profile/' . $nickname),
|
||||
'$basepath' => $a->getHostName()
|
||||
]);
|
||||
|
||||
$stpl = get_markup_template('settings/settings.tpl');
|
||||
|
|
|
@ -108,7 +108,7 @@ EOT;
|
|||
|
||||
$arr = [];
|
||||
|
||||
$arr['guid'] = System::createGUID(32);
|
||||
$arr['guid'] = System::createUUID();
|
||||
$arr['uri'] = $uri;
|
||||
$arr['uid'] = $owner_uid;
|
||||
$arr['contact-id'] = $contact['id'];
|
||||
|
|
|
@ -115,7 +115,7 @@ EOT;
|
|||
|
||||
$arr = [];
|
||||
|
||||
$arr['guid'] = System::createGUID(32);
|
||||
$arr['guid'] = System::createUUID();
|
||||
$arr['uri'] = $uri;
|
||||
$arr['uid'] = $owner_uid;
|
||||
$arr['contact-id'] = $contact['id'];
|
||||
|
|
|
@ -14,18 +14,14 @@ use Friendica\Model\User;
|
|||
|
||||
function unfollow_post()
|
||||
{
|
||||
$return_url = $_SESSION['return_url'];
|
||||
$return_url = 'contacts';
|
||||
|
||||
if (!local_user()) {
|
||||
notice(L10n::t('Permission denied.'));
|
||||
goaway($return_url);
|
||||
goaway('/login');
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
if (!empty($_REQUEST['cancel'])) {
|
||||
goaway($return_url);
|
||||
}
|
||||
|
||||
$uid = local_user();
|
||||
$url = notags(trim(defaults($_REQUEST, 'url', '')));
|
||||
|
||||
|
@ -40,9 +36,13 @@ function unfollow_post()
|
|||
// NOTREACHED
|
||||
}
|
||||
|
||||
if (!empty($_REQUEST['cancel'])) {
|
||||
goaway($return_url . '/' . $contact['id']);
|
||||
}
|
||||
|
||||
if (!in_array($contact['network'], Protocol::NATIVE_SUPPORT)) {
|
||||
notice(L10n::t('Unfollowing is currently not supported by your network.'));
|
||||
goaway($return_url);
|
||||
goaway($return_url . '/' . $contact['id']);
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
|
@ -69,9 +69,11 @@ function unfollow_post()
|
|||
|
||||
function unfollow_content(App $a)
|
||||
{
|
||||
$return_url = 'contacts';
|
||||
|
||||
if (!local_user()) {
|
||||
notice(L10n::t('Permission denied.'));
|
||||
goaway($_SESSION['return_url']);
|
||||
goaway('/login');
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
|
@ -86,7 +88,7 @@ function unfollow_content(App $a)
|
|||
|
||||
if (!DBA::isResult($contact)) {
|
||||
notice(L10n::t("You aren't following this contact."));
|
||||
goaway('contacts');
|
||||
goaway($return_url);
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
|
@ -103,7 +105,7 @@ function unfollow_content(App $a)
|
|||
|
||||
if (!DBA::isResult($self)) {
|
||||
notice(L10n::t('Permission denied.'));
|
||||
goaway($_SESSION['return_url']);
|
||||
goaway($return_url);
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
|
|
|
@ -105,12 +105,6 @@ function videos_init(App $a)
|
|||
$a->page['htmlhead'] .= replace_macros($tpl,[
|
||||
'$baseurl' => System::baseUrl(),
|
||||
]);
|
||||
|
||||
$tpl = get_markup_template("videos_end.tpl");
|
||||
$a->page['end'] .= replace_macros($tpl,[
|
||||
'$baseurl' => System::baseUrl(),
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -347,8 +341,8 @@ function videos_content(App $a)
|
|||
);
|
||||
|
||||
if (DBA::isResult($r)) {
|
||||
$a->set_pager_total(count($r));
|
||||
$a->set_pager_itemspage(20);
|
||||
$a->setPagerTotal(count($r));
|
||||
$a->setPagerItemsPage(20);
|
||||
}
|
||||
|
||||
$r = q("SELECT hash, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`created`) AS `created`,
|
||||
|
|
|
@ -71,7 +71,7 @@ function viewcontacts_content(App $a)
|
|||
DBA::escape(Protocol::OSTATUS)
|
||||
);
|
||||
if (DBA::isResult($r)) {
|
||||
$a->set_pager_total($r[0]['total']);
|
||||
$a->setPagerTotal($r[0]['total']);
|
||||
}
|
||||
|
||||
$r = q("SELECT * FROM `contact`
|
||||
|
|
|
@ -26,7 +26,7 @@ function viewsrc_content(App $a)
|
|||
$item = Item::selectFirst(['body'], ['uid' => local_user(), 'id' => $item_id]);
|
||||
|
||||
if (DBA::isResult($item)) {
|
||||
if (is_ajax()) {
|
||||
if ($a->isAjax()) {
|
||||
echo str_replace("\n", '<br />', $item['body']);
|
||||
killme();
|
||||
} else {
|
||||
|
|
|
@ -120,13 +120,6 @@ function wallmessage_content(App $a) {
|
|||
'$linkurl' => L10n::t('Please enter a link URL:')
|
||||
]);
|
||||
|
||||
$tpl = get_markup_template('wallmsg-end.tpl');
|
||||
$a->page['end'] .= replace_macros($tpl, [
|
||||
'$baseurl' => System::baseUrl(true),
|
||||
'$nickname' => $user['nickname'],
|
||||
'$linkurl' => L10n::t('Please enter a link URL:')
|
||||
]);
|
||||
|
||||
$tpl = get_markup_template('wallmessage.tpl');
|
||||
$o = replace_macros($tpl, [
|
||||
'$header' => L10n::t('Send Private Message'),
|
||||
|
|
14
mod/xrd.php
14
mod/xrd.php
|
@ -13,7 +13,7 @@ function xrd_init(App $a)
|
|||
{
|
||||
if ($a->argv[0] == 'xrd') {
|
||||
if (empty($_GET['uri'])) {
|
||||
killme();
|
||||
System::httpExit(404);
|
||||
}
|
||||
|
||||
$uri = urldecode(notags(trim($_GET['uri'])));
|
||||
|
@ -24,7 +24,7 @@ function xrd_init(App $a)
|
|||
}
|
||||
} else {
|
||||
if (empty($_GET['resource'])) {
|
||||
killme();
|
||||
System::httpExit(404);
|
||||
}
|
||||
|
||||
$uri = urldecode(notags(trim($_GET['resource'])));
|
||||
|
@ -48,16 +48,16 @@ function xrd_init(App $a)
|
|||
|
||||
$user = DBA::selectFirst('user', [], ['nickname' => $name]);
|
||||
if (!DBA::isResult($user)) {
|
||||
killme();
|
||||
System::httpExit(404);
|
||||
}
|
||||
|
||||
$profile_url = System::baseUrl().'/profile/'.$user['nickname'];
|
||||
|
||||
$alias = str_replace('/profile/', '/~', $profile_url);
|
||||
|
||||
$addr = 'acct:'.$user['nickname'].'@'.$a->get_hostname();
|
||||
if ($a->get_path()) {
|
||||
$addr .= '/'.$a->get_path();
|
||||
$addr = 'acct:'.$user['nickname'].'@'.$a->getHostName();
|
||||
if ($a->getURLPath()) {
|
||||
$addr .= '/'.$a->getURLPath();
|
||||
}
|
||||
|
||||
if ($mode == 'xml') {
|
||||
|
@ -80,6 +80,7 @@ function xrd_json($a, $uri, $alias, $profile_url, $r)
|
|||
['rel' => NAMESPACE_DFRN, 'href' => $profile_url],
|
||||
['rel' => NAMESPACE_FEED, 'type' => 'application/atom+xml', 'href' => System::baseUrl().'/dfrn_poll/'.$r['nickname']],
|
||||
['rel' => 'http://webfinger.net/rel/profile-page', 'type' => 'text/html', 'href' => $profile_url],
|
||||
['rel' => 'self', 'type' => 'application/activity+json', 'href' => $profile_url],
|
||||
['rel' => 'http://microformats.org/profile/hcard', 'type' => 'text/html', 'href' => System::baseUrl().'/hcard/'.$r['nickname']],
|
||||
['rel' => NAMESPACE_POCO, 'href' => System::baseUrl().'/poco/'.$r['nickname']],
|
||||
['rel' => 'http://webfinger.net/rel/avatar', 'type' => 'image/jpeg', 'href' => System::baseUrl().'/photo/profile/'.$r['uid'].'.jpg'],
|
||||
|
@ -92,6 +93,7 @@ function xrd_json($a, $uri, $alias, $profile_url, $r)
|
|||
['rel' => 'http://purl.org/openwebauth/v1', 'type' => 'application/x-dfrn+json', 'href' => System::baseUrl().'/owa']
|
||||
]
|
||||
];
|
||||
|
||||
echo json_encode($json);
|
||||
killme();
|
||||
}
|
||||
|
|
574
src/App.php
574
src/App.php
File diff suppressed because it is too large
Load diff
117
src/App/Mode.php
Normal file
117
src/App/Mode.php
Normal file
|
@ -0,0 +1,117 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\App;
|
||||
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Database\DBA;
|
||||
|
||||
/**
|
||||
* Mode of the current Friendica Node
|
||||
*
|
||||
* @package Friendica\App
|
||||
*/
|
||||
class Mode
|
||||
{
|
||||
const LOCALCONFIGPRESENT = 1;
|
||||
const DBAVAILABLE = 2;
|
||||
const DBCONFIGAVAILABLE = 4;
|
||||
const MAINTENANCEDISABLED = 8;
|
||||
|
||||
/***
|
||||
* @var int the mode of this Application
|
||||
*
|
||||
*/
|
||||
private $mode;
|
||||
|
||||
/**
|
||||
* @var string the basepath of the application
|
||||
*/
|
||||
private $basepath;
|
||||
|
||||
public function __construct($basepath = '')
|
||||
{
|
||||
$this->basepath = $basepath;
|
||||
$this->mode = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the App mode
|
||||
*
|
||||
* - App::MODE_INSTALL : Either the database connection can't be established or the config table doesn't exist
|
||||
* - App::MODE_MAINTENANCE: The maintenance mode has been set
|
||||
* - App::MODE_NORMAL : Normal run with all features enabled
|
||||
*
|
||||
* @param string $basepath the Basepath of the Application
|
||||
*
|
||||
*/
|
||||
public function determine($basepath = null)
|
||||
{
|
||||
if (!empty($basepath)) {
|
||||
$this->basepath = $basepath;
|
||||
}
|
||||
|
||||
$this->mode = 0;
|
||||
|
||||
if (!file_exists($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.ini.php')
|
||||
&& !file_exists($this->basepath . DIRECTORY_SEPARATOR . '.htconfig.php')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->mode |= Mode::LOCALCONFIGPRESENT;
|
||||
|
||||
if (!DBA::connected()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->mode |= Mode::DBAVAILABLE;
|
||||
|
||||
if (DBA::fetchFirst("SHOW TABLES LIKE 'config'") === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->mode |= Mode::DBCONFIGAVAILABLE;
|
||||
|
||||
if (Config::get('system', 'maintenance')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->mode |= Mode::MAINTENANCEDISABLED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks, if the Friendica Node has the given mode
|
||||
*
|
||||
* @param int $mode A mode to test
|
||||
*
|
||||
* @return bool returns true, if the mode is set
|
||||
*/
|
||||
public function has($mode)
|
||||
{
|
||||
return ($this->mode & $mode) > 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Install mode is when the local config file is missing or the DB schema hasn't been installed yet.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isInstall()
|
||||
{
|
||||
return !$this->has(Mode::LOCALCONFIGPRESENT) ||
|
||||
!$this->has(MODE::DBCONFIGAVAILABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normal mode is when the local config file is set, the DB schema is installed and the maintenance mode is off.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isNormal()
|
||||
{
|
||||
return $this->has(Mode::LOCALCONFIGPRESENT) &&
|
||||
$this->has(Mode::DBAVAILABLE) &&
|
||||
$this->has(Mode::DBCONFIGAVAILABLE) &&
|
||||
$this->has(Mode::MAINTENANCEDISABLED);
|
||||
}
|
||||
}
|
|
@ -21,7 +21,16 @@ abstract class BaseModule extends BaseObject
|
|||
*/
|
||||
public static function init()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Module GET method to display raw content from technical endpoints
|
||||
*
|
||||
* Extend this method if the module is supposed to return communication data,
|
||||
* e.g. from protocol implementations.
|
||||
*/
|
||||
public static function rawContent()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,7 +7,9 @@ namespace Friendica\Content;
|
|||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Util\Network;
|
||||
|
||||
/**
|
||||
* @brief ContactSelector class
|
||||
|
@ -68,28 +70,29 @@ class ContactSelector
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $s network
|
||||
* @param string $network network
|
||||
* @param string $profile optional, default empty
|
||||
* @return string
|
||||
*/
|
||||
public static function networkToName($s, $profile = "")
|
||||
public static function networkToName($network, $profile = "")
|
||||
{
|
||||
$nets = [
|
||||
Protocol::DFRN => L10n::t('Friendica'),
|
||||
Protocol::OSTATUS => L10n::t('OStatus'),
|
||||
Protocol::FEED => L10n::t('RSS/Atom'),
|
||||
Protocol::MAIL => L10n::t('Email'),
|
||||
Protocol::DIASPORA => L10n::t('Diaspora'),
|
||||
Protocol::ZOT => L10n::t('Zot!'),
|
||||
Protocol::LINKEDIN => L10n::t('LinkedIn'),
|
||||
Protocol::XMPP => L10n::t('XMPP/IM'),
|
||||
Protocol::MYSPACE => L10n::t('MySpace'),
|
||||
Protocol::GPLUS => L10n::t('Google+'),
|
||||
Protocol::PUMPIO => L10n::t('pump.io'),
|
||||
Protocol::TWITTER => L10n::t('Twitter'),
|
||||
Protocol::DIASPORA2 => L10n::t('Diaspora Connector'),
|
||||
Protocol::STATUSNET => L10n::t('GNU Social Connector'),
|
||||
Protocol::PNUT => L10n::t('pnut'),
|
||||
Protocol::DFRN => L10n::t('Friendica'),
|
||||
Protocol::OSTATUS => L10n::t('OStatus'),
|
||||
Protocol::FEED => L10n::t('RSS/Atom'),
|
||||
Protocol::MAIL => L10n::t('Email'),
|
||||
Protocol::DIASPORA => L10n::t('Diaspora'),
|
||||
Protocol::ZOT => L10n::t('Zot!'),
|
||||
Protocol::LINKEDIN => L10n::t('LinkedIn'),
|
||||
Protocol::XMPP => L10n::t('XMPP/IM'),
|
||||
Protocol::MYSPACE => L10n::t('MySpace'),
|
||||
Protocol::GPLUS => L10n::t('Google+'),
|
||||
Protocol::PUMPIO => L10n::t('pump.io'),
|
||||
Protocol::TWITTER => L10n::t('Twitter'),
|
||||
Protocol::DIASPORA2 => L10n::t('Diaspora Connector'),
|
||||
Protocol::STATUSNET => L10n::t('GNU Social Connector'),
|
||||
Protocol::ACTIVITYPUB => L10n::t('ActivityPub'),
|
||||
Protocol::PNUT => L10n::t('pnut'),
|
||||
];
|
||||
|
||||
Addon::callHooks('network_to_name', $nets);
|
||||
|
@ -97,15 +100,37 @@ class ContactSelector
|
|||
$search = array_keys($nets);
|
||||
$replace = array_values($nets);
|
||||
|
||||
$networkname = str_replace($search, $replace, $s);
|
||||
$networkname = str_replace($search, $replace, $network);
|
||||
|
||||
if ((in_array($s, [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) && ($profile != "")) {
|
||||
$r = DBA::fetchFirst("SELECT `gserver`.`platform` FROM `gcontact`
|
||||
INNER JOIN `gserver` ON `gserver`.`nurl` = `gcontact`.`server_url`
|
||||
WHERE `gcontact`.`nurl` = ? AND `platform` != ''", normalise_link($profile));
|
||||
if ((in_array($network, [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) && ($profile != "")) {
|
||||
// Create the server url out of the profile url
|
||||
$parts = parse_url($profile);
|
||||
unset($parts['path']);
|
||||
$server_url = [normalise_link(Network::unparseURL($parts))];
|
||||
|
||||
if (DBA::isResult($r)) {
|
||||
$networkname = $r['platform'];
|
||||
// Fetch the server url
|
||||
$gcontact = DBA::selectFirst('gcontact', ['server_url'], ['nurl' => normalise_link($profile)]);
|
||||
if (!empty($gcontact) && !empty($gcontact['server_url'])) {
|
||||
$server_url[] = normalise_link($gcontact['server_url']);
|
||||
}
|
||||
|
||||
// Now query the GServer for the platform name
|
||||
$gserver = DBA::selectFirst('gserver', ['platform', 'network'], ['nurl' => $server_url]);
|
||||
|
||||
if (DBA::isResult($gserver)) {
|
||||
if (!empty($gserver['platform'])) {
|
||||
$platform = $gserver['platform'];
|
||||
} elseif (!empty($gserver['network']) && ($gserver['network'] != Protocol::ACTIVITYPUB)) {
|
||||
$platform = self::networkToName($gserver['network']);
|
||||
}
|
||||
|
||||
if (!empty($platform)) {
|
||||
$networkname = $platform;
|
||||
|
||||
if ($network == Protocol::ACTIVITYPUB) {
|
||||
$networkname .= ' (AP)';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ class Nav
|
|||
// user info
|
||||
$contact = DBA::selectFirst('contact', ['micro'], ['uid' => $a->user['uid'], 'self' => true]);
|
||||
$userinfo = [
|
||||
'icon' => (DBA::isResult($contact) ? $a->remove_baseurl($contact['micro']) : 'images/person-48.jpg'),
|
||||
'icon' => (DBA::isResult($contact) ? $a->removeBaseURL($contact['micro']) : 'images/person-48.jpg'),
|
||||
'name' => $a->user['username'],
|
||||
];
|
||||
} else {
|
||||
|
|
|
@ -1060,11 +1060,11 @@ class BBCode extends BaseObject
|
|||
$ch = @curl_init($match[1]);
|
||||
@curl_setopt($ch, CURLOPT_NOBODY, true);
|
||||
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
@curl_setopt($ch, CURLOPT_USERAGENT, $a->get_useragent());
|
||||
@curl_setopt($ch, CURLOPT_USERAGENT, $a->getUserAgent());
|
||||
@curl_exec($ch);
|
||||
$curl_info = @curl_getinfo($ch);
|
||||
|
||||
$a->save_timestamp($stamp1, "network");
|
||||
$a->saveTimestamp($stamp1, "network");
|
||||
|
||||
if (substr($curl_info["content_type"], 0, 6) == "image/") {
|
||||
$text = "[url=" . $match[1] . "]" . $match[1] . "[/url]";
|
||||
|
@ -1119,11 +1119,11 @@ class BBCode extends BaseObject
|
|||
$ch = @curl_init($match[1]);
|
||||
@curl_setopt($ch, CURLOPT_NOBODY, true);
|
||||
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
@curl_setopt($ch, CURLOPT_USERAGENT, $a->get_useragent());
|
||||
@curl_setopt($ch, CURLOPT_USERAGENT, $a->getUserAgent());
|
||||
@curl_exec($ch);
|
||||
$curl_info = @curl_getinfo($ch);
|
||||
|
||||
$a->save_timestamp($stamp1, "network");
|
||||
$a->saveTimestamp($stamp1, "network");
|
||||
|
||||
// if its a link to a picture then embed this picture
|
||||
if (substr($curl_info["content_type"], 0, 6) == "image/") {
|
||||
|
@ -1265,9 +1265,6 @@ class BBCode extends BaseObject
|
|||
$text = preg_replace("/\s?\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism", "[share$1]$2[/share]", $text);
|
||||
$text = preg_replace("/\s?\[quote(.*?)\]\s?(.*?)\s?\[\/quote\]\s?/ism", "[quote$1]$2[/quote]", $text);
|
||||
|
||||
$text = preg_replace("/\n\[code\]/ism", "[code]", $text);
|
||||
$text = preg_replace("/\[\/code\]\n/ism", "[/code]", $text);
|
||||
|
||||
// when the content is meant exporting to other systems then remove the avatar picture since this doesn't really look good on these systems
|
||||
if (!$try_oembed) {
|
||||
$text = preg_replace("/\[share(.*?)avatar\s?=\s?'.*?'\s?(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism", "\n[share$1$2]$3[/share]", $text);
|
||||
|
@ -1717,18 +1714,6 @@ class BBCode extends BaseObject
|
|||
$text = Smilies::replace($text, false, true);
|
||||
}
|
||||
|
||||
// Replace inline code blocks
|
||||
$text = preg_replace_callback("|(?!<br[^>]*>)<code>([^<]*)</code>(?!<br[^>]*>)|ism",
|
||||
function ($match) use ($simple_html) {
|
||||
$return = '<key>' . $match[1] . '</key>';
|
||||
// Use <code> for Diaspora inline code blocks
|
||||
if ($simple_html === 3) {
|
||||
$return = '<code>' . $match[1] . '</code>';
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
, $text);
|
||||
|
||||
// Unhide all [noparse] contained bbtags unspacefying them
|
||||
// and triming the [noparse] tag.
|
||||
|
||||
|
@ -1946,7 +1931,7 @@ class BBCode extends BaseObject
|
|||
// unmask the special chars back to HTML
|
||||
$text = str_replace(['&\_lt\_;', '&\_gt\_;', '&\_amp\_;'], ['<', '>', '&'], $text);
|
||||
|
||||
$a->save_timestamp($stamp1, "parser");
|
||||
$a->saveTimestamp($stamp1, "parser");
|
||||
|
||||
// Libertree has a problem with escaped hashtags.
|
||||
$text = str_replace(['\#'], ['#'], $text);
|
||||
|
|
|
@ -35,7 +35,7 @@ class Markdown extends BaseObject
|
|||
$MarkdownParser->code_class_prefix = 'language-';
|
||||
$html = $MarkdownParser->transform($text);
|
||||
|
||||
self::getApp()->save_timestamp($stamp1, "parser");
|
||||
self::getApp()->saveTimestamp($stamp1, "parser");
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
|
|
@ -142,10 +142,7 @@ class Widget
|
|||
|
||||
$nets = array();
|
||||
while ($rr = DBA::fetch($r)) {
|
||||
/// @TODO If 'network' is not there, this triggers an E_NOTICE
|
||||
if ($rr['network']) {
|
||||
$nets[] = array('ref' => $rr['network'], 'name' => ContactSelector::networkToName($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
|
||||
}
|
||||
$nets[] = array('ref' => $rr['network'], 'name' => ContactSelector::networkToName($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
|
||||
}
|
||||
DBA::close($r);
|
||||
|
||||
|
|
|
@ -51,14 +51,14 @@ class ACL extends BaseObject
|
|||
break;
|
||||
|
||||
case 'PRIVATE':
|
||||
$networks = [Protocol::DFRN, Protocol::MAIL, Protocol::DIASPORA];
|
||||
$networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::MAIL, Protocol::DIASPORA];
|
||||
break;
|
||||
|
||||
case 'TWO_WAY':
|
||||
if (!empty($a->user['prvnets'])) {
|
||||
$networks = [Protocol::DFRN, Protocol::MAIL, Protocol::DIASPORA];
|
||||
$networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::MAIL, Protocol::DIASPORA];
|
||||
} else {
|
||||
$networks = [Protocol::DFRN, Protocol::MAIL, Protocol::DIASPORA, Protocol::OSTATUS];
|
||||
$networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::MAIL, Protocol::DIASPORA, Protocol::OSTATUS];
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -344,9 +344,9 @@ class ACL extends BaseObject
|
|||
$a = self::getApp();
|
||||
$p = $a->pager['page'] != 1 ? '&p=' . $a->pager['page'] : '';
|
||||
|
||||
$response = Network::curl(get_server() . '/lsearch?f=' . $p . '&search=' . urlencode($search));
|
||||
if ($response['success']) {
|
||||
$lsearch = json_decode($response['body'], true);
|
||||
$curlResult = Network::curl(get_server() . '/lsearch?f=' . $p . '&search=' . urlencode($search));
|
||||
if ($curlResult->isSuccess()) {
|
||||
$lsearch = json_decode($curlResult->getBody(), true);
|
||||
if (!empty($lsearch['results'])) {
|
||||
$return = $lsearch['results'];
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
namespace Friendica\Core;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Database\DBA;
|
||||
|
||||
require_once 'include/dba.php';
|
||||
|
@ -12,8 +13,65 @@ require_once 'include/dba.php';
|
|||
/**
|
||||
* Some functions to handle addons
|
||||
*/
|
||||
class Addon
|
||||
class Addon extends BaseObject
|
||||
{
|
||||
/**
|
||||
* @brief Synchronise addons:
|
||||
*
|
||||
* system.addon contains a comma-separated list of names
|
||||
* of addons which are used on this system.
|
||||
* Go through the database list of already installed addons, and if we have
|
||||
* an entry, but it isn't in the config list, call the uninstall procedure
|
||||
* and mark it uninstalled in the database (for now we'll remove it).
|
||||
* Then go through the config list and if we have a addon that isn't installed,
|
||||
* call the install procedure and add it to the database.
|
||||
*
|
||||
*/
|
||||
public static function check()
|
||||
{
|
||||
$a = self::getApp();
|
||||
|
||||
$r = DBA::select('addon', [], ['installed' => 1]);
|
||||
if (DBA::isResult($r)) {
|
||||
$installed = DBA::toArray($r);
|
||||
} else {
|
||||
$installed = [];
|
||||
}
|
||||
|
||||
$addons = Config::get('system', 'addon');
|
||||
$addons_arr = [];
|
||||
|
||||
if ($addons) {
|
||||
$addons_arr = explode(',', str_replace(' ', '', $addons));
|
||||
}
|
||||
|
||||
$a->addons = $addons_arr;
|
||||
|
||||
$installed_arr = [];
|
||||
|
||||
if (count($installed)) {
|
||||
foreach ($installed as $i) {
|
||||
if (!in_array($i['name'], $addons_arr)) {
|
||||
self::uninstall($i['name']);
|
||||
} else {
|
||||
$installed_arr[] = $i['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($addons_arr)) {
|
||||
foreach ($addons_arr as $p) {
|
||||
if (!in_array($p, $installed_arr)) {
|
||||
self::install($p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self::loadHooks();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief uninstalls an addon.
|
||||
*
|
||||
|
@ -139,7 +197,7 @@ class Addon
|
|||
*/
|
||||
public static function registerHook($hook, $file, $function, $priority = 0)
|
||||
{
|
||||
$file = str_replace(get_app()->get_basepath() . DIRECTORY_SEPARATOR, '', $file);
|
||||
$file = str_replace(self::getApp()->getBasePath() . DIRECTORY_SEPARATOR, '', $file);
|
||||
|
||||
$condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
|
||||
$exists = DBA::exists('hook', $condition);
|
||||
|
@ -162,7 +220,7 @@ class Addon
|
|||
*/
|
||||
public static function unregisterHook($hook, $file, $function)
|
||||
{
|
||||
$relative_file = str_replace(get_app()->get_basepath() . DIRECTORY_SEPARATOR, '', $file);
|
||||
$relative_file = str_replace(self::getApp()->getBasePath() . DIRECTORY_SEPARATOR, '', $file);
|
||||
|
||||
// This here is only needed for fixing a problem that existed on the develop branch
|
||||
$condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
|
||||
|
@ -178,7 +236,7 @@ class Addon
|
|||
*/
|
||||
public static function loadHooks()
|
||||
{
|
||||
$a = get_app();
|
||||
$a = self::getApp();
|
||||
$a->hooks = [];
|
||||
$r = DBA::select('hook', ['hook', 'file', 'function'], [], ['order' => ['priority' => 'desc', 'file']]);
|
||||
|
||||
|
@ -201,7 +259,7 @@ class Addon
|
|||
*/
|
||||
public static function forkHooks($priority, $name, $data = null)
|
||||
{
|
||||
$a = get_app();
|
||||
$a = self::getApp();
|
||||
|
||||
if (is_array($a->hooks) && array_key_exists($name, $a->hooks)) {
|
||||
foreach ($a->hooks[$name] as $hook) {
|
||||
|
@ -221,7 +279,7 @@ class Addon
|
|||
*/
|
||||
public static function callHooks($name, &$data = null)
|
||||
{
|
||||
$a = get_app();
|
||||
$a = self::getApp();
|
||||
|
||||
if (is_array($a->hooks) && array_key_exists($name, $a->hooks)) {
|
||||
foreach ($a->hooks[$name] as $hook) {
|
||||
|
@ -262,7 +320,7 @@ class Addon
|
|||
*/
|
||||
public static function isApp($name)
|
||||
{
|
||||
$a = get_app();
|
||||
$a = self::getApp();
|
||||
|
||||
if (is_array($a->hooks) && (array_key_exists('app_menu', $a->hooks))) {
|
||||
foreach ($a->hooks['app_menu'] as $hook) {
|
||||
|
@ -293,7 +351,7 @@ class Addon
|
|||
*/
|
||||
public static function getInfo($addon)
|
||||
{
|
||||
$a = get_app();
|
||||
$a = self::getApp();
|
||||
|
||||
$info = [
|
||||
'name' => $addon,
|
||||
|
@ -310,7 +368,7 @@ class Addon
|
|||
|
||||
$stamp1 = microtime(true);
|
||||
$f = file_get_contents("addon/$addon/$addon.php");
|
||||
$a->save_timestamp($stamp1, "file");
|
||||
$a->saveTimestamp($stamp1, "file");
|
||||
|
||||
$r = preg_match("|/\*.*\*/|msU", $f, $m);
|
||||
|
||||
|
|
|
@ -23,13 +23,15 @@ class Cache extends \Friendica\BaseObject
|
|||
/**
|
||||
* @var Cache\ICacheDriver
|
||||
*/
|
||||
private static $driver = null;
|
||||
private static $driver = null;
|
||||
public static $driver_class = null;
|
||||
public static $driver_name = null;
|
||||
|
||||
public static function init()
|
||||
{
|
||||
$driver_name = Config::get('system', 'cache_driver', 'database');
|
||||
|
||||
self::$driver = CacheDriverFactory::create($driver_name);
|
||||
self::$driver_name = Config::get('system', 'cache_driver', 'database');
|
||||
self::$driver = CacheDriverFactory::create(self::$driver_name);
|
||||
self::$driver_class = get_class(self::$driver);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,6 +48,24 @@ class Cache extends \Friendica\BaseObject
|
|||
return self::$driver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns all the cache keys sorted alphabetically
|
||||
*
|
||||
* @param string $prefix Prefix of the keys (optional)
|
||||
*
|
||||
* @return array Empty if the driver doesn't support this feature
|
||||
*/
|
||||
public static function getAllKeys($prefix = null)
|
||||
{
|
||||
$time = microtime(true);
|
||||
|
||||
$return = self::getDriver()->getAllKeys($prefix);
|
||||
|
||||
self::getApp()->saveTimestamp($time, 'cache');
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Fetch cached data according to the key
|
||||
*
|
||||
|
@ -59,7 +79,7 @@ class Cache extends \Friendica\BaseObject
|
|||
|
||||
$return = self::getDriver()->get($key);
|
||||
|
||||
self::getApp()->save_timestamp($time, 'cache');
|
||||
self::getApp()->saveTimestamp($time, 'cache');
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
@ -81,7 +101,7 @@ class Cache extends \Friendica\BaseObject
|
|||
|
||||
$return = self::getDriver()->set($key, $value, $duration);
|
||||
|
||||
self::getApp()->save_timestamp($time, 'cache_write');
|
||||
self::getApp()->saveTimestamp($time, 'cache_write');
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
@ -99,7 +119,7 @@ class Cache extends \Friendica\BaseObject
|
|||
|
||||
$return = self::getDriver()->delete($key);
|
||||
|
||||
self::getApp()->save_timestamp($time, 'cache_write');
|
||||
self::getApp()->saveTimestamp($time, 'cache_write');
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
@ -107,12 +127,12 @@ class Cache extends \Friendica\BaseObject
|
|||
/**
|
||||
* @brief Remove outdated data from the cache
|
||||
*
|
||||
* @param integer $max_level The maximum cache level that is to be cleared
|
||||
* @param boolean $outdated just remove outdated values
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function clear()
|
||||
public static function clear($outdated = true)
|
||||
{
|
||||
return self::getDriver()->clear();
|
||||
return self::getDriver()->clear($outdated);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,56 @@ abstract class AbstractCacheDriver extends BaseObject
|
|||
* @param string $key The original key
|
||||
* @return string The cache key used for the cache
|
||||
*/
|
||||
protected function getCacheKey($key) {
|
||||
protected function getCacheKey($key)
|
||||
{
|
||||
// We fetch with the hostname as key to avoid problems with other applications
|
||||
return self::getApp()->get_hostname() . ":" . $key;
|
||||
return self::getApp()->getHostName() . ":" . $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $keys A list of cached keys
|
||||
* @return array A list of original keys
|
||||
*/
|
||||
protected function getOriginalKeys($keys)
|
||||
{
|
||||
if (empty($keys)) {
|
||||
return [];
|
||||
} else {
|
||||
// Keys are prefixed with the node hostname, let's remove it
|
||||
array_walk($keys, function (&$value) {
|
||||
$value = preg_replace('/^' . self::getApp()->getHostName() . ':/', '', $value);
|
||||
});
|
||||
|
||||
sort($keys);
|
||||
|
||||
return $keys;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the keys of an array with a given prefix
|
||||
* Returns the filtered keys as an new array
|
||||
*
|
||||
* @param array $array The array, which should get filtered
|
||||
* @param string|null $prefix The prefix (if null, all keys will get returned)
|
||||
*
|
||||
* @return array The filtered array with just the keys
|
||||
*/
|
||||
protected function filterArrayKeysByPrefix($array, $prefix = null)
|
||||
{
|
||||
if (empty($prefix)) {
|
||||
return array_keys($array);
|
||||
} else {
|
||||
$result = [];
|
||||
|
||||
foreach (array_keys($array) as $key) {
|
||||
if (strpos($key, $prefix) === 0) {
|
||||
array_push($result, $key);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,14 @@ class ArrayCache extends AbstractCacheDriver implements IMemoryCacheDriver
|
|||
/** @var array Array with the cached data */
|
||||
protected $cachedData = array();
|
||||
|
||||
/**
|
||||
* (@inheritdoc)
|
||||
*/
|
||||
public function getAllKeys($prefix = null)
|
||||
{
|
||||
return $this->filterArrayKeysByPrefix($this->cachedData, $prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* (@inheritdoc)
|
||||
*/
|
||||
|
|
|
@ -13,6 +13,31 @@ use Friendica\Util\DateTimeFormat;
|
|||
*/
|
||||
class DatabaseCacheDriver extends AbstractCacheDriver implements ICacheDriver
|
||||
{
|
||||
/**
|
||||
* (@inheritdoc)
|
||||
*/
|
||||
public function getAllKeys($prefix = null)
|
||||
{
|
||||
if (empty($prefix)) {
|
||||
$where = ['`expires` >= ?', DateTimeFormat::utcNow()];
|
||||
} else {
|
||||
$where = ['`expires` >= ? AND `k` LIKE CONCAT(?, \'%\')', DateTimeFormat::utcNow(), $prefix];
|
||||
}
|
||||
|
||||
$stmt = DBA::select('cache', ['k'], $where);
|
||||
|
||||
$keys = [];
|
||||
while ($key = DBA::fetch($stmt)) {
|
||||
array_push($keys, $key['k']);
|
||||
}
|
||||
DBA::close($stmt);
|
||||
|
||||
return $keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* (@inheritdoc)
|
||||
*/
|
||||
public function get($key)
|
||||
{
|
||||
$cache = DBA::selectFirst('cache', ['v'], ['`k` = ? AND `expires` >= ?', $key, DateTimeFormat::utcNow()]);
|
||||
|
@ -32,6 +57,9 @@ class DatabaseCacheDriver extends AbstractCacheDriver implements ICacheDriver
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* (@inheritdoc)
|
||||
*/
|
||||
public function set($key, $value, $ttl = Cache::FIVE_MINUTES)
|
||||
{
|
||||
$fields = [
|
||||
|
@ -43,11 +71,17 @@ class DatabaseCacheDriver extends AbstractCacheDriver implements ICacheDriver
|
|||
return DBA::update('cache', $fields, ['k' => $key], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* (@inheritdoc)
|
||||
*/
|
||||
public function delete($key)
|
||||
{
|
||||
return DBA::delete('cache', ['k' => $key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* (@inheritdoc)
|
||||
*/
|
||||
public function clear($outdated = true)
|
||||
{
|
||||
if ($outdated) {
|
||||
|
|
|
@ -11,6 +11,15 @@ use Friendica\Core\Cache;
|
|||
*/
|
||||
interface ICacheDriver
|
||||
{
|
||||
/**
|
||||
* Lists all cache keys
|
||||
*
|
||||
* @param string prefix optional a prefix to search
|
||||
*
|
||||
* @return array Empty if it isn't supported by the cache driver
|
||||
*/
|
||||
public function getAllKeys($prefix = null);
|
||||
|
||||
/**
|
||||
* Fetches cached data according to the key
|
||||
*
|
||||
|
|
|
@ -22,6 +22,11 @@ class MemcacheCacheDriver extends AbstractCacheDriver implements IMemoryCacheDri
|
|||
*/
|
||||
private $memcache;
|
||||
|
||||
/**
|
||||
* @param string $memcache_host
|
||||
* @param int $memcache_port
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct($memcache_host, $memcache_port)
|
||||
{
|
||||
if (!class_exists('Memcache', false)) {
|
||||
|
@ -35,6 +40,30 @@ class MemcacheCacheDriver extends AbstractCacheDriver implements IMemoryCacheDri
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (@inheritdoc)
|
||||
*/
|
||||
public function getAllKeys($prefix = null)
|
||||
{
|
||||
$keys = [];
|
||||
$allSlabs = $this->memcache->getExtendedStats('slabs');
|
||||
foreach ($allSlabs as $slabs) {
|
||||
foreach (array_keys($slabs) as $slabId) {
|
||||
$cachedump = $this->memcache->getExtendedStats('cachedump', (int)$slabId);
|
||||
foreach ($cachedump as $key => $arrVal) {
|
||||
if (!is_array($arrVal)) {
|
||||
continue;
|
||||
}
|
||||
$keys = array_merge($keys, array_keys($arrVal));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$keys = $this->getOriginalKeys($keys);
|
||||
|
||||
return $this->filterArrayKeysByPrefix($keys, $prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* (@inheritdoc)
|
||||
*/
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Friendica\Core\Cache;
|
|||
use Friendica\Core\Cache;
|
||||
|
||||
use Exception;
|
||||
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||
use Memcached;
|
||||
|
||||
/**
|
||||
|
@ -53,6 +54,24 @@ class MemcachedCacheDriver extends AbstractCacheDriver implements IMemoryCacheDr
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (@inheritdoc)
|
||||
*/
|
||||
public function getAllKeys($prefix = null)
|
||||
{
|
||||
$keys = $this->getOriginalKeys($this->memcached->getAllKeys());
|
||||
|
||||
if ($this->memcached->getResultCode() == Memcached::RES_SUCCESS) {
|
||||
return $this->filterArrayKeysByPrefix($keys, $prefix);
|
||||
} else {
|
||||
logger('Memcached \'getAllKeys\' failed with ' . $this->memcached->getResultMessage(), LOGGER_ALL);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (@inheritdoc)
|
||||
*/
|
||||
public function get($key)
|
||||
{
|
||||
$return = null;
|
||||
|
@ -63,11 +82,16 @@ class MemcachedCacheDriver extends AbstractCacheDriver implements IMemoryCacheDr
|
|||
|
||||
if ($this->memcached->getResultCode() === Memcached::RES_SUCCESS) {
|
||||
$return = $value;
|
||||
} else {
|
||||
logger('Memcached \'get\' failed with ' . $this->memcached->getResultMessage(), LOGGER_ALL);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* (@inheritdoc)
|
||||
*/
|
||||
public function set($key, $value, $ttl = Cache::FIVE_MINUTES)
|
||||
{
|
||||
$cachekey = $this->getCacheKey($key);
|
||||
|
@ -85,15 +109,20 @@ class MemcachedCacheDriver extends AbstractCacheDriver implements IMemoryCacheDr
|
|||
$value
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* (@inheritdoc)
|
||||
*/
|
||||
public function delete($key)
|
||||
{
|
||||
$cachekey = $this->getCacheKey($key);
|
||||
return $this->memcached->delete($cachekey);
|
||||
}
|
||||
|
||||
/**
|
||||
* (@inheritdoc)
|
||||
*/
|
||||
public function clear($outdated = true)
|
||||
{
|
||||
if ($outdated) {
|
||||
|
@ -104,12 +133,7 @@ class MemcachedCacheDriver extends AbstractCacheDriver implements IMemoryCacheDr
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Sets a value if it's not already stored
|
||||
*
|
||||
* @param string $key The cache key
|
||||
* @param mixed $value The old value we know from the cache
|
||||
* @param int $ttl The cache lifespan, must be one of the Cache constants
|
||||
* @return bool
|
||||
* (@inheritdoc)
|
||||
*/
|
||||
public function add($key, $value, $ttl = Cache::FIVE_MINUTES)
|
||||
{
|
||||
|
|
|
@ -20,6 +20,11 @@ class RedisCacheDriver extends AbstractCacheDriver implements IMemoryCacheDriver
|
|||
*/
|
||||
private $redis;
|
||||
|
||||
/**
|
||||
* @param string $redis_host
|
||||
* @param int $redis_port
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct($redis_host, $redis_port)
|
||||
{
|
||||
if (!class_exists('Redis', false)) {
|
||||
|
@ -33,6 +38,25 @@ class RedisCacheDriver extends AbstractCacheDriver implements IMemoryCacheDriver
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (@inheritdoc)
|
||||
*/
|
||||
public function getAllKeys($prefix = null)
|
||||
{
|
||||
if (empty($prefix)) {
|
||||
$search = '*';
|
||||
} else {
|
||||
$search = $prefix . '*';
|
||||
}
|
||||
|
||||
$list = $this->redis->keys($this->getCacheKey($search));
|
||||
|
||||
return $this->getOriginalKeys($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* (@inheritdoc)
|
||||
*/
|
||||
public function get($key)
|
||||
{
|
||||
$return = null;
|
||||
|
@ -55,6 +79,9 @@ class RedisCacheDriver extends AbstractCacheDriver implements IMemoryCacheDriver
|
|||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* (@inheritdoc)
|
||||
*/
|
||||
public function set($key, $value, $ttl = Cache::FIVE_MINUTES)
|
||||
{
|
||||
$cachekey = $this->getCacheKey($key);
|
||||
|
@ -75,12 +102,18 @@ class RedisCacheDriver extends AbstractCacheDriver implements IMemoryCacheDriver
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (@inheritdoc)
|
||||
*/
|
||||
public function delete($key)
|
||||
{
|
||||
$cachekey = $this->getCacheKey($key);
|
||||
return ($this->redis->delete($cachekey) > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* (@inheritdoc)
|
||||
*/
|
||||
public function clear($outdated = true)
|
||||
{
|
||||
if ($outdated) {
|
||||
|
@ -127,6 +160,7 @@ class RedisCacheDriver extends AbstractCacheDriver implements IMemoryCacheDriver
|
|||
$this->redis->unwatch();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* (@inheritdoc)
|
||||
*/
|
||||
|
|
|
@ -31,7 +31,7 @@ class Config extends BaseObject
|
|||
public static function init()
|
||||
{
|
||||
// Database isn't ready or populated yet
|
||||
if (!(self::getApp()->mode & App::MODE_DBCONFIGAVAILABLE)) {
|
||||
if (!self::getApp()->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ class Config extends BaseObject
|
|||
public static function load($family = "config")
|
||||
{
|
||||
// Database isn't ready or populated yet
|
||||
if (!(self::getApp()->mode & App::MODE_DBCONFIGAVAILABLE)) {
|
||||
if (!self::getApp()->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ class Config extends BaseObject
|
|||
public static function get($family, $key, $default_value = null, $refresh = false)
|
||||
{
|
||||
// Database isn't ready or populated yet, fallback to file config
|
||||
if (!(self::getApp()->mode & App::MODE_DBCONFIGAVAILABLE)) {
|
||||
if (!self::getApp()->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
return self::getApp()->getConfigValue($family, $key, $default_value);
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ class Config extends BaseObject
|
|||
public static function set($family, $key, $value)
|
||||
{
|
||||
// Database isn't ready or populated yet
|
||||
if (!(self::getApp()->mode & App::MODE_DBCONFIGAVAILABLE)) {
|
||||
if (!self::getApp()->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ class Config extends BaseObject
|
|||
public static function delete($family, $key)
|
||||
{
|
||||
// Database isn't ready or populated yet
|
||||
if (!(self::getApp()->mode & App::MODE_DBCONFIGAVAILABLE)) {
|
||||
if (!self::getApp()->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ class Console extends \Asika\SimpleConsole\Console
|
|||
protected $customHelpOptions = ['h', 'help', '?'];
|
||||
|
||||
protected $subConsoles = [
|
||||
'cache' => __NAMESPACE__ . '\Console\Cache',
|
||||
'config' => __NAMESPACE__ . '\Console\Config',
|
||||
'createdoxygen' => __NAMESPACE__ . '\Console\CreateDoxygen',
|
||||
'docbloxerrorchecker' => __NAMESPACE__ . '\Console\DocBloxErrorChecker',
|
||||
|
@ -37,6 +38,7 @@ class Console extends \Asika\SimpleConsole\Console
|
|||
Usage: bin/console [--version] [-h|--help|-?] <command> [<args>] [-v]
|
||||
|
||||
Commands:
|
||||
cache Manage node cache
|
||||
config Edit site config
|
||||
createdoxygen Generate Doxygen headers
|
||||
dbstructure Do database updates
|
||||
|
|
|
@ -39,7 +39,7 @@ HELP;
|
|||
|
||||
protected function doExecute()
|
||||
{
|
||||
$a = get_app();
|
||||
$a = \Friendica\BaseObject::getApp();
|
||||
|
||||
if ($this->getOption('v')) {
|
||||
$this->out('Class: ' . __CLASS__);
|
||||
|
@ -56,7 +56,7 @@ HELP;
|
|||
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
|
||||
}
|
||||
|
||||
if ($a->mode === App::MODE_INSTALL) {
|
||||
if ($a->getMode()->isInstall()) {
|
||||
throw new RuntimeException('Friendica isn\'t properly installed yet.');
|
||||
}
|
||||
|
||||
|
|
|
@ -3,15 +3,14 @@
|
|||
namespace Friendica\Core\Console;
|
||||
|
||||
use Asika\SimpleConsole\Console;
|
||||
use Friendica\App;
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Install;
|
||||
use Friendica\Core\Theme;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBStructure;
|
||||
use RuntimeException;
|
||||
|
||||
require_once 'mod/install.php';
|
||||
require_once 'include/dba.php';
|
||||
|
||||
class AutomaticInstallation extends Console
|
||||
|
@ -30,20 +29,21 @@ Notes
|
|||
Not checking .htaccess/URL-Rewrite during CLI installation.
|
||||
|
||||
Options
|
||||
-h|--help|-? Show help information
|
||||
-v Show more debug information.
|
||||
-a All setup checks are required (except .htaccess)
|
||||
-f|--file <config> prepared config file (e.g. "config/local.ini.php" itself) which will override every other config option - except the environment variables)
|
||||
-s|--savedb Save the DB credentials to the file (if environment variables is used)
|
||||
-H|--dbhost <host> The host of the mysql/mariadb database (env MYSQL_HOST)
|
||||
-p|--dbport <port> The port of the mysql/mariadb database (env MYSQL_PORT)
|
||||
-d|--dbdata <database> The name of the mysql/mariadb database (env MYSQL_DATABASE)
|
||||
-U|--dbuser <username> The username of the mysql/mariadb database login (env MYSQL_USER or MYSQL_USERNAME)
|
||||
-P|--dbpass <password> The password of the mysql/mariadb database login (env MYSQL_PASSWORD)
|
||||
-b|--phppath <path> The path of the PHP binary (env FRIENDICA_PHP_PATH)
|
||||
-A|--admin <mail> The admin email address of Friendica (env FRIENDICA_ADMIN_MAIL)
|
||||
-T|--tz <timezone> The timezone of Friendica (env FRIENDICA_TZ)
|
||||
-L|--lang <language> The language of Friendica (env FRIENDICA_LANG)
|
||||
-h|--help|-? Show help information
|
||||
-v Show more debug information.
|
||||
-a All setup checks are required (except .htaccess)
|
||||
-f|--file <config> prepared config file (e.g. "config/local.ini.php" itself) which will override every other config option - except the environment variables)
|
||||
-s|--savedb Save the DB credentials to the file (if environment variables is used)
|
||||
-H|--dbhost <host> The host of the mysql/mariadb database (env MYSQL_HOST)
|
||||
-p|--dbport <port> The port of the mysql/mariadb database (env MYSQL_PORT)
|
||||
-d|--dbdata <database> The name of the mysql/mariadb database (env MYSQL_DATABASE)
|
||||
-U|--dbuser <username> The username of the mysql/mariadb database login (env MYSQL_USER or MYSQL_USERNAME)
|
||||
-P|--dbpass <password> The password of the mysql/mariadb database login (env MYSQL_PASSWORD)
|
||||
-u|--urlpath <url_path> The URL path of Friendica - f.e. '/friendica' (env FRIENDICA_URL_PATH)
|
||||
-b|--phppath <php_path> The path of the PHP binary (env FRIENDICA_PHP_PATH)
|
||||
-A|--admin <mail> The admin email address of Friendica (env FRIENDICA_ADMIN_MAIL)
|
||||
-T|--tz <timezone> The timezone of Friendica (env FRIENDICA_TZ)
|
||||
-L|--lang <language> The language of Friendica (env FRIENDICA_LANG)
|
||||
|
||||
Environment variables
|
||||
MYSQL_HOST The host of the mysql/mariadb database (mandatory if mysql and environment is used)
|
||||
|
@ -51,6 +51,7 @@ Environment variables
|
|||
MYSQL_USERNAME|MYSQL_USER The username of the mysql/mariadb database login (MYSQL_USERNAME is for mysql, MYSQL_USER for mariadb)
|
||||
MYSQL_PASSWORD The password of the mysql/mariadb database login
|
||||
MYSQL_DATABASE The name of the mysql/mariadb database
|
||||
FRIENDICA_URL_PATH The URL path of Friendica (f.e. '/friendica')
|
||||
FRIENDICA_PHP_PATH The path of the PHP binary
|
||||
FRIENDICA_ADMIN_MAIL The admin email address of Friendica (this email will be used for admin access)
|
||||
FRIENDICA_TZ The timezone of Friendica
|
||||
|
@ -75,6 +76,8 @@ HELP;
|
|||
|
||||
$a = BaseObject::getApp();
|
||||
|
||||
$install = new Install();
|
||||
|
||||
// if a config file is set,
|
||||
$config_file = $this->getOption(['f', 'file']);
|
||||
|
||||
|
@ -82,8 +85,8 @@ HELP;
|
|||
if ($config_file != 'config' . DIRECTORY_SEPARATOR . 'local.ini.php') {
|
||||
// Copy config file
|
||||
$this->out("Copying config file...\n");
|
||||
if (!copy($a->basepath . DIRECTORY_SEPARATOR . $config_file, $a->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.ini.php')) {
|
||||
throw new RuntimeException("ERROR: Saving config file failed. Please copy '$config_file' to '$a->basepath" . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "local.ini.php' manually.\n");
|
||||
if (!copy($a->getBasePath() . DIRECTORY_SEPARATOR . $config_file, $a->getBasePath() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.ini.php')) {
|
||||
throw new RuntimeException("ERROR: Saving config file failed. Please copy '$config_file' to '" . $a->getBasePath() . "'" . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "local.ini.php' manually.\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,21 +105,23 @@ HELP;
|
|||
$db_data = $this->getOption(['d', 'dbdata'], ($save_db) ? getenv('MYSQL_DATABASE') : '');
|
||||
$db_user = $this->getOption(['U', 'dbuser'], ($save_db) ? getenv('MYSQL_USER') . getenv('MYSQL_USERNAME') : '');
|
||||
$db_pass = $this->getOption(['P', 'dbpass'], ($save_db) ? getenv('MYSQL_PASSWORD') : '');
|
||||
$php_path = $this->getOption(['b', 'phppath'], (!empty('FRIENDICA_PHP_PATH')) ? getenv('FRIENDICA_PHP_PATH') : '');
|
||||
$url_path = $this->getOption(['u', 'urlpath'], (!empty('FRIENDICA_URL_PATH')) ? getenv('FRIENDICA_URL_PATH') : null);
|
||||
$php_path = $this->getOption(['b', 'phppath'], (!empty('FRIENDICA_PHP_PATH')) ? getenv('FRIENDICA_PHP_PATH') : null);
|
||||
$admin_mail = $this->getOption(['A', 'admin'], (!empty('FRIENDICA_ADMIN_MAIL')) ? getenv('FRIENDICA_ADMIN_MAIL') : '');
|
||||
$tz = $this->getOption(['T', 'tz'], (!empty('FRIENDICA_TZ')) ? getenv('FRIENDICA_TZ') : '');
|
||||
$lang = $this->getOption(['L', 'lang'], (!empty('FRIENDICA_LANG')) ? getenv('FRIENDICA_LANG') : '');
|
||||
|
||||
Install::createConfig(
|
||||
$install->createConfig(
|
||||
$php_path,
|
||||
$url_path,
|
||||
((!empty($db_port)) ? $db_host . ':' . $db_port : $db_host),
|
||||
$db_user,
|
||||
$db_pass,
|
||||
$db_data,
|
||||
$php_path,
|
||||
$tz,
|
||||
$lang,
|
||||
$admin_mail
|
||||
$admin_mail,
|
||||
$a->getBasePath()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -126,7 +131,10 @@ HELP;
|
|||
$this->out("Checking basic setup...\n");
|
||||
|
||||
$checkResults = [];
|
||||
$checkResults['basic'] = $this->runBasicChecks($a);
|
||||
|
||||
$this->runBasicChecks($install);
|
||||
|
||||
$checkResults['basic'] = $install->getChecks();
|
||||
$errorMessage = $this->extractErrors($checkResults['basic']);
|
||||
|
||||
if ($errorMessage !== '') {
|
||||
|
@ -151,7 +159,7 @@ HELP;
|
|||
// Install database
|
||||
$this->out("Inserting data into database...\n");
|
||||
|
||||
$checkResults['data'] = Install::installDatabaseStructure();
|
||||
$checkResults['data'] = DBStructure::update(false, true, true);
|
||||
|
||||
if ($checkResults['data'] !== '') {
|
||||
throw new RuntimeException("ERROR: DB Database creation error. Is the DB empty?\n");
|
||||
|
@ -174,28 +182,26 @@ HELP;
|
|||
}
|
||||
|
||||
/**
|
||||
* @param App $app
|
||||
* @return array
|
||||
* @param Install $install the Installer instance
|
||||
*/
|
||||
private function runBasicChecks($app)
|
||||
private function runBasicChecks(Install $install)
|
||||
{
|
||||
$checks = [];
|
||||
|
||||
Install::checkFunctions($checks);
|
||||
Install::checkImagick($checks);
|
||||
Install::checkLocalIni($checks);
|
||||
Install::checkSmarty3($checks);
|
||||
Install::checkKeys($checks);
|
||||
$install->resetChecks();
|
||||
$install->checkFunctions();
|
||||
$install->checkImagick();
|
||||
$install->checkLocalIni();
|
||||
$install->checkSmarty3();
|
||||
$install->checkKeys();
|
||||
|
||||
if (!empty(Config::get('config', 'php_path'))) {
|
||||
Install::checkPHP(Config::get('config', 'php_path'), $checks);
|
||||
if (!$install->checkPHP(Config::get('config', 'php_path'), true)) {
|
||||
throw new RuntimeException(" ERROR: The php_path is not valid in the config.\n");
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException(" ERROR: The php_path is not set in the config.\n");
|
||||
}
|
||||
|
||||
$this->out(" NOTICE: Not checking .htaccess/URL-Rewrite during CLI installation.\n");
|
||||
|
||||
return $checks;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -203,6 +209,7 @@ HELP;
|
|||
* @param $db_user
|
||||
* @param $db_pass
|
||||
* @param $db_data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function runDatabaseCheck($db_host, $db_user, $db_pass, $db_data)
|
||||
|
|
178
src/Core/Console/Cache.php
Normal file
178
src/Core/Console/Cache.php
Normal file
|
@ -0,0 +1,178 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Core\Console;
|
||||
|
||||
use Asika\SimpleConsole\CommandArgsException;
|
||||
use Friendica\App;
|
||||
use Friendica\Core;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* @brief tool to access the cache from the CLI
|
||||
*
|
||||
* With this script you can access the cache of your node from the CLI.
|
||||
* You can read current values stored in the cache and set new values
|
||||
* in cache keys.
|
||||
*
|
||||
* @author Hypolite Petovan <hypolite@mrpetovan.com>
|
||||
*/
|
||||
class Cache extends \Asika\SimpleConsole\Console
|
||||
{
|
||||
protected $helpOptions = ['h', 'help', '?'];
|
||||
|
||||
protected function getHelp()
|
||||
{
|
||||
$help = <<<HELP
|
||||
console cache - Manage node cache
|
||||
Synopsis
|
||||
bin/console cache list [-h|--help|-?] [-v]
|
||||
bin/console cache get <key> [-h|--help|-?] [-v]
|
||||
bin/console cache set <key> <value> [-h|--help|-?] [-v]
|
||||
bin/console cache flush [-h|--help|-?] [-v]
|
||||
bin/console cache clear [-h|--help|-?] [-v]
|
||||
|
||||
Description
|
||||
bin/console cache list [<prefix>]
|
||||
List all cache keys, optionally filtered by a prefix
|
||||
|
||||
bin/console cache get <key>
|
||||
Shows the value of the provided cache key
|
||||
|
||||
bin/console cache set <key> <value> [<ttl>]
|
||||
Sets the value of the provided cache key, optionally with the provided TTL (time to live) with a default of five minutes.
|
||||
|
||||
bin/console cache flush
|
||||
Clears expired cache keys
|
||||
|
||||
bin/console cache clear
|
||||
Clears all cache keys
|
||||
|
||||
Options
|
||||
-h|--help|-? Show help information
|
||||
-v Show more debug information.
|
||||
HELP;
|
||||
return $help;
|
||||
}
|
||||
|
||||
protected function doExecute()
|
||||
{
|
||||
$a = \Friendica\BaseObject::getApp();
|
||||
|
||||
if ($this->getOption('v')) {
|
||||
$this->out('Executable: ' . $this->executable);
|
||||
$this->out('Class: ' . __CLASS__);
|
||||
$this->out('Arguments: ' . var_export($this->args, true));
|
||||
$this->out('Options: ' . var_export($this->options, true));
|
||||
}
|
||||
|
||||
if ($a->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
$this->out('Database isn\'t ready or populated yet, database cache won\'t be available');
|
||||
}
|
||||
|
||||
Core\Cache::init();
|
||||
|
||||
if ($this->getOption('v')) {
|
||||
$this->out('Cache Driver Name: ' . Core\Cache::$driver_name);
|
||||
$this->out('Cache Driver Class: ' . Core\Cache::$driver_class);
|
||||
}
|
||||
|
||||
switch ($this->getArgument(0)) {
|
||||
case 'list':
|
||||
$this->executeList();
|
||||
break;
|
||||
case 'get':
|
||||
$this->executeGet();
|
||||
break;
|
||||
case 'set':
|
||||
$this->executeSet();
|
||||
break;
|
||||
case 'flush':
|
||||
$this->executeFlush();
|
||||
break;
|
||||
case 'clear':
|
||||
$this->executeClear();
|
||||
break;
|
||||
}
|
||||
|
||||
if (count($this->args) == 0) {
|
||||
$this->out($this->getHelp());
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function executeList()
|
||||
{
|
||||
$prefix = $this->getArgument(1);
|
||||
$keys = Core\Cache::getAllKeys($prefix);
|
||||
|
||||
if (empty($prefix)) {
|
||||
$this->out('Listing all cache keys:');
|
||||
} else {
|
||||
$this->out('Listing all cache keys starting with "' . $prefix . '":');
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
foreach ($keys as $key) {
|
||||
$this->out($key);
|
||||
$count++;
|
||||
}
|
||||
|
||||
$this->out($count . ' keys found');
|
||||
}
|
||||
|
||||
private function executeGet()
|
||||
{
|
||||
if (count($this->args) >= 2) {
|
||||
$key = $this->getArgument(1);
|
||||
$value = Core\Cache::get($key);
|
||||
|
||||
$this->out("{$key} => " . var_export($value, true));
|
||||
} else {
|
||||
throw new CommandArgsException('Too few arguments for get');
|
||||
}
|
||||
}
|
||||
|
||||
private function executeSet()
|
||||
{
|
||||
if (count($this->args) >= 3) {
|
||||
$key = $this->getArgument(1);
|
||||
$value = $this->getArgument(2);
|
||||
$duration = intval($this->getArgument(3, Core\Cache::FIVE_MINUTES));
|
||||
|
||||
if (is_array(Core\Cache::get($key))) {
|
||||
throw new RuntimeException("$key is an array and can't be set using this command.");
|
||||
}
|
||||
|
||||
$result = Core\Cache::set($key, $value, $duration);
|
||||
if ($result) {
|
||||
$this->out("{$key} <= " . Core\Cache::get($key));
|
||||
} else {
|
||||
$this->out("Unable to set {$key}");
|
||||
}
|
||||
} else {
|
||||
throw new CommandArgsException('Too few arguments for set');
|
||||
}
|
||||
}
|
||||
|
||||
private function executeFlush()
|
||||
{
|
||||
$result = Core\Cache::clear();
|
||||
if ($result) {
|
||||
$this->out('Cache successfully flushed');
|
||||
} else {
|
||||
$this->out('Unable to flush the cache');
|
||||
}
|
||||
}
|
||||
|
||||
private function executeClear()
|
||||
{
|
||||
$result = Core\Cache::clear(false);
|
||||
if ($result) {
|
||||
$this->out('Cache successfully cleared');
|
||||
} else {
|
||||
$this->out('Unable to flush the cache');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
namespace Friendica\Core\Console;
|
||||
|
||||
use Asika\SimpleConsole\CommandArgsException;
|
||||
|
@ -13,9 +7,6 @@ use Friendica\App;
|
|||
use Friendica\Core;
|
||||
use RuntimeException;
|
||||
|
||||
require_once 'include/dba.php';
|
||||
require_once 'include/text.php';
|
||||
|
||||
/**
|
||||
* @brief tool to access the system config from the CLI
|
||||
*
|
||||
|
@ -80,7 +71,7 @@ HELP;
|
|||
|
||||
protected function doExecute()
|
||||
{
|
||||
$a = get_app();
|
||||
$a = \Friendica\BaseObject::getApp();
|
||||
|
||||
if ($this->getOption('v')) {
|
||||
$this->out('Executable: ' . $this->executable);
|
||||
|
@ -93,7 +84,7 @@ HELP;
|
|||
throw new CommandArgsException('Too many arguments');
|
||||
}
|
||||
|
||||
if (!($a->mode & App::MODE_DBCONFIGAVAILABLE)) {
|
||||
if (!$a->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
$this->out('Database isn\'t ready or populated yet, showing file config only');
|
||||
}
|
||||
|
||||
|
@ -152,7 +143,7 @@ HELP;
|
|||
if (count($this->args) == 0) {
|
||||
Core\Config::load();
|
||||
|
||||
if (Core\Config::get('system', 'config_adapter') == 'jit' && $a->mode & App::MODE_DBCONFIGAVAILABLE) {
|
||||
if (Core\Config::get('system', 'config_adapter') == 'jit' && $a->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
$this->out('Warning: The JIT (Just In Time) Config adapter doesn\'t support loading the entire configuration, showing file config only');
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue