3 namespace Friendica\Module\Admin;
\r
5 use Friendica\Core\Addon;
\r
6 use Friendica\Core\Config;
\r
7 use Friendica\Core\L10n;
\r
8 use Friendica\Core\Logger;
\r
9 use Friendica\Core\Renderer;
\r
10 use Friendica\Core\System;
\r
11 use Friendica\Core\Update;
\r
12 use Friendica\Database\DBA;
\r
13 use Friendica\Database\DBStructure;
\r
14 use Friendica\Model\Register;
\r
15 use Friendica\Module\BaseAdminModule;
\r
16 use Friendica\Util\DateTimeFormat;
\r
17 use Friendica\Util\Network;
\r
19 class Summary extends BaseAdminModule
\r
21 public static function content()
\r
25 $a = self::getApp();
\r
27 // are there MyISAM tables in the DB? If so, trigger a warning message
\r
29 if (DBA::count('`information_schema`.`tables`', ['engine' => 'myisam', 'table_schema' => DBA::databaseName()])) {
\r
30 $warningtext[] = L10n::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 bin/console.php dbstructure 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');
\r
33 // Check if github.com/friendica/master/VERSION is higher then
\r
34 // the local version of Friendica. Check is opt-in, source may be master or devel branch
\r
35 if (Config::get('system', 'check_new_version_url', 'none') != 'none') {
\r
36 $gitversion = Config::get('system', 'git_friendica_version');
\r
37 if (version_compare(FRIENDICA_VERSION, $gitversion) < 0) {
\r
38 $warningtext[] = L10n::t('There is a new version of Friendica available for download. Your current version is %1$s, upstream version is %2$s', FRIENDICA_VERSION, $gitversion);
\r
42 if (Config::get('system', 'dbupdate', DBStructure::UPDATE_NOT_CHECKED) == DBStructure::UPDATE_NOT_CHECKED) {
\r
43 DBStructure::update($a->getBasePath(), false, true);
\r
46 if (Config::get('system', 'dbupdate') == DBStructure::UPDATE_FAILED) {
\r
47 $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.');
\r
50 if (Config::get('system', 'update') == Update::FAILED) {
\r
51 $warningtext[] = L10n::t('The last update failed. Please run "php bin/console.php dbstructure update" from the command line and have a look at the errors that might appear. (Some of the errors are possibly inside the logfile.)');
\r
54 $last_worker_call = Config::get('system', 'last_worker_execution', false);
\r
55 if (!$last_worker_call) {
\r
56 $warningtext[] = L10n::t('The worker was never executed. Please check your database structure!');
\r
57 } elseif ((strtotime(DateTimeFormat::utcNow()) - strtotime($last_worker_call)) > 60 * 60) {
\r
58 $warningtext[] = L10n::t('The last worker execution was on %s UTC. This is older than one hour. Please check your crontab settings.', $last_worker_call);
\r
61 // Legacy config file warning
\r
62 if (file_exists('.htconfig.php')) {
\r
63 $warningtext[] = L10n::t('Friendica\'s configuration now is stored in config/local.config.php, please copy config/local-sample.config.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');
\r
66 if (file_exists('config/local.ini.php')) {
\r
67 $warningtext[] = L10n::t('Friendica\'s configuration now is stored in config/local.config.php, please copy config/local-sample.config.php and move your config from <code>config/local.ini.php</code>. See <a href="%s">the Config help page</a> for help with the transition.', $a->getBaseURL() . '/help/Config');
\r
70 // Check server vitality
\r
71 if (!self::checkSelfHostMeta()) {
\r
72 $well_known = $a->getBaseURL() . '/.well-known/host-meta';
\r
73 $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.',
\r
74 $well_known, $well_known, $a->getBaseURL() . '/help/Install');
\r
78 [L10n::t('Normal Account'), 0],
\r
79 [L10n::t('Automatic Follower Account'), 0],
\r
80 [L10n::t('Public Forum Account'), 0],
\r
81 [L10n::t('Automatic Friend Account'), 0],
\r
82 [L10n::t('Blog Account'), 0],
\r
83 [L10n::t('Private Forum Account'), 0]
\r
87 $pageFlagsCountStmt = DBA::p('SELECT `page-flags`, COUNT(`uid`) AS `count` FROM `user` GROUP BY `page-flags`');
\r
88 while ($pageFlagsCount = DBA::fetch($pageFlagsCountStmt)) {
\r
89 $accounts[$pageFlagsCount['page-flags']][1] = $pageFlagsCount['count'];
\r
90 $users += $pageFlagsCount['count'];
\r
92 DBA::close($pageFlagsCountStmt);
\r
94 Logger::log('accounts: ' . print_r($accounts, true), Logger::DATA);
\r
96 $pending = Register::getPendingCount();
\r
98 $queue = DBA::count('queue', []);
\r
100 $deferred = DBA::count('workerqueue', ['`executed` <= ? AND NOT `done` AND `next_try` > ?',
\r
101 DBA::NULL_DATETIME, DateTimeFormat::utcNow()]);
\r
103 $workerqueue = DBA::count('workerqueue', ['`executed` <= ? AND NOT `done` AND `next_try` < ?',
\r
104 DBA::NULL_DATETIME, DateTimeFormat::utcNow()]);
\r
106 // We can do better, but this is a quick queue status
\r
107 $queues = ['label' => L10n::t('Message queues'), 'queue' => $queue, 'deferred' => $deferred, 'workerq' => $workerqueue];
\r
109 $variables = DBA::toArray(DBA::p('SHOW variables LIKE "max_allowed_packet"'));
\r
110 $max_allowed_packet = $variables ? $variables[0]['Value'] : 0;
\r
112 $server_settings = [
\r
113 'label' => L10n::t('Server Settings'),
\r
115 'upload_max_filesize' => ini_get('upload_max_filesize'),
\r
116 'post_max_size' => ini_get('post_max_size'),
\r
117 'memory_limit' => ini_get('memory_limit')
\r
120 'max_allowed_packet' => $max_allowed_packet
\r
124 $t = Renderer::getMarkupTemplate('admin/summary.tpl');
\r
125 return Renderer::replaceMacros($t, [
\r
126 '$title' => L10n::t('Administration'),
\r
127 '$page' => L10n::t('Summary'),
\r
128 '$queues' => $queues,
\r
129 '$users' => [L10n::t('Registered users'), $users],
\r
130 '$accounts' => $accounts,
\r
131 '$pending' => [L10n::t('Pending registrations'), $pending],
\r
132 '$version' => [L10n::t('Version'), FRIENDICA_VERSION],
\r
133 '$baseurl' => System::baseUrl(),
\r
134 '$platform' => FRIENDICA_PLATFORM,
\r
135 '$codename' => FRIENDICA_CODENAME,
\r
136 '$build' => Config::get('system', 'build'),
\r
137 '$addons' => [L10n::t('Active addons'), Addon::getEnabledList()],
\r
138 '$serversettings' => $server_settings,
\r
139 '$warningtext' => $warningtext
\r
143 private static function checkSelfHostMeta()
\r
145 // Fetch the host-meta to check if this really is a vital server
\r
146 return Network::curl(System::baseUrl() . '/.well-known/host-meta')->isSuccess();
\r