<?php
-
/**
* @file mod/admin.php
*
* @brief Friendica admin
*/
use Friendica\App;
+use Friendica\Content\Feature;
use Friendica\Core\System;
use Friendica\Core\Config;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
+use Friendica\Database\DBStructure;
+use Friendica\Model\Contact;
use Friendica\Model\User;
-use Friendica\Object\Contact;
+use Friendica\Module\Login;
require_once 'include/enotify.php';
require_once 'include/text.php';
function admin_content(App $a)
{
if (!is_site_admin()) {
- return login(false);
+ return Login::form();
}
if (x($_SESSION, 'submanage') && intval($_SESSION['submanage'])) {
// off one % two of them are needed in the query
// Add more platforms if you like, when one returns 0 known nodes it is not
// displayed on the stats page.
- $platforms = array('Friendi%%a', 'Diaspora', '%%red%%', 'Hubzilla', 'BlaBlaNet', 'GNU Social', 'StatusNet', 'Mastodon', 'Pleroma');
+ $platforms = array('Friendi%%a', 'Diaspora', '%%red%%', 'Hubzilla', 'BlaBlaNet', 'GNU Social', 'StatusNet', 'Mastodon', 'Pleroma', 'socialhome');
$colors = array(
'Friendi%%a' => '#ffc018', // orange from the logo
'Diaspora' => '#a1a1a1', // logo is black and white, makes a gray
'GNU Social' => '#a22430', // dark red from the logo
'StatusNet' => '#789240', // the green from the logo (red and blue have already others
'Mastodon' => '#1a9df9', // blue from the Mastodon logo
- 'Pleroma' => '#E46F0F' // Orange from the text that is used on Pleroma instances
+ 'Pleroma' => '#E46F0F', // Orange from the text that is used on Pleroma instances
+ 'socialhome' => '#52056b' // lilac from the Django Image used at the Socialhome homepage
);
$counts = array();
$total = 0;
+ $users = 0;
foreach ($platforms as $p) {
// get a total count for the platform, the name and version of the
// highest version and the protocol tpe
- $c = q('SELECT COUNT(*) AS `total`, ANY_VALUE(`platform`) AS `platform`,
+ $c = q('SELECT COUNT(*) AS `total`, SUM(`registered-users`) AS `users`, ANY_VALUE(`platform`) AS `platform`,
ANY_VALUE(`network`) AS `network`, MAX(`version`) AS `version` FROM `gserver`
WHERE `platform` LIKE "%s" AND `last_contact` >= `last_failure`
ORDER BY `version` ASC;', $p);
- $total = $total + $c[0]['total'];
+ $total += $c[0]['total'];
+ $users += $c[0]['users'];
// what versions for that platform do we know at all?
// again only the active nodes
'$autoactive' => Config::get('system', 'poco_completion'),
'$counts' => $counts,
'$version' => FRIENDICA_VERSION,
- '$legendtext' => sprintf(t('Currently this node is aware of %d nodes from the following platforms:'), $total),
+ '$legendtext' => sprintf(t('Currently this node is aware of %d nodes with %d registered users from the following platforms:'), $total, $users),
'$baseurl' => System::baseUrl(),
));
}
$warningtext = array();
if (DBM::is_result($r)) {
$showwarning = true;
- $warningtext[] = sprintf(t('Your DB still runs with MyISAM tables. You should change the engine type to InnoDB. As Friendica will use InnoDB only features in the future, you should change this! See <a href="%s">here</a> for a guide that may be helpful converting the table engines. You may also use the command <tt>php include/dbstructure.php toinnodb</tt> of your Friendica installation for an automatic conversion.<br />'), 'https://dev.mysql.com/doc/refman/5.7/en/converting-tables-to-innodb.html');
+ $warningtext[] = sprintf(t('Your DB still runs with MyISAM tables. You should change the engine type to InnoDB. As Friendica will use InnoDB only features in the future, you should change this! See <a href="%s">here</a> for a guide that may be helpful converting the table engines. You may also use the command <tt>php scripts/dbstructure.php toinnodb</tt> of your Friendica installation for an automatic conversion.<br />'), 'https://dev.mysql.com/doc/refman/5.7/en/converting-tables-to-innodb.html');
}
// Check if github.com/friendica/master/VERSION is higher then
// the local version of Friendica. Check is opt-in, source may be master or devel branch
}
if (Config::get('system', 'dbupdate', DB_UPDATE_NOT_CHECKED) == DB_UPDATE_NOT_CHECKED) {
- require_once("include/dbstructure.php");
- update_structure(false, true);
+ DBStructure::update(false, true);
}
if (Config::get('system', 'dbupdate') == DB_UPDATE_FAILED) {
$showwarning = true;
- $warningtext[] = t('The database update failed. Please run "php include/dbstructure.php update" from the command line and have a look at the errors that might appear.');
+ $warningtext[] = t('The database update failed. Please run "php scripts/dbstructure.php update" from the command line and have a look at the errors that might appear.');
}
$last_worker_call = Config::get('system', 'last_poller_execution', false);
$community_page_style_choices = array(
CP_NO_COMMUNITY_PAGE => t("No community page"),
CP_USERS_ON_SERVER => t("Public postings from users of this site"),
- CP_GLOBAL_COMMUNITY => t("Global community page")
+ CP_GLOBAL_COMMUNITY => t("Public postings from the federated network"),
+ CP_USERS_AND_GLOBAL => t("Public postings from local users and the federated network")
);
/* OStatus conversation poll choices */
'$banner' => array('banner', t("Banner/Logo"), $banner, ""),
'$shortcut_icon' => array('shortcut_icon', t("Shortcut icon"), Config::get('system','shortcut_icon'), t("Link to an icon that will be used for browsers.")),
'$touch_icon' => array('touch_icon', t("Touch icon"), Config::get('system','touch_icon'), t("Link to an icon that will be used for tablets and mobiles.")),
- '$info' => array('info', t('Additional Info'), $info, sprintf(t('For public servers: you can add additional information here that will be listed at %s/siteinfo.'), get_server())),
+ '$info' => array('info', t('Additional Info'), $info, sprintf(t('For public servers: you can add additional information here that will be listed at %s/servers.'), get_server())),
'$language' => array('language', t("System language"), Config::get('system','language'), "", $lang_choices),
'$theme' => array('theme', t("System theme"), Config::get('system','theme'), t("Default system theme - may be over-ridden by user profiles - <a href='#' id='cnftheme'>change theme settings</a>"), $theme_choices),
'$theme_mobile' => array('theme_mobile', t("Mobile system theme"), Config::get('system', 'mobile-theme', '---'), t("Theme for mobile devices"), $theme_choices_mobile),
'$no_multi_reg' => array('no_multi_reg', t("Block multiple registrations"), Config::get('system','block_extended_register'), t("Disallow users to register additional accounts for use as pages.")),
'$no_openid' => array('no_openid', t("OpenID support"), !Config::get('system','no_openid'), t("OpenID support for registration and logins.")),
'$no_regfullname' => array('no_regfullname', t("Fullname check"), !Config::get('system','no_regfullname'), t("Force users to register with a space between firstname and lastname in Full name, as an antispam measure")),
- '$community_page_style' => array('community_page_style', t("Community Page Style"), Config::get('system','community_page_style'), t("Type of community page to show. 'Global community' shows every public posting from an open distributed network that arrived on this server."), $community_page_style_choices),
+ '$community_page_style' => array('community_page_style', t("Community pages for visitors"), Config::get('system','community_page_style'), t("Which community pages should be available for visitors. Local users always see both pages."), $community_page_style_choices),
'$max_author_posts_community_page' => array('max_author_posts_community_page', t("Posts per user on community page"), Config::get('system','max_author_posts_community_page'), t("The maximum number of posts per user on the community page. (Not valid for 'Global Community')")),
'$ostatus_disabled' => array('ostatus_disabled', t("Enable OStatus support"), !Config::get('system','ostatus_disabled'), 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' => array('ostatus_full_threads', t("Only import OStatus threads from our contacts"), Config::get('system','ostatus_full_threads'), 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.")),
}
if (($a->argc > 2) && (intval($a->argv[2]) || ($a->argv[2] === 'check'))) {
- require_once("include/dbstructure.php");
- $retval = update_structure(false, true);
+ $retval = DBStructure::update(false, true);
if (!$retval) {
$o .= sprintf(t("Database structure update %s was successfully applied."), DB_UPDATE_VERSION) . "<br />";
Config::set('database', 'dbupdate_' . DB_UPDATE_VERSION, 'success');
check_form_security_token_redirectOnErr('/admin/users', 'admin_users');
if (!($nu_name === "") && !($nu_email === "") && !($nu_nickname === "")) {
- require_once 'include/user.php';
-
- $result = create_user(array('username' => $nu_name, 'email' => $nu_email,
- 'nickname' => $nu_nickname, 'verified' => 1, 'language' => $nu_language));
- if (!$result['success']) {
- notice($result['message']);
+ try {
+ $result = User::create([
+ 'username' => $nu_name,
+ 'email' => $nu_email,
+ 'nickname' => $nu_nickname,
+ 'verified' => 1,
+ 'language' => $nu_language
+ ]);
+ } catch (Exception $ex) {
+ notice($ex->getMessage());
return;
}
- $nu = $result['user'];
+
+ $user = $result['user'];
$preamble = deindent(t('
Dear %1$s,
the administrator of %2$s has set up an account for you.'));
Thank you and welcome to %4$s.'));
- $preamble = sprintf($preamble, $nu['username'], $a->config['sitename']);
- $body = sprintf($body, System::baseUrl(), $nu['email'], $result['password'], $a->config['sitename']);
+ $preamble = sprintf($preamble, $user['username'], $a->config['sitename']);
+ $body = sprintf($body, System::baseUrl(), $user['email'], $result['password'], $a->config['sitename']);
notification(array(
'type' => SYSTEM_EMAIL,
- 'to_email' => $nu['email'],
+ 'to_email' => $user['email'],
'subject' => sprintf(t('Registration details for %s'), $a->config['sitename']),
'preamble' => $preamble,
'body' => $body));
/* get pending */
$pending = q("SELECT `register`.*, `contact`.`name`, `user`.`email`
FROM `register`
- LEFT JOIN `contact` ON `register`.`uid` = `contact`.`uid`
- LEFT JOIN `user` ON `register`.`uid` = `user`.`uid`;");
+ INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
+ INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;");
/* get users */
logger('postvars: ' . print_r($_POST, true), LOGGER_DATA);
$arr = array();
- $features = get_features(false);
+ $features = Feature::get(false);
foreach ($features as $fname => $fdata) {
foreach (array_slice($fdata, 1) as $f) {
{
if ((argc() > 1) && (argv(1) === 'features')) {
$arr = array();
- $features = get_features(false);
+ $features = Feature::get(false);
foreach ($features as $fname => $fdata) {
$arr[$fname] = array();