]> git.mxchange.org Git - friendica.git/blobdiff - mod/admin.php
Fix unused code in include
[friendica.git] / mod / admin.php
index 1e7d90436f86e2f029514b4262cb80e489e93536..d8e2226a795470dea2a55805bb16bc1fb89d52a3 100644 (file)
@@ -1,17 +1,19 @@
 <?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';
@@ -152,7 +154,7 @@ function admin_post(App $a)
 function admin_content(App $a)
 {
        if (!is_site_admin()) {
-               return login(false);
+               return Login::form();
        }
 
        if (x($_SESSION, 'submanage') && intval($_SESSION['submanage'])) {
@@ -533,7 +535,7 @@ function admin_page_federation(App $a)
        // 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
@@ -543,19 +545,22 @@ function admin_page_federation(App $a)
                '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
@@ -647,7 +652,7 @@ function admin_page_federation(App $a)
                '$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(),
        ));
 }
@@ -708,7 +713,7 @@ function admin_page_summary(App $a)
        $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
@@ -721,12 +726,11 @@ function admin_page_summary(App $a)
        }
 
        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);
@@ -1173,7 +1177,8 @@ function admin_page_site(App $a)
        $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 */
@@ -1279,7 +1284,7 @@ function admin_page_site(App $a)
                '$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),
@@ -1308,7 +1313,7 @@ function admin_page_site(App $a)
                '$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.")),
@@ -1385,8 +1390,7 @@ function admin_page_dbsync(App $a)
        }
 
        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');
@@ -1466,15 +1470,20 @@ function admin_page_users_post(App $a)
        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.'));
@@ -1504,12 +1513,12 @@ function admin_page_users_post(App $a)
 
                        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));
@@ -1589,8 +1598,8 @@ function admin_page_users(App $a)
        /* 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 */
@@ -2293,7 +2302,7 @@ function admin_page_features_post(App $a)
        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) {
@@ -2338,7 +2347,7 @@ function admin_page_features(App $a)
 {
        if ((argc() > 1) && (argv(1) === 'features')) {
                $arr = array();
-               $features = get_features(false);
+               $features = Feature::get(false);
 
                foreach ($features as $fname => $fdata) {
                        $arr[$fname] = array();