1
0
Fork 0
friendica_2020-09-1_sharedH.../mod/admin.php

180 lines
5.7 KiB
PHP
Raw Normal View History

2011-06-13 12:52:29 +02:00
<?php
2017-11-30 02:28:30 +01:00
/**
* @file mod/admin.php
*
* @brief Friendica admin
*/
2018-01-15 00:59:08 +01:00
use Friendica\App;
use Friendica\BaseModule;
use Friendica\Content\Feature;
use Friendica\Content\Pager;
2018-01-15 00:59:08 +01:00
use Friendica\Content\Text\Markdown;
2017-04-30 06:01:26 +02:00
use Friendica\Core\Config;
use Friendica\Core\L10n;
2018-10-29 22:20:46 +01:00
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
2019-02-03 22:22:04 +01:00
use Friendica\Core\StorageManager;
2018-01-15 00:59:08 +01:00
use Friendica\Core\System;
use Friendica\Core\Theme;
use Friendica\Core\Update;
2017-11-05 13:15:53 +01:00
use Friendica\Core\Worker;
use Friendica\Database\DBA;
2017-12-14 22:13:02 +01:00
use Friendica\Database\DBStructure;
2017-12-07 15:04:24 +01:00
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\Register;
use Friendica\Model\User;
use Friendica\Module;
use Friendica\Module\Login;
use Friendica\Module\Tos;
use Friendica\Protocol\PortableContact;
use Friendica\Util\Arrays;
2019-02-03 22:22:04 +01:00
use Friendica\Util\BasePath;
use Friendica\Util\BaseURL;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\Strings;
use Friendica\Util\Temporal;
use Psr\Log\LogLevel;
/**
* @brief Process send data from the admin panels subpages
2015-12-26 08:49:38 +01:00
*
2018-10-14 17:32:54 +02:00
* This function acts as relay for processing the data send from the subpages
2015-12-26 08:49:38 +01:00
* of the admin panel. Depending on the 1st parameter of the url (argv[1])
* specialized functions are called to process the data from the subpages.
*
2018-10-14 17:32:54 +02:00
* The function itself does not return anything, but the subsequently function
2015-12-26 08:49:38 +01:00
* return the HTML for the pages of the admin panel.
*
* @param App $a
2019-01-07 07:07:42 +01:00
* @throws ImagickException
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
2017-11-30 02:28:30 +01:00
function admin_post(App $a)
{
if (!is_site_admin()) {
return;
2011-06-13 18:03:06 +02:00
}
// do not allow a page manager to access the admin panel at all.
if (!empty($_SESSION['submanage'])) {
return;
}
$return_path = 'admin';
2011-06-13 18:03:06 +02:00
$a->internalRedirect($return_path);
return; // NOTREACHED
2011-06-13 18:03:06 +02:00
}
2011-06-13 12:52:29 +02:00
/**
* @brief Generates content of the admin panel pages
*
2016-01-19 09:15:32 +01:00
* This function generates the content for the admin panel. It consists of the
* aside menu (same for the entire admin panel) and the code for the soecified
* subpage of the panel.
*
* The structure of the adress is: /admin/subpage/details though "details" is
* only necessary for some subpages, like themes or addons where it is the name
* of one theme resp. addon from which the details should be shown. Content for
* the subpages is generated in separate functions for each of the subpages.
*
* The returned string hold the generated HTML code of the page.
*
* @param App $a
* @return string
2019-01-07 07:07:42 +01:00
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
2017-11-30 02:28:30 +01:00
function admin_content(App $a)
{
if (!is_site_admin()) {
return Login::form();
2011-06-13 12:52:29 +02:00
}
if (!empty($_SESSION['submanage'])) {
return "";
}
// APC deactivated, since there are problems with PHP 5.5
//if (function_exists("apc_delete")) {
// $toDelete = new APCIterator('user', APC_ITER_VALUE);
// apc_delete($toDelete);
//}
// Header stuff
$a->page['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('admin/settings_head.tpl'), []);
/*
2011-06-13 12:52:29 +02:00
* Side bar links
*/
$aside_tools = [];
// array(url, name, extra css classes)
// not part of $aside to make the template more adjustable
$aside_sub = [
'information' => [L10n::t('Information'), [
'overview' => ['admin/', L10n::t('Overview'), 'overview'],
'federation' => ['admin/federation/' , L10n::t('Federation Statistics'), 'federation']]],
'configuration' => [L10n::t('Configuration'), [
'site' => ['admin/site/' , L10n::t('Site') , 'site'],
'users' => ['admin/users/' , L10n::t('Users') , 'users'],
'addons' => ['admin/addons/' , L10n::t('Addons') , 'addons'],
'themes' => ['admin/themes/' , L10n::t('Themes') , 'themes'],
'features' => ['admin/features/' , L10n::t('Additional features') , 'features'],
'tos' => ['admin/tos/' , L10n::t('Terms of Service') , 'tos']]],
'database' => [L10n::t('Database'), [
'dbsync' => ['admin/dbsync/' , L10n::t('DB updates') , 'dbsync'],
'deferred' => ['admin/deferred/' , L10n::t('Inspect Deferred Workers'), 'deferred'],
'workerqueue' => ['admin/workerqueue/' , L10n::t('Inspect worker Queue') , 'workerqueue']]],
'tools' => [L10n::t('Tools'), [
'contactblock' => ['admin/contactblock/', L10n::t('Contact Blocklist') , 'contactblock'],
'blocklist' => ['admin/blocklist/' , L10n::t('Server Blocklist') , 'blocklist'],
'deleteitem' => ['admin/deleteitem/' , L10n::t('Delete Item') , 'deleteitem'],]],
'logs' => [L10n::t('Logs'), [
'logsconfig' => ['admin/logs/', L10n::t('Logs'), 'logs'],
'logsview' => ['admin/viewlogs/', L10n::t('View Logs'), 'viewlogs']
]],
'diagnostics' => [L10n::t('Diagnostics'), [
'phpinfo' => ['phpinfo/', L10n::t('PHP Info'), 'phpinfo'],
'probe' => ['probe/', L10n::t('probe address'), 'probe'],
'webfinger' =>['webfinger/', L10n::t('check webfinger'), 'webfinger']
]]
];
2013-01-27 13:57:44 +01:00
$aside_tools['addons_admin'] = [];
2013-01-27 13:57:44 +01:00
$t = Renderer::getMarkupTemplate('admin/aside.tpl');
$a->page['aside'] .= Renderer::replaceMacros($t, [
'$admin' => $aside_tools,
'$subpages' => $aside_sub,
2018-01-21 19:33:59 +01:00
'$admtxt' => L10n::t('Admin'),
'$plugadmtxt' => L10n::t('Addon Features'),
'$h_pending' => L10n::t('User registrations waiting for confirmation'),
2017-11-30 02:28:30 +01:00
'$admurl' => "admin/"
]);
2011-06-13 12:52:29 +02:00
// Page content
2011-06-13 12:52:29 +02:00
$o = '';
// urls
if ($a->argc > 1) {
switch ($a->argv[1]) {
2011-06-13 12:52:29 +02:00
default:
2018-01-21 19:33:59 +01:00
notice(L10n::t("Item not found."));
2011-06-13 12:52:29 +02:00
}
}
2013-01-27 13:57:44 +01:00
if ($a->isAjax()) {
echo $o;
2018-12-26 06:40:12 +01:00
exit();
2012-04-13 11:20:05 +02:00
} else {
return $o;
}
}
2011-06-13 12:52:29 +02:00
function admin_page_server_vital()
{
// Fetch the host-meta to check if this really is a vital server
return Network::curl(System::baseUrl() . '/.well-known/host-meta')->isSuccess();
}