*/
use Friendica\App;
+use Friendica\BaseModule;
use Friendica\Content\Feature;
+use Friendica\Content\Pager;
use Friendica\Content\Text\Markdown;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
+use Friendica\Core\Logger;
+use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Core\Theme;
+use Friendica\Core\Update;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Database\DBStructure;
use Friendica\Model\Contact;
use Friendica\Model\Item;
+use Friendica\Model\Register;
use Friendica\Model\User;
use Friendica\Module\Login;
use Friendica\Module\Tos;
+use Friendica\Util\Arrays;
use Friendica\Util\DateTimeFormat;
+use Friendica\Util\Network;
+use Friendica\Util\Strings;
use Friendica\Util\Temporal;
require_once 'include/enotify.php';
/**
* @brief Process send data from the admin panels subpages
*
- * This function acts as relais for processing the data send from the subpages
+ * This function acts as relay for processing the data send from the subpages
* 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.
*
- * The function itself does not return anything, but the subsequencely function
+ * The function itself does not return anything, but the subsequently function
* return the HTML for the pages of the admin panel.
*
* @param App $a
break;
case 'themes':
if ($a->argc < 2) {
- if (is_ajax()) {
+ if ($a->isAjax()) {
return;
}
- goaway('admin/');
+ $a->internalRedirect('admin/');
return;
}
$theme = $a->argv[2];
if (is_file("view/theme/$theme/config.php")) {
- $orig_theme = $a->theme;
+ $orig_theme = Renderer::$theme;
$orig_page = $a->page;
$orig_session_theme = $_SESSION['theme'];
require_once "view/theme/$theme/theme.php";
}
$_SESSION['theme'] = $orig_session_theme;
- $a->theme = $orig_theme;
+ Renderer::$theme = $orig_theme;
$a->page = $orig_page;
}
info(L10n::t('Theme settings updated.'));
- if (is_ajax()) {
+ if ($a->isAjax()) {
return;
}
$return_path = 'admin/themes/' . $theme;
}
}
- goaway($return_path);
+ $a->internalRedirect($return_path);
return; // NOTREACHED
}
// apc_delete($toDelete);
//}
// Header stuff
- $a->page['htmlhead'] .= replace_macros(get_markup_template('admin/settings_head.tpl'), []);
+ $a->page['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('admin/settings_head.tpl'), []);
/*
* Side bar links
// 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"],
- 'queue' => ["admin/queue/" , L10n::t('Inspect Queue') , "queue"],
- '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']
+ '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'],
+ 'queue' => ['admin/queue/' , L10n::t('Inspect Queue') , 'queue'],
+ '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']
+ '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']
]]
];
$r = q("SELECT `name` FROM `addon` WHERE `plugin_admin` = 1 ORDER BY `name`");
$aside_tools['addons_admin'] = [];
+ $addons_admin = [];
foreach ($r as $h) {
$addon = $h['name'];
$aside_tools['addons_admin'][] = ["admin/addons/" . $addon, $addon, "addon"];
// temp addons with admin
- $a->addons_admin[] = $addon;
+ $addons_admin[] = $addon;
}
- $t = get_markup_template('admin/aside.tpl');
- $a->page['aside'] .= replace_macros($t, [
+ $t = Renderer::getMarkupTemplate('admin/aside.tpl');
+ $a->page['aside'] .= Renderer::replaceMacros($t, [
'$admin' => $aside_tools,
'$subpages' => $aside_sub,
'$admtxt' => L10n::t('Admin'),
$o = admin_page_users($a);
break;
case 'addons':
- $o = admin_page_addons($a);
+ $o = admin_page_addons($a, $addons_admin);
break;
case 'themes':
$o = admin_page_themes($a);
case 'queue':
$o = admin_page_queue($a);
break;
+ case 'deferred':
+ $o = admin_page_workerqueue($a, true);
+ break;
case 'workerqueue':
- $o = admin_page_workerqueue($a);
+ $o = admin_page_workerqueue($a, false);
break;
case 'federation':
$o = admin_page_federation($a);
$o = admin_page_summary($a);
}
- if (is_ajax()) {
+ if ($a->isAjax()) {
echo $o;
killme();
return '';
function admin_page_tos(App $a)
{
$tos = new Tos();
- $t = get_markup_template('admin/tos.tpl');
- return replace_macros($t, [
+ $t = Renderer::getMarkupTemplate('admin/tos.tpl');
+ return Renderer::replaceMacros($t, [
'$title' => L10n::t('Administration'),
'$page' => L10n::t('Terms of Service'),
'$displaytos' => ['displaytos', L10n::t('Display Terms of Service'), Config::get('system', 'tosdisplay'), L10n::t('Enable the Terms of Service page. If this is enabled a link to the terms will be added to the registration form and the general information page.')],
'$preview' => L10n::t('Privacy Statement Preview'),
'$privtext' => $tos->privacy_complete,
'$tostext' => ['tostext', L10n::t('The Terms of Service'), Config::get('system', 'tostext'), L10n::t('Enter the Terms of Service for your node here. You can use BBCode. Headers of sections should be [h2] and below.')],
- '$form_security_token' => get_form_security_token("admin_tos"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("admin_tos"),
'$submit' => L10n::t('Save Settings'),
]);
}
*/
function admin_page_tos_post(App $a)
{
- check_form_security_token_redirectOnErr('/admin/tos', 'admin_tos');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/admin/tos', 'admin_tos');
if (!x($_POST, "page_tos")) {
return;
Config::set('system', 'tosprivstatement', $displayprivstatement);
Config::set('system', 'tostext', $tostext);
- goaway('admin/tos');
+ $a->internalRedirect('admin/tos');
return; // NOTREACHED
}
];
}
}
- $t = get_markup_template('admin/blocklist.tpl');
- return replace_macros($t, [
+ $t = Renderer::getMarkupTemplate('admin/blocklist.tpl');
+ return Renderer::replaceMacros($t, [
'$title' => L10n::t('Administration'),
'$page' => L10n::t('Server Blocklist'),
'$intro' => L10n::t('This page can be used to define a black list of servers from the federated network that are not allowed to interact with your node. For all entered domains you should also give a reason why you have blocked the remote server.'),
'$entries' => $blocklistform,
'$baseurl' => System::baseUrl(true),
'$confirm_delete' => L10n::t('Delete entry from blocklist?'),
- '$form_security_token' => get_form_security_token("admin_blocklist")
+ '$form_security_token' => BaseModule::getFormSecurityToken("admin_blocklist")
]);
}
return;
}
- check_form_security_token_redirectOnErr('/admin/blocklist', 'admin_blocklist');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/admin/blocklist', 'admin_blocklist');
if (x($_POST['page_blocklist_save'])) {
// Add new item to blocklist
$blocklist = Config::get('system', 'blocklist');
$blocklist[] = [
- 'domain' => notags(trim($_POST['newentry_domain'])),
- 'reason' => notags(trim($_POST['newentry_reason']))
+ 'domain' => Strings::removeTags(trim($_POST['newentry_domain'])),
+ 'reason' => Strings::removeTags(trim($_POST['newentry_reason']))
];
Config::set('system', 'blocklist', $blocklist);
info(L10n::t('Server added to blocklist.') . EOL);
$blocklist = [];
foreach ($_POST['domain'] as $id => $domain) {
// Trimming whitespaces as well as any lingering slashes
- $domain = notags(trim($domain, "\x00..\x1F/"));
- $reason = notags(trim($_POST['reason'][$id]));
+ $domain = Strings::removeTags(trim($domain, "\x00..\x1F/"));
+ $reason = Strings::removeTags(trim($_POST['reason'][$id]));
if (!x($_POST['delete'][$id])) {
$blocklist[] = [
'domain' => $domain,
Config::set('system', 'blocklist', $blocklist);
info(L10n::t('Site blocklist updated.') . EOL);
}
- goaway('admin/blocklist');
+ $a->internalRedirect('admin/blocklist');
return; // NOTREACHED
}
$contact_url = x($_POST, 'contact_url') ? $_POST['contact_url'] : '';
$contacts = x($_POST, 'contacts') ? $_POST['contacts'] : [];
- check_form_security_token_redirectOnErr('/admin/contactblock', 'admin_contactblock');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/admin/contactblock', 'admin_contactblock');
if (x($_POST, 'page_contactblock_block')) {
$contact_id = Contact::getIdForURL($contact_url);
}
notice(L10n::tt("%s contact unblocked", "%s contacts unblocked", count($contacts)));
}
- goaway('admin/contactblock');
+ $a->internalRedirect('admin/contactblock');
return; // NOTREACHED
}
$total = DBA::count('contact', $condition);
- $a->set_pager_total($total);
- $a->set_pager_itemspage(30);
+ $pager = new Pager($a->query_string, 30);
- $statement = DBA::select('contact', [], $condition, ['limit' => [$a->pager['start'], $a->pager['itemspage']]]);
+ $statement = DBA::select('contact', [], $condition, ['limit' => [$pager->getStart(), $pager->getItemsPerPage()]]);
$contacts = DBA::toArray($statement);
- $t = get_markup_template('admin/contactblock.tpl');
- $o = replace_macros($t, [
+ $t = Renderer::getMarkupTemplate('admin/contactblock.tpl');
+ $o = Renderer::replaceMacros($t, [
// strings //
'$title' => L10n::t('Administration'),
'$page' => L10n::t('Remote Contact Blocklist'),
'$h_newblock' => L10n::t('Block New Remote Contact'),
'$th_contacts' => [L10n::t('Photo'), L10n::t('Name'), L10n::t('Address'), L10n::t('Profile URL')],
- '$form_security_token' => get_form_security_token("admin_contactblock"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("admin_contactblock"),
// values //
'$baseurl' => System::baseUrl(true),
'$contacts' => $contacts,
'$total_contacts' => L10n::tt('%s total blocked contact', '%s total blocked contacts', $total),
- '$paginate' => paginate($a),
+ '$paginate' => $pager->renderFull($total),
'$contacturl' => ['contact_url', L10n::t("Profile URL"), '', L10n::t("URL of the remote contact to block.")],
]);
return $o;
*/
function admin_page_deleteitem(App $a)
{
- $t = get_markup_template('admin/deleteitem.tpl');
+ $t = Renderer::getMarkupTemplate('admin/deleteitem.tpl');
- return replace_macros($t, [
+ return Renderer::replaceMacros($t, [
'$title' => L10n::t('Administration'),
'$page' => L10n::t('Delete Item'),
'$submit' => L10n::t('Delete this Item'),
'$intro2' => L10n::t('You need to know the GUID of the item. You can find it e.g. by looking at the display URL. The last part of http://example.com/display/123456 is the GUID, here 123456.'),
'$deleteitemguid' => ['deleteitemguid', L10n::t("GUID"), '', L10n::t("The GUID of the item you want to delete."), 'required', 'autofocus'],
'$baseurl' => System::baseUrl(),
- '$form_security_token' => get_form_security_token("admin_deleteitem")
+ '$form_security_token' => BaseModule::getFormSecurityToken("admin_deleteitem")
]);
}
return;
}
- check_form_security_token_redirectOnErr('/admin/deleteitem/', 'admin_deleteitem');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/admin/deleteitem/', 'admin_deleteitem');
if (x($_POST['page_deleteitem_submit'])) {
- $guid = trim(notags($_POST['deleteitemguid']));
+ $guid = trim(Strings::removeTags($_POST['deleteitemguid']));
// The GUID should not include a "/", so if there is one, we got an URL
// and the last part of it is most likely the GUID.
if (strpos($guid, '/')) {
}
info(L10n::t('Item marked for deletion.') . EOL);
- goaway('admin/deleteitem');
+ $a->internalRedirect('admin/deleteitem');
return; // NOTREACHED
}
$hint = L10n::t('The <em>Auto Discovered Contact Directory</em> feature is not enabled, it will improve the data displayed here.');
// load the template, replace the macros and return the page content
- $t = get_markup_template('admin/federation.tpl');
- return replace_macros($t, [
+ $t = Renderer::getMarkupTemplate('admin/federation.tpl');
+ return Renderer::replaceMacros($t, [
'$title' => L10n::t('Administration'),
'$page' => L10n::t('Federation Statistics'),
'$intro' => $intro,
function admin_page_queue(App $a)
{
// get content from the queue table
- $r = q("SELECT `c`.`name`, `c`.`nurl`, `q`.`id`, `q`.`network`, `q`.`created`, `q`.`last`
- FROM `queue` AS `q`, `contact` AS `c`
- WHERE `c`.`id` = `q`.`cid`
- ORDER BY `q`.`cid`, `q`.`created`;");
+ $entries = DBA::p("SELECT `contact`.`name`, `contact`.`nurl`,
+ `queue`.`id`, `queue`.`network`, `queue`.`created`, `queue`.`last`
+ FROM `queue` INNER JOIN `contact` ON `contact`.`id` = `queue`.`cid`
+ ORDER BY `queue`.`cid`, `queue`.`created`");
+
+ $r = [];
+ while ($entry = DBA::fetch($entries)) {
+ $entry['created'] = DateTimeFormat::local($entry['created']);
+ $entry['last'] = DateTimeFormat::local($entry['last']);
+ $r[] = $entry;
+ }
+ DBA::close($entries);
- $t = get_markup_template('admin/queue.tpl');
- return replace_macros($t, [
+ $t = Renderer::getMarkupTemplate('admin/queue.tpl');
+ return Renderer::replaceMacros($t, [
'$title' => L10n::t('Administration'),
'$page' => L10n::t('Inspect Queue'),
'$count' => count($r),
* @param App $a
* @return string
*/
-function admin_page_workerqueue(App $a)
+function admin_page_workerqueue(App $a, $deferred)
{
// get jobs from the workerqueue table
- $statement = DBA::select('workerqueue', ['id', 'parameter', 'created', 'priority'], ['done' => 0], ['order'=> ['priority']]);
- $r = DBA::toArray($statement);
+ if ($deferred) {
+ $condition = ["NOT `done` AND `next_try` > ?", DateTimeFormat::utcNow()];
+ $sub_title = L10n::t('Inspect Deferred Worker Queue');
+ $info = L10n::t("This page lists the deferred worker jobs. This are jobs that couldn't be executed at the first time.");
+ } else {
+ $condition = ["NOT `done` AND `next_try` < ?", DateTimeFormat::utcNow()];
+ $sub_title = L10n::t('Inspect Worker Queue');
+ $info = L10n::t('This page lists the currently queued worker jobs. These jobs are handled by the worker cronjob you\'ve set up during install.');
+ }
+
+ $entries = DBA::select('workerqueue', ['id', 'parameter', 'created', 'priority'], $condition, ['order'=> ['priority']]);
- for($i = 0; $i < count($r); $i++) {
+ $r = [];
+ while ($entry = DBA::fetch($entries)) {
// fix GH-5469. ref: src/Core/Worker.php:217
- $r[$i]['parameter'] = implode(json_decode($r[$i]['parameter'], true), ': ');
+ $entry['parameter'] = Arrays::recursiveImplode(json_decode($entry['parameter'], true), ': ');
+ $entry['created'] = DateTimeFormat::local($entry['created']);
+ $r[] = $entry;
}
+ DBA::close($entries);
- $t = get_markup_template('admin/workerqueue.tpl');
- return replace_macros($t, [
+ $t = Renderer::getMarkupTemplate('admin/workerqueue.tpl');
+ return Renderer::replaceMacros($t, [
'$title' => L10n::t('Administration'),
- '$page' => L10n::t('Inspect Worker Queue'),
+ '$page' => $sub_title,
'$count' => count($r),
'$id_header' => L10n::t('ID'),
'$param_header' => L10n::t('Job Parameters'),
'$created_header' => L10n::t('Created'),
'$prio_header' => L10n::t('Priority'),
- '$info' => L10n::t('This page lists the currently queued worker jobs. These jobs are handled by the worker cronjob you\'ve set up during install.'),
+ '$info' => $info,
'$entries' => $r,
]);
}
}
}
- if (Config::get('system', 'dbupdate', DB_UPDATE_NOT_CHECKED) == DB_UPDATE_NOT_CHECKED) {
+ if (Config::get('system', 'dbupdate', DBStructure::UPDATE_NOT_CHECKED) == DBStructure::UPDATE_NOT_CHECKED) {
DBStructure::update(false, true);
}
- if (Config::get('system', 'dbupdate') == DB_UPDATE_FAILED) {
+ if (Config::get('system', 'dbupdate') == DBStructure::UPDATE_FAILED) {
$showwarning = true;
$warningtext[] = L10n::t('The database update failed. Please run "php bin/console.php dbstructure update" from the command line and have a look at the errors that might appear.');
}
// 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->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->getBaseURL() . '/help/Install');
}
$r = q("SELECT `page-flags`, COUNT(`uid`) AS `count` FROM `user` GROUP BY `page-flags`");
$users+= $u['count'];
}
- logger('accounts: ' . print_r($accounts, true), LOGGER_DATA);
+ Logger::log('accounts: ' . print_r($accounts, true), Logger::DATA);
- $r = q("SELECT COUNT(`id`) AS `count` FROM `register`");
- $pending = $r[0]['count'];
+ $pending = Register::getPendingCount();
- $r = q("SELECT COUNT(*) AS `total` FROM `queue` WHERE 1");
- $queue = (($r) ? $r[0]['total'] : 0);
+ $queue = DBA::count('queue', []);
- $r = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE NOT `done`");
- $workerqueue = (($r) ? $r[0]['total'] : 0);
+ $deferred = DBA::count('workerqueue', ["`executed` <= ? AND NOT `done` AND `next_try` > ?",
+ DBA::NULL_DATETIME, DateTimeFormat::utcNow()]);
+
+ $workerqueue = DBA::count('workerqueue', ["`executed` <= ? AND NOT `done` AND `next_try` < ?",
+ DBA::NULL_DATETIME, DateTimeFormat::utcNow()]);
// We can do better, but this is a quick queue status
- $queues = ['label' => L10n::t('Message queues'), 'queue' => $queue, 'workerq' => $workerqueue];
+ $queues = ['label' => L10n::t('Message queues'), 'queue' => $queue, 'deferred' => $deferred, 'workerq' => $workerqueue];
+
+ $r = q("SHOW variables LIKE 'max_allowed_packet'");
+ $max_allowed_packet = (($r) ? $r[0]['Value'] : 0);
- $t = get_markup_template('admin/summary.tpl');
- return replace_macros($t, [
+ $server_settings = ['label' => L10n::t('Server Settings'),
+ 'php' => ['upload_max_filesize' => ini_get('upload_max_filesize'),
+ 'post_max_size' => ini_get('post_max_size'),
+ 'memory_limit' => ini_get('memory_limit')],
+ 'mysql' => ['max_allowed_packet' => $max_allowed_packet]];
+
+ $t = Renderer::getMarkupTemplate('admin/summary.tpl');
+ return Renderer::replaceMacros($t, [
'$title' => L10n::t('Administration'),
'$page' => L10n::t('Summary'),
'$queues' => $queues,
'$platform' => FRIENDICA_PLATFORM,
'$codename' => FRIENDICA_CODENAME,
'$build' => Config::get('system', 'build'),
- '$addons' => [L10n::t('Active addons'), $a->addons],
+ '$addons' => [L10n::t('Active addons'), Addon::getEnabledList()],
+ '$serversettings' => $server_settings,
'$showwarning' => $showwarning,
'$warningtext' => $warningtext
]);
*/
function admin_page_site_post(App $a)
{
- check_form_security_token_redirectOnErr('/admin/site', 'admin_site');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/admin/site', 'admin_site');
if (!empty($_POST['republish_directory'])) {
Worker::add(PRIORITY_LOW, 'Directory');
$parsed = @parse_url($new_url);
if (!is_array($parsed) || !x($parsed, 'host') || !x($parsed, 'scheme')) {
notice(L10n::t("Can not parse base url. Must have at least <scheme>://<domain>"));
- goaway('admin/site');
+ $a->internalRedirect('admin/site');
}
/* steps:
* send relocate for every local user
* */
- $old_url = System::baseUrl(true);
+ $old_url = $a->getBaseURL(true);
// Generate host names for relocation the addresses in the format user@address.tld
$new_host = str_replace("http://", "@", normalise_link($new_url));
$old_host = str_replace("http://", "@", normalise_link($old_url));
- function update_table($table_name, $fields, $old_url, $new_url)
+ function update_table(App $a, $table_name, $fields, $old_url, $new_url)
{
$dbold = DBA::escape($old_url);
$dbnew = DBA::escape($new_url);
if (!DBA::isResult($r)) {
notice("Failed updating '$table_name': " . DBA::errorMessage());
- goaway('admin/site');
+ $a->internalRedirect('admin/site');
}
}
// update tables
// update profile links in the format "http://server.tld"
- update_table("profile", ['photo', 'thumb'], $old_url, $new_url);
- update_table("term", ['url'], $old_url, $new_url);
- update_table("contact", ['photo', 'thumb', 'micro', 'url', 'nurl', 'alias', 'request', 'notify', 'poll', 'confirm', 'poco', 'avatar'], $old_url, $new_url);
- update_table("gcontact", ['url', 'nurl', 'photo', 'server_url', 'notify', 'alias'], $old_url, $new_url);
- update_table("item", ['owner-link', 'author-link', 'body', 'plink', 'tag'], $old_url, $new_url);
+ update_table($a, "profile", ['photo', 'thumb'], $old_url, $new_url);
+ update_table($a, "term", ['url'], $old_url, $new_url);
+ update_table($a, "contact", ['photo', 'thumb', 'micro', 'url', 'nurl', 'alias', 'request', 'notify', 'poll', 'confirm', 'poco', 'avatar'], $old_url, $new_url);
+ update_table($a, "gcontact", ['url', 'nurl', 'photo', 'server_url', 'notify', 'alias'], $old_url, $new_url);
+ update_table($a, "item", ['owner-link', 'author-link', 'body', 'plink', 'tag'], $old_url, $new_url);
// update profile addresses in the format "user@server.tld"
- update_table("contact", ['addr'], $old_host, $new_host);
- update_table("gcontact", ['connect', 'addr'], $old_host, $new_host);
+ update_table($a, "contact", ['addr'], $old_host, $new_host);
+ update_table($a, "gcontact", ['connect', 'addr'], $old_host, $new_host);
// 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");
info("Relocation started. Could take a while to complete.");
- goaway('admin/site');
+ $a->internalRedirect('admin/site');
}
// end relocate
- $sitename = ((x($_POST,'sitename')) ? notags(trim($_POST['sitename'])) : '');
- $hostname = ((x($_POST,'hostname')) ? notags(trim($_POST['hostname'])) : '');
- $sender_email = ((x($_POST,'sender_email')) ? notags(trim($_POST['sender_email'])) : '');
+ $sitename = ((x($_POST,'sitename')) ? Strings::removeTags(trim($_POST['sitename'])) : '');
+ $hostname = ((x($_POST,'hostname')) ? Strings::removeTags(trim($_POST['hostname'])) : '');
+ $sender_email = ((x($_POST,'sender_email')) ? Strings::removeTags(trim($_POST['sender_email'])) : '');
$banner = ((x($_POST,'banner')) ? trim($_POST['banner']) : false);
- $shortcut_icon = ((x($_POST,'shortcut_icon')) ? notags(trim($_POST['shortcut_icon'])) : '');
- $touch_icon = ((x($_POST,'touch_icon')) ? notags(trim($_POST['touch_icon'])) : '');
+ $shortcut_icon = ((x($_POST,'shortcut_icon')) ? Strings::removeTags(trim($_POST['shortcut_icon'])) : '');
+ $touch_icon = ((x($_POST,'touch_icon')) ? Strings::removeTags(trim($_POST['touch_icon'])) : '');
$info = ((x($_POST,'info')) ? trim($_POST['info']) : false);
- $language = ((x($_POST,'language')) ? notags(trim($_POST['language'])) : '');
- $theme = ((x($_POST,'theme')) ? notags(trim($_POST['theme'])) : '');
- $theme_mobile = ((x($_POST,'theme_mobile')) ? notags(trim($_POST['theme_mobile'])) : '');
+ $language = ((x($_POST,'language')) ? Strings::removeTags(trim($_POST['language'])) : '');
+ $theme = ((x($_POST,'theme')) ? Strings::removeTags(trim($_POST['theme'])) : '');
+ $theme_mobile = ((x($_POST,'theme_mobile')) ? Strings::removeTags(trim($_POST['theme_mobile'])) : '');
$maximagesize = ((x($_POST,'maximagesize')) ? intval(trim($_POST['maximagesize'])) : 0);
$maximagelength = ((x($_POST,'maximagelength')) ? intval(trim($_POST['maximagelength'])) : MAX_IMAGE_LENGTH);
$jpegimagequality = ((x($_POST,'jpegimagequality')) ? intval(trim($_POST['jpegimagequality'])) : JPEG_QUALITY);
$register_text = ((x($_POST,'register_text')) ? strip_tags(trim($_POST['register_text'])) : '');
- $allowed_sites = ((x($_POST,'allowed_sites')) ? notags(trim($_POST['allowed_sites'])) : '');
- $allowed_email = ((x($_POST,'allowed_email')) ? notags(trim($_POST['allowed_email'])) : '');
- $forbidden_nicknames = ((x($_POST,'forbidden_nicknames')) ? strtolower(notags(trim($_POST['forbidden_nicknames']))) : '');
+ $allowed_sites = ((x($_POST,'allowed_sites')) ? Strings::removeTags(trim($_POST['allowed_sites'])) : '');
+ $allowed_email = ((x($_POST,'allowed_email')) ? Strings::removeTags(trim($_POST['allowed_email'])) : '');
+ $forbidden_nicknames = ((x($_POST,'forbidden_nicknames')) ? strtolower(Strings::removeTags(trim($_POST['forbidden_nicknames']))) : '');
$no_oembed_rich_content = x($_POST,'no_oembed_rich_content');
- $allowed_oembed = ((x($_POST,'allowed_oembed')) ? notags(trim($_POST['allowed_oembed'])) : '');
+ $allowed_oembed = ((x($_POST,'allowed_oembed')) ? Strings::removeTags(trim($_POST['allowed_oembed'])) : '');
$block_public = ((x($_POST,'block_public')) ? True : False);
$force_publish = ((x($_POST,'publish_all')) ? True : False);
- $global_directory = ((x($_POST,'directory')) ? notags(trim($_POST['directory'])) : '');
+ $global_directory = ((x($_POST,'directory')) ? Strings::removeTags(trim($_POST['directory'])) : '');
$newuser_private = ((x($_POST,'newuser_private')) ? True : False);
$enotify_no_content = ((x($_POST,'enotify_no_content')) ? True : False);
$private_addons = ((x($_POST,'private_addons')) ? True : False);
$max_author_posts_community_page = ((x($_POST,'max_author_posts_community_page')) ? intval(trim($_POST['max_author_posts_community_page'])) : 0);
$verifyssl = ((x($_POST,'verifyssl')) ? True : False);
- $proxyuser = ((x($_POST,'proxyuser')) ? notags(trim($_POST['proxyuser'])) : '');
- $proxy = ((x($_POST,'proxy')) ? notags(trim($_POST['proxy'])) : '');
+ $proxyuser = ((x($_POST,'proxyuser')) ? Strings::removeTags(trim($_POST['proxyuser'])) : '');
+ $proxy = ((x($_POST,'proxy')) ? Strings::removeTags(trim($_POST['proxy'])) : '');
$timeout = ((x($_POST,'timeout')) ? intval(trim($_POST['timeout'])) : 60);
$maxloadavg = ((x($_POST,'maxloadavg')) ? intval(trim($_POST['maxloadavg'])) : 50);
$maxloadavg_frontend = ((x($_POST,'maxloadavg_frontend')) ? intval(trim($_POST['maxloadavg_frontend'])) : 50);
$dbclean_expire_days = ((x($_POST,'dbclean_expire_days')) ? intval($_POST['dbclean_expire_days']) : 0);
$dbclean_unclaimed = ((x($_POST,'dbclean_unclaimed')) ? intval($_POST['dbclean_unclaimed']) : 0);
$suppress_tags = ((x($_POST,'suppress_tags')) ? True : False);
- $itemcache = ((x($_POST,'itemcache')) ? notags(trim($_POST['itemcache'])) : '');
+ $itemcache = ((x($_POST,'itemcache')) ? Strings::removeTags(trim($_POST['itemcache'])) : '');
$itemcache_duration = ((x($_POST,'itemcache_duration')) ? intval($_POST['itemcache_duration']) : 0);
$max_comments = ((x($_POST,'max_comments')) ? intval($_POST['max_comments']) : 0);
- $temppath = ((x($_POST,'temppath')) ? notags(trim($_POST['temppath'])) : '');
- $basepath = ((x($_POST,'basepath')) ? notags(trim($_POST['basepath'])) : '');
- $singleuser = ((x($_POST,'singleuser')) ? notags(trim($_POST['singleuser'])) : '');
+ $temppath = ((x($_POST,'temppath')) ? Strings::removeTags(trim($_POST['temppath'])) : '');
+ $basepath = ((x($_POST,'basepath')) ? Strings::removeTags(trim($_POST['basepath'])) : '');
+ $singleuser = ((x($_POST,'singleuser')) ? Strings::removeTags(trim($_POST['singleuser'])) : '');
$proxy_disabled = ((x($_POST,'proxy_disabled')) ? True : False);
$only_tag_search = ((x($_POST,'only_tag_search')) ? True : False);
$rino = ((x($_POST,'rino')) ? intval($_POST['rino']) : 0);
- $check_new_version_url = ((x($_POST, 'check_new_version_url')) ? notags(trim($_POST['check_new_version_url'])) : 'none');
+ $check_new_version_url = ((x($_POST, 'check_new_version_url')) ? Strings::removeTags(trim($_POST['check_new_version_url'])) : 'none');
$worker_queues = ((x($_POST,'worker_queues')) ? intval($_POST['worker_queues']) : 10);
$worker_dont_fork = ((x($_POST,'worker_dont_fork')) ? True : False);
$worker_frontend = ((x($_POST,'worker_frontend')) ? True : False);
$relay_directly = ((x($_POST,'relay_directly')) ? True : False);
- $relay_server = ((x($_POST,'relay_server')) ? notags(trim($_POST['relay_server'])) : '');
+ $relay_server = ((x($_POST,'relay_server')) ? Strings::removeTags(trim($_POST['relay_server'])) : '');
$relay_subscribe = ((x($_POST,'relay_subscribe')) ? True : False);
- $relay_scope = ((x($_POST,'relay_scope')) ? notags(trim($_POST['relay_scope'])) : '');
- $relay_server_tags = ((x($_POST,'relay_server_tags')) ? notags(trim($_POST['relay_server_tags'])) : '');
+ $relay_scope = ((x($_POST,'relay_scope')) ? Strings::removeTags(trim($_POST['relay_scope'])) : '');
+ $relay_server_tags = ((x($_POST,'relay_server_tags')) ? Strings::removeTags(trim($_POST['relay_server_tags'])) : '');
$relay_user_tags = ((x($_POST,'relay_user_tags')) ? True : False);
// Has the directory url changed? If yes, then resubmit the existing profiles there
Worker::add(PRIORITY_LOW, 'Directory');
}
- if ($a->get_path() != "") {
+ if ($a->getURLPath() != "") {
$diaspora_enabled = false;
}
if ($ssl_policy != intval(Config::get('system', 'ssl_policy'))) {
Config::set('system', 'dbclean-expire-unclaimed', $dbclean_unclaimed);
if ($itemcache != '') {
- $itemcache = App::realpath($itemcache);
+ $itemcache = App::getRealPath($itemcache);
}
Config::set('system', 'itemcache', $itemcache);
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);
Config::set('system', 'rino_encrypt', $rino);
info(L10n::t('Site settings updated.') . EOL);
- goaway('admin/site');
+ $a->internalRedirect('admin/site');
return; // NOTREACHED
}
];
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);
$optimize_max_tablesize = -1;
}
- $t = get_markup_template('admin/site.tpl');
- return replace_macros($t, [
+ $t = Renderer::getMarkupTemplate('admin/site.tpl');
+ return Renderer::replaceMacros($t, [
'$title' => L10n::t('Administration'),
'$page' => L10n::t('Site'),
'$submit' => L10n::t('Save Settings'),
'$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."),
'$relay_server_tags' => ['relay_server_tags', L10n::t("Server tags"), Config::get('system','relay_server_tags'), L10n::t("Comma separated list of tags for the 'tags' subscription.")],
'$relay_user_tags' => ['relay_user_tags', L10n::t("Allow user tags"), Config::get('system', 'relay_user_tags', true), L10n::t("If enabled, the tags from the saved searches will used for the 'tags' subscription in addition to the 'relay_server_tags'.")],
- '$form_security_token' => get_form_security_token("admin_site"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("admin_site"),
'$relocate_button' => L10n::t('Start Relocation'),
]);
}
Config::set('system', 'build', intval($curr) + 1);
}
info(L10n::t('Update has been marked successful') . EOL);
- goaway('admin/dbsync');
+ $a->internalRedirect('admin/dbsync');
}
if (($a->argc > 2) && (intval($a->argv[2]) || ($a->argv[2] === 'check'))) {
$retval = DBStructure::update(false, true);
if ($retval === '') {
$o .= L10n::t("Database structure update %s was successfully applied.", DB_UPDATE_VERSION) . "<br />";
- Config::set('database', 'dbupdate_' . DB_UPDATE_VERSION, 'success');
+ Config::set('database', 'last_successful_update', DB_UPDATE_VERSION);
+ Config::set('database', 'last_successful_update_time', time());
} else {
$o .= L10n::t("Executing of database structure update %s failed with error: %s", DB_UPDATE_VERSION, $retval) . "<br />";
}
if (function_exists($func)) {
$retval = $func();
- if ($retval === UPDATE_FAILED) {
+ if ($retval === Update::FAILED) {
$o .= L10n::t("Executing %s failed with error: %s", $func, $retval);
- } elseif ($retval === UPDATE_SUCCESS) {
+ } elseif ($retval === Update::SUCCESS) {
$o .= L10n::t('Update %s was successfully applied.', $func);
Config::set('database', $func, 'success');
} else {
}
if (!count($failed)) {
- $o = replace_macros(get_markup_template('structure_check.tpl'), [
+ $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('structure_check.tpl'), [
'$base' => System::baseUrl(true),
'$banner' => L10n::t('No failed updates.'),
'$check' => L10n::t('Check database structure'),
]);
} else {
- $o = replace_macros(get_markup_template('failed_updates.tpl'), [
+ $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('failed_updates.tpl'), [
'$base' => System::baseUrl(true),
'$banner' => L10n::t('Failed Updates'),
'$desc' => L10n::t('This does not include updates prior to 1139, which did not return a status.'),
$nu_email = defaults($_POST, 'new_user_email' , '');
$nu_language = Config::get('system', 'language');
- check_form_security_token_redirectOnErr('/admin/users', 'admin_users');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/admin/users', 'admin_users');
if (!($nu_name === "") && !($nu_email === "") && !($nu_nickname === "")) {
try {
$body = sprintf($body, System::baseUrl(), $user['email'], $result['password'], Config::get('config', 'sitename'));
notification([
- 'type' => SYSTEM_EMAIL,
+ 'type' => SYSTEM_EMAIL,
+ 'language' => $user['language'],
+ 'to_name' => $user['username'],
'to_email' => $user['email'],
- 'subject' => L10n::t('Registration details for %s', Config::get('config', 'sitename')),
+ 'uid' => $user['uid'],
+ 'subject' => L10n::t('Registration details for %s', Config::get('config', 'sitename')),
'preamble' => $preamble,
- 'body' => $body]);
+ 'body' => $body]);
}
if (x($_POST, 'page_users_block')) {
user_deny($hash);
}
}
- goaway('admin/users');
+ $a->internalRedirect('admin/users');
return; // NOTREACHED
}
$user = DBA::selectFirst('user', ['username', 'blocked'], ['uid' => $uid]);
if (!DBA::isResult($user)) {
notice('User not found' . EOL);
- goaway('admin/users');
+ $a->internalRedirect('admin/users');
return ''; // NOTREACHED
}
switch ($a->argv[2]) {
case "delete":
- check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/admin/users', 'admin_users', 't');
// delete user
User::remove($uid);
notice(L10n::t("User '%s' deleted", $user['username']) . EOL);
break;
case "block":
- check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/admin/users', 'admin_users', 't');
q("UPDATE `user` SET `blocked` = %d WHERE `uid` = %s",
intval(1 - $user['blocked']),
intval($uid)
notice(sprintf(($user['blocked'] ? L10n::t("User '%s' unblocked") : L10n::t("User '%s' blocked")), $user['username']) . EOL);
break;
}
- goaway('admin/users');
+ $a->internalRedirect('admin/users');
return ''; // NOTREACHED
}
/* get pending */
- $pending = q("SELECT `register`.*, `contact`.`name`, `user`.`email`
- FROM `register`
- INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
- INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;");
-
+ $pending = Register::getPending();
- /* 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);
- }
+ $pager = new Pager($a->query_string, 100);
/* ordering */
$valid_orders = [
FROM `user`
INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
WHERE `user`.`verified`
- ORDER BY $sql_order $sql_order_direction LIMIT %d, %d", intval($a->pager['start']), intval($a->pager['itemspage'])
+ ORDER BY $sql_order $sql_order_direction LIMIT %d, %d", $pager->getStart(), $pager->getItemsPerPage()
);
$adminlist = explode(",", str_replace(" ", "", Config::get('config', 'admin_email')));
$th_users = array_map(null, [L10n::t('Name'), L10n::t('Email'), L10n::t('Register date'), L10n::t('Last login'), L10n::t('Last item'), L10n::t('Type')], $valid_orders);
- $t = get_markup_template('admin/users.tpl');
- $o = replace_macros($t, [
+ $t = Renderer::getMarkupTemplate('admin/users.tpl');
+ $o = Renderer::replaceMacros($t, [
// strings //
'$title' => L10n::t('Administration'),
'$page' => L10n::t('Users'),
'$h_users' => L10n::t('Users'),
'$h_newuser' => L10n::t('New User'),
- '$th_deleted' => [L10n::t('Name'), L10n::t('Email'), L10n::t('Register date'), L10n::t('Last login'), L10n::t('Last item'), L10n::t('Deleted since')],
+ '$th_deleted' => [L10n::t('Name'), L10n::t('Email'), L10n::t('Register date'), L10n::t('Last login'), L10n::t('Last item'), L10n::t('Delete in')],
'$th_users' => $th_users,
'$order_users' => $order,
'$order_direction_users' => $order_direction,
'$confirm_delete_multi' => L10n::t('Selected users will be deleted!\n\nEverything these users had posted on this site will be permanently deleted!\n\nAre you sure?'),
'$confirm_delete' => L10n::t('The user {0} will be deleted!\n\nEverything this user has posted on this site will be permanently deleted!\n\nAre you sure?'),
- '$form_security_token' => get_form_security_token("admin_users"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("admin_users"),
// values //
- '$baseurl' => System::baseUrl(true),
+ '$baseurl' => $a->getBaseURL(true),
'$pending' => $pending,
'deleted' => $deleted,
'$newusernickname' => ['new_user_nickname', L10n::t("Nickname"), '', L10n::t("Nickname of the new user.")],
'$newuseremail' => ['new_user_email', L10n::t("Email"), '', L10n::t("Email address of the new user."), '', '', 'email'],
]);
- $o .= paginate($a);
+ $o .= $pager->renderFull(DBA::count('user'));
return $o;
}
*
* The returned string returned hulds the HTML code of the page.
*
- * @param App $a
+ * @param App $a
+ * @param array $addons_admin A list of admin addon names
* @return string
*/
-function admin_page_addons(App $a)
+function admin_page_addons(App $a, array $addons_admin)
{
/*
* Single addon
return '';
}
- if (x($_GET, "a") && $_GET['a'] == "t") {
- check_form_security_token_redirectOnErr('/admin/addons', 'admin_themes', 't');
+ if (defaults($_GET, 'a', '') == "t") {
+ BaseModule::checkFormSecurityTokenRedirectOnError('/admin/addons', 'admin_themes', 't');
// Toggle addon status
- $idx = array_search($addon, $a->addons);
- if ($idx !== false) {
- unset($a->addons[$idx]);
+ if (Addon::isEnabled($addon)) {
Addon::uninstall($addon);
info(L10n::t("Addon %s disabled.", $addon));
} else {
- $a->addons[] = $addon;
Addon::install($addon);
info(L10n::t("Addon %s enabled.", $addon));
}
- Config::set("system", "addon", implode(", ", $a->addons));
- goaway('admin/addons');
+
+ Addon::saveEnabledList();
+ $a->internalRedirect('admin/addons');
return ''; // NOTREACHED
}
// display addon details
- if (in_array($addon, $a->addons)) {
+ if (Addon::isEnabled($addon)) {
$status = "on";
$action = L10n::t("Disable");
} else {
}
$admin_form = "";
- if (in_array($addon, $a->addons_admin)) {
+ if (in_array($addon, $addons_admin)) {
require_once "addon/$addon/$addon.php";
$func = $addon . '_addon_admin';
$func($a, $admin_form);
}
- $t = get_markup_template('admin/addon_details.tpl');
+ $t = Renderer::getMarkupTemplate('admin/addon_details.tpl');
- return replace_macros($t, [
+ return Renderer::replaceMacros($t, [
'$title' => L10n::t('Administration'),
'$page' => L10n::t('Addons'),
'$toggle' => L10n::t('Toggle'),
'$settings' => L10n::t('Settings'),
- '$baseurl' => System::baseUrl(true),
+ '$baseurl' => $a->getBaseURL(true),
'$addon' => $addon,
'$status' => $status,
'$screenshot' => '',
'$readme' => $readme,
- '$form_security_token' => get_form_security_token("admin_themes"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("admin_themes"),
]);
}
* List addons
*/
if (x($_GET, "a") && $_GET['a'] == "r") {
- check_form_security_token_redirectOnErr(System::baseUrl() . '/admin/addons', 'admin_themes', 't');
+ BaseModule::checkFormSecurityTokenRedirectOnError($a->getBaseURL() . '/admin/addons', 'admin_themes', 't');
Addon::reload();
info("Addons reloaded");
- goaway(System::baseUrl() . '/admin/addons');
+ $a->internalRedirect('admin/addons');
}
$addons = [];
$show_addon = true;
// If the addon is unsupported, then only show it, when it is enabled
- if ((strtolower($info["status"]) == "unsupported") && !in_array($id, $a->addons)) {
+ if ((strtolower($info["status"]) == "unsupported") && !Addon::isEnabled($id)) {
$show_addon = false;
}
}
if ($show_addon) {
- $addons[] = [$id, (in_array($id, $a->addons) ? "on" : "off"), $info];
+ $addons[] = [$id, (Addon::isEnabled($id) ? "on" : "off"), $info];
}
}
}
}
- $t = get_markup_template('admin/addons.tpl');
- return replace_macros($t, [
+ $t = Renderer::getMarkupTemplate('admin/addons.tpl');
+ return Renderer::replaceMacros($t, [
'$title' => L10n::t('Administration'),
'$page' => L10n::t('Addons'),
'$submit' => L10n::t('Save Settings'),
'$addons' => $addons,
'$pcount' => count($addons),
'$noplugshint' => L10n::t('There are currently no addons available on your node. You can find the official addon repository at %1$s and might find other interesting addons in the open addon registry at %2$s', 'https://github.com/friendica/friendica-addons', 'http://addons.friendi.ca'),
- '$form_security_token' => get_form_security_token("admin_themes"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("admin_themes"),
]);
}
}
if (x($_GET, "a") && $_GET['a'] == "t") {
- check_form_security_token_redirectOnErr('/admin/themes', 'admin_themes', 't');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/admin/themes', 'admin_themes', 't');
// Toggle theme status
}
Config::set('system', 'allowed_themes', $s);
- goaway('admin/themes');
+ $a->internalRedirect('admin/themes');
return ''; // NOTREACHED
}
$admin_form = '';
if (is_file("view/theme/$theme/config.php")) {
- $orig_theme = $a->theme;
+ $orig_theme = Renderer::$theme;
$orig_page = $a->page;
$orig_session_theme = $_SESSION['theme'];
require_once "view/theme/$theme/theme.php";
}
$_SESSION['theme'] = $orig_session_theme;
- $a->theme = $orig_theme;
+ Renderer::$theme = $orig_theme;
$a->page = $orig_page;
}
$screenshot = null;
}
- $t = get_markup_template('admin/addon_details.tpl');
- return replace_macros($t, [
+ $t = Renderer::getMarkupTemplate('admin/addon_details.tpl');
+ return Renderer::replaceMacros($t, [
'$title' => L10n::t('Administration'),
'$page' => L10n::t('Themes'),
'$toggle' => L10n::t('Toggle'),
'$screenshot' => $screenshot,
'$readme' => $readme,
- '$form_security_token' => get_form_security_token("admin_themes"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("admin_themes"),
]);
}
// reload active themes
if (x($_GET, "a") && $_GET['a'] == "r") {
- check_form_security_token_redirectOnErr(System::baseUrl() . '/admin/themes', 'admin_themes', 't');
+ BaseModule::checkFormSecurityTokenRedirectOnError(System::baseUrl() . '/admin/themes', 'admin_themes', 't');
foreach ($themes as $th) {
if ($th['allowed']) {
Theme::uninstall($th['name']);
}
}
info("Themes reloaded");
- goaway(System::baseUrl() . '/admin/themes');
+ $a->internalRedirect('admin/themes');
}
/*
$addons[] = [$th['name'], (($th['allowed']) ? "on" : "off"), Theme::getInfo($th['name'])];
}
- $t = get_markup_template('admin/addons.tpl');
- return replace_macros($t, [
+ $t = Renderer::getMarkupTemplate('admin/addons.tpl');
+ return Renderer::replaceMacros($t, [
'$title' => L10n::t('Administration'),
'$page' => L10n::t('Themes'),
'$submit' => L10n::t('Save Settings'),
'$noplugshint' => L10n::t('No themes found on the system. They should be placed in %1$s', '<code>/view/themes</code>'),
'$experimental' => L10n::t('[Experimental]'),
'$unsupported' => L10n::t('[Unsupported]'),
- '$form_security_token' => get_form_security_token("admin_themes"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("admin_themes"),
]);
}
function admin_page_logs_post(App $a)
{
if (x($_POST, "page_logs")) {
- check_form_security_token_redirectOnErr('/admin/logs', 'admin_logs');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/admin/logs', 'admin_logs');
- $logfile = ((x($_POST,'logfile')) ? notags(trim($_POST['logfile'])) : '');
+ $logfile = ((x($_POST,'logfile')) ? Strings::removeTags(trim($_POST['logfile'])) : '');
$debugging = ((x($_POST,'debugging')) ? true : false);
$loglevel = ((x($_POST,'loglevel')) ? intval(trim($_POST['loglevel'])) : 0);
}
info(L10n::t("Log settings updated."));
- goaway('admin/logs');
+ $a->internalRedirect('admin/logs');
return; // NOTREACHED
}
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'
+ Logger::WARNING => 'Warning',
+ Logger::INFO => 'Info',
+ Logger::TRACE => 'Trace',
+ Logger::DEBUG => 'Debug',
+ Logger::DATA => 'Data',
+ Logger::ALL => 'All'
];
if (ini_get('log_errors')) {
$phplogenabled = L10n::t('PHP log currently disabled.');
}
- $t = get_markup_template('admin/logs.tpl');
+ $t = Renderer::getMarkupTemplate('admin/logs.tpl');
- return replace_macros($t, [
+ return Renderer::replaceMacros($t, [
'$title' => L10n::t('Administration'),
'$page' => L10n::t('Logs'),
'$submit' => L10n::t('Save Settings'),
'$debugging' => ['debugging', L10n::t("Enable Debugging"), Config::get('system', 'debugging'), ""],
'$logfile' => ['logfile', L10n::t("Log file"), Config::get('system', 'logfile'), L10n::t("Must be writable by web server. Relative to your Friendica top-level directory.")],
'$loglevel' => ['loglevel', L10n::t("Log level"), Config::get('system', 'loglevel'), "", $log_choices],
- '$form_security_token' => get_form_security_token("admin_logs"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("admin_logs"),
'$phpheader' => L10n::t("PHP logging"),
'$phphint' => L10n::t("To temporarily enable logging of PHP errors and warnings you can prepend the following to the index.php file of your installation. The filename set in the 'error_log' line is relative to the friendica top-level directory and must be writeable by the web server. The option '1' for 'log_errors' and 'display_errors' is to enable these options, set to '0' to disable them."),
'$phplogcode' => "error_reporting(E_ERROR | E_WARNING | E_PARSE);\nini_set('error_log','php.out');\nini_set('log_errors','1');\nini_set('display_errors', '1');",
*/
function admin_page_viewlogs(App $a)
{
- $t = get_markup_template('admin/viewlogs.tpl');
+ $t = Renderer::getMarkupTemplate('admin/viewlogs.tpl');
$f = Config::get('system', 'logfile');
$data = '';
}
$seek = fseek($fp, 0 - $size, SEEK_END);
if ($seek === 0) {
- $data = escape_tags(fread($fp, $size));
+ $data = Strings::escapeTags(fread($fp, $size));
while (!feof($fp)) {
- $data .= escape_tags(fread($fp, 4096));
+ $data .= Strings::escapeTags(fread($fp, 4096));
}
}
}
fclose($fp);
}
}
- return replace_macros($t, [
+ return Renderer::replaceMacros($t, [
'$title' => L10n::t('Administration'),
'$page' => L10n::t('View Logs'),
'$data' => $data,
*/
function admin_page_features_post(App $a)
{
- check_form_security_token_redirectOnErr('/admin/features', 'admin_manage_features');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/admin/features', 'admin_manage_features');
- logger('postvars: ' . print_r($_POST, true), LOGGER_DATA);
+ Logger::log('postvars: ' . print_r($_POST, true), Logger::DATA);
$features = Feature::get(false);
}
}
- goaway('admin/features');
+ $a->internalRedirect('admin/features');
return; // NOTREACHED
}
*/
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);
}
}
- $tpl = get_markup_template('admin/settings_features.tpl');
- $o = replace_macros($tpl, [
- '$form_security_token' => get_form_security_token("admin_manage_features"),
+ $tpl = Renderer::getMarkupTemplate('admin/settings_features.tpl');
+ $o = Renderer::replaceMacros($tpl, [
+ '$form_security_token' => BaseModule::getFormSecurityToken("admin_manage_features"),
'$title' => L10n::t('Manage Additional Features'),
'$features' => $arr,
'$submit' => L10n::t('Save Settings'),
return $o;
}
}
+
+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();
+}