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\Util\Arrays;
use Friendica\Util\Network;
use Friendica\Util\Strings;
use Friendica\Util\Temporal;
+use Psr\Log\LogLevel;
/**
* Sets the current theme for theme settings pages.
* return the HTML for the pages of the admin panel.
*
* @param App $a
- *
+ * @throws ImagickException
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function admin_post(App $a)
{
*
* @param App $a
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function admin_content(App $a)
{
if ($a->isAjax()) {
echo $o;
- killme();
- return '';
+ exit();
} else {
return $o;
}
*
* @param App $a
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function admin_page_tos(App $a)
{
* @brief Process send data from Admin TOS Page
*
* @param App $a
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function admin_page_tos_post(App $a)
{
*
* @param App $a
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function admin_page_blocklist(App $a)
{
* @brief Process send data from Admin Blocklist Page
*
* @param App $a
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function admin_page_blocklist_post(App $a)
{
* @brief Process data send by the contact block admin page
*
* @param App $a
+ * @throws ImagickException
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function admin_page_contactblock_post(App $a)
{
*
* @param App $a
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function admin_page_contactblock(App $a)
{
*
* @param App $a
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function admin_page_deleteitem(App $a)
{
* URLs like the full /display URL to make the process more easy for the admin.
*
* @param App $a
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function admin_page_deleteitem_post(App $a)
{
*
* @param App $a
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function admin_page_federation(App $a)
{
*
* @param App $a
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function admin_page_queue(App $a)
{
* The returned string holds the content of the page.
*
* @param App $a
+ * @param $deferred
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function admin_page_workerqueue(App $a, $deferred)
{
*
* @param App $a
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function admin_page_summary(App $a)
{
* @brief Process send data from Admin Site Page
*
* @param App $a
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function admin_page_site_post(App $a)
{
$relay_server_tags = (!empty($_POST['relay_server_tags']) ? Strings::escapeTags(trim($_POST['relay_server_tags'])) : '');
$relay_user_tags = !empty($_POST['relay_user_tags']);
$active_panel = (!empty($_POST['active_panel']) ? "#" . Strings::escapeTags(trim($_POST['active_panel'])) : '');
-
+
+ /**
+ * @var $storagebackend \Friendica\Model\Storage\IStorage
+ */
$storagebackend = Strings::escapeTags(trim(defaults($_POST, 'storagebackend', '')));
StorageManager::setBackend($storagebackend);
-
+
// save storage backend form
- $storage_opts = $storagebackend::getOptions();
- $storage_form_prefix=preg_replace('|[^a-zA-Z0-9]|' ,'', $storagebackend);
- $storage_opts_data = [];
- foreach($storage_opts as $name => $info) {
- $fieldname = $storage_form_prefix . '_' . $name;
- switch ($info[0]) { // type
- case 'checkbox':
- case 'yesno':
- $value = !empty($_POST[$fieldname]);
- break;
- default:
- $value = defaults($_POST, $fieldname, '');
+ if (!is_null($storagebackend) && $storagebackend != "") {
+ $storage_opts = $storagebackend::getOptions();
+ $storage_form_prefix=preg_replace('|[^a-zA-Z0-9]|' ,'', $storagebackend);
+ $storage_opts_data = [];
+ foreach($storage_opts as $name => $info) {
+ $fieldname = $storage_form_prefix . '_' . $name;
+ switch ($info[0]) { // type
+ case 'checkbox':
+ case 'yesno':
+ $value = !empty($_POST[$fieldname]);
+ break;
+ default:
+ $value = defaults($_POST, $fieldname, '');
+ }
+ $storage_opts_data[$name] = $value;
}
- $storage_opts_data[$name] = $value;
- }
- unset($name);
- unset($info);
+ unset($name);
+ unset($info);
- $storage_form_errors = $storagebackend::saveOptions($storage_opts_data);
- if (count($storage_form_errors)) {
- foreach($storage_form_errors as $name => $err) {
- notice('Storage backend, ' . $storage_opts[$name][1] . ': ' . $err);
+ $storage_form_errors = $storagebackend::saveOptions($storage_opts_data);
+ if (count($storage_form_errors)) {
+ foreach($storage_form_errors as $name => $err) {
+ notice('Storage backend, ' . $storage_opts[$name][1] . ': ' . $err);
+ }
+ $a->internalRedirect('admin/site' . $active_panel);
}
- $a->internalRedirect('admin/site' . $active_panel);
}
-
Config::set('system', 'banner', $banner);
}
- if ($info == "") {
+ if (empty($info)) {
Config::delete('config', 'info');
} else {
Config::set('config', 'info', $info);
*
* @param App $a
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function admin_page_site(App $a)
{
/* Register policy */
$register_choices = [
- REGISTER_CLOSED => L10n::t("Closed"),
- REGISTER_APPROVE => L10n::t("Requires approval"),
- REGISTER_OPEN => L10n::t("Open")
+ Module\Register::CLOSED => L10n::t("Closed"),
+ Module\Register::APPROVE => L10n::t("Requires approval"),
+ Module\Register::OPEN => L10n::t("Open")
];
$ssl_choices = [
/* storage backend */
$storage_backends = StorageManager::listBackends();
+ /**
+ * @var $storage_current_backend \Friendica\Model\Storage\IStorage
+ */
$storage_current_backend = StorageManager::getBackend();
$storage_backends_choices = [
$storage_form_prefix=preg_replace('|[^a-zA-Z0-9]|' ,'', $storage_current_backend);
$storage_form = [];
- foreach($storage_current_backend::getOptions() as $name => $info) {
- $type = $info[0];
- $info[0] = $storage_form_prefix . '_' . $name;
- $info['type'] = $type;
- $info['field'] = 'field_' . $type . '.tpl';
- $storage_form[$name] = $info;
+ if (!is_null($storage_current_backend) && $storage_current_backend != "") {
+ foreach($storage_current_backend::getOptions() as $name => $info) {
+ $type = $info[0];
+ $info[0] = $storage_form_prefix . '_' . $name;
+ $info['type'] = $type;
+ $info['field'] = 'field_' . $type . '.tpl';
+ $storage_form[$name] = $info;
+ }
}
*
* @param App $a
* @return string
- * */
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ */
function admin_page_dbsync(App $a)
{
$o = '';
* @brief Process data send by Users admin page
*
* @param App $a
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function admin_page_users_post(App $a)
{
*
* @param App $a
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function admin_page_users(App $a)
{
$adminlist = explode(",", str_replace(" ", "", Config::get('config', 'admin_email')));
$_setup_users = function ($e) use ($adminlist) {
$page_types = [
- Contact::PAGE_NORMAL => L10n::t('Normal Account Page'),
- Contact::PAGE_SOAPBOX => L10n::t('Soapbox Page'),
- Contact::PAGE_COMMUNITY => L10n::t('Public Forum'),
- Contact::PAGE_FREELOVE => L10n::t('Automatic Friend Page'),
- Contact::PAGE_PRVGROUP => L10n::t('Private Forum')
+ User::PAGE_FLAGS_NORMAL => L10n::t('Normal Account Page'),
+ User::PAGE_FLAGS_SOAPBOX => L10n::t('Soapbox Page'),
+ User::PAGE_FLAGS_COMMUNITY => L10n::t('Public Forum'),
+ User::PAGE_FLAGS_FREELOVE => L10n::t('Automatic Friend Page'),
+ User::PAGE_FLAGS_PRVGROUP => L10n::t('Private Forum')
];
$account_types = [
- Contact::ACCOUNT_TYPE_PERSON => L10n::t('Personal Page'),
- Contact::ACCOUNT_TYPE_ORGANISATION => L10n::t('Organisation Page'),
- Contact::ACCOUNT_TYPE_NEWS => L10n::t('News Page'),
- Contact::ACCOUNT_TYPE_COMMUNITY => L10n::t('Community Forum')
+ User::ACCOUNT_TYPE_PERSON => L10n::t('Personal Page'),
+ User::ACCOUNT_TYPE_ORGANISATION => L10n::t('Organisation Page'),
+ User::ACCOUNT_TYPE_NEWS => L10n::t('News Page'),
+ User::ACCOUNT_TYPE_COMMUNITY => L10n::t('Community Forum'),
+ User::ACCOUNT_TYPE_RELAY => L10n::t('Relay'),
];
$e['page_flags_raw'] = $e['page-flags'];
* @param App $a
* @param array $addons_admin A list of admin addon names
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function admin_page_addons(App $a, array $addons_admin)
{
*
* @param App $a
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function admin_page_themes(App $a)
{
* @brief Prosesses data send by Logs admin page
*
* @param App $a
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function admin_page_logs_post(App $a)
{
$logfile = (!empty($_POST['logfile']) ? Strings::escapeTags(trim($_POST['logfile'])) : '');
$debugging = !empty($_POST['debugging']);
- $loglevel = (!empty($_POST['loglevel']) ? intval(trim($_POST['loglevel'])) : 0);
+ $loglevel = defaults($_POST, 'loglevel', LogLevel::ERROR);
Config::set('system', 'logfile', $logfile);
Config::set('system', 'debugging', $debugging);
*
* @param App $a
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function admin_page_logs(App $a)
{
$log_choices = [
- Logger::WARNING => 'Warning',
- Logger::INFO => 'Info',
- Logger::TRACE => 'Trace',
- Logger::DEBUG => 'Debug',
- Logger::DATA => 'Data',
- Logger::ALL => 'All'
+ LogLevel::ERROR => 'Error',
+ LogLevel::WARNING => 'Warning',
+ LogLevel::NOTICE => 'Notice',
+ LogLevel::INFO => 'Info',
+ LogLevel::DEBUG => 'Debug',
];
if (ini_get('log_errors')) {
*
* @param App $a
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function admin_page_viewlogs(App $a)
{
* @brief Prosesses data send by the features admin page
*
* @param App $a
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function admin_page_features_post(App $a)
{
*
* @param App $a
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function admin_page_features(App $a)
{