]> git.mxchange.org Git - friendica.git/blobdiff - mod/admin.php
Merge pull request #3539 from AndyHee/20170617-admin_settings
[friendica.git] / mod / admin.php
index 97d52f14f49365c4933f9814cf7cd9490179cc73..a32accaf9a89177ca0da4725c4f4509875db082e 100644 (file)
@@ -6,7 +6,8 @@
  * @brief Friendica admin
  */
 
-use \Friendica\Core\Config;
+use Friendica\App;
+use Friendica\Core\Config;
 
 require_once("include/enotify.php");
 require_once("include/text.php");
@@ -278,7 +279,7 @@ function admin_page_blocklist(App $a) {
                        $blocklistform[] = array(
                                'domain' => array("domain[$id]", t('Blocked domain'), $b['domain'], '', t('The blocked domain'), 'required', '', ''),
                                'reason' => array("reason[$id]", t("Reason for the block"), $b['reason'], t('The reason why you blocked this domain.').'('.$b['domain'].')', 'required', '', ''),
-                               'delete' => array("delete[$id]", t("Delete domain").' ('.$b['domain'].')', False , "Check to delete this entry from the blocklist")
+                               'delete' => array("delete[$id]", t("Delete domain").' ('.$b['domain'].')', False , t("Check to delete this entry from the blocklist"))
                        );
                }
        }
@@ -544,19 +545,24 @@ function admin_page_summary(App $a) {
                $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');
        }
-       // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
-       if ((version_compare($db->server_info(), '5.7.4') >= 0) AND
-               !(strpos($db->server_info(), 'MariaDB') !== false)) {
-               $warningtext[] = t('You are using a MySQL version which does not support all features that Friendica uses. You should consider switching to MariaDB.');
+
+       if (Config::get('system', 'dbupdate', DB_UPDATE_NOT_CHECKED) == DB_UPDATE_NOT_CHECKED) {
+               require_once("include/dbstructure.php");
+               update_structure(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.');
+       }
+
        $r = q("SELECT `page-flags`, COUNT(`uid`) AS `count` FROM `user` GROUP BY `page-flags`");
        $accounts = array(
                array(t('Normal Account'), 0),
-               array(t('Soapbox Account'), 0),
-               array(t('Community/Celebrity Account'), 0),
+               array(t('Automatic Follower Account'), 0),
+               array(t('Public Forum Account'), 0),
                array(t('Automatic Friend Account'), 0),
                array(t('Blog Account'), 0),
-               array(t('Private Forum'), 0)
+               array(t('Private Forum Account'), 0)
        );
 
        $users=0;
@@ -573,7 +579,7 @@ function admin_page_summary(App $a) {
        $r = qu("SELECT COUNT(*) AS `total` FROM `queue` WHERE 1");
        $queue = (($r) ? $r[0]['total'] : 0);
 
-       $r = qu("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE 1");
+       $r = qu("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE NOT `done`");
        $workerqueue = (($r) ? $r[0]['total'] : 0);
 
        // We can do better, but this is a quick queue status
@@ -731,6 +737,7 @@ function admin_page_site_post(App $a) {
        $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);
+       $min_memory             =       ((x($_POST,'min_memory'))               ? intval(trim($_POST['min_memory']))            : 0);
        $optimize_max_tablesize =       ((x($_POST,'optimize_max_tablesize'))   ? intval(trim($_POST['optimize_max_tablesize'])): 100);
        $optimize_fragmentation =       ((x($_POST,'optimize_fragmentation'))   ? intval(trim($_POST['optimize_fragmentation'])): 30);
        $poco_completion        =       ((x($_POST,'poco_completion'))          ? intval(trim($_POST['poco_completion']))       : false);
@@ -763,7 +770,7 @@ function admin_page_site_post(App $a) {
        $worker_frontend        =       ((x($_POST,'worker_frontend'))          ? True                                          : False);
 
        // Has the directory url changed? If yes, then resubmit the existing profiles there
-       if ($global_directory != Config::get('system', 'directory') AND ($global_directory != '')) {
+       if ($global_directory != Config::get('system', 'directory') && ($global_directory != '')) {
                Config::set('system', 'directory', $global_directory);
                proc_run(PRIORITY_LOW, 'include/directory.php');
        }
@@ -816,6 +823,7 @@ function admin_page_site_post(App $a) {
        set_config('system','ssl_policy',$ssl_policy);
        set_config('system','maxloadavg',$maxloadavg);
        set_config('system','maxloadavg_frontend',$maxloadavg_frontend);
+       set_config('system','min_memory',$min_memory);
        set_config('system','optimize_max_tablesize',$optimize_max_tablesize);
        set_config('system','optimize_fragmentation',$optimize_fragmentation);
        set_config('system','poco_completion',$poco_completion);
@@ -928,7 +936,7 @@ function admin_page_site(App $a) {
        /* Installed langs */
        $lang_choices = get_available_languages();
 
-       if (strlen(get_config('system','directory_submit_url')) AND
+       if (strlen(get_config('system','directory_submit_url')) &&
                !strlen(get_config('system','directory'))) {
                        set_config('system','directory', dirname(get_config('system','directory_submit_url')));
                        del_config('system','directory_submit_url');
@@ -950,7 +958,7 @@ function admin_page_site(App $a) {
                        $f = basename($file);
 
                        // Only show allowed themes here
-                       if (($allowed_theme_list != '') AND !strstr($allowed_theme_list, $f)) {
+                       if (($allowed_theme_list != '') && !strstr($allowed_theme_list, $f)) {
                                continue;
                        }
 
@@ -1113,6 +1121,7 @@ function admin_page_site(App $a) {
                '$timeout'              => array('timeout', t("Network timeout"), (x(get_config('system','curl_timeout'))?get_config('system','curl_timeout'):60), t("Value is in seconds. Set to 0 for unlimited (not recommended).")),
                '$maxloadavg'           => array('maxloadavg', t("Maximum Load Average"), ((intval(get_config('system','maxloadavg')) > 0)?get_config('system','maxloadavg'):50), t("Maximum system load before delivery and poll processes are deferred - default 50.")),
                '$maxloadavg_frontend'  => array('maxloadavg_frontend', t("Maximum Load Average (Frontend)"), ((intval(get_config('system','maxloadavg_frontend')) > 0)?get_config('system','maxloadavg_frontend'):50), t("Maximum system load before the frontend quits service - default 50.")),
+               '$min_memory'           => array('min_memory', t("Minimal Memory"), ((intval(get_config('system','min_memory')) > 0)?get_config('system','min_memory'):0), t("Minimal free memory in MB for the poller. Needs access to /proc/meminfo - default 0 (deactivated).")),
                '$optimize_max_tablesize'=> array('optimize_max_tablesize', t("Maximum table size for optimization"), $optimize_max_tablesize, t("Maximum table size (in MB) for the automatic optimization - default 100 MB. Enter -1 to disable it.")),
                '$optimize_fragmentation'=> array('optimize_fragmentation', t("Minimum level of fragmentation"), ((intval(get_config('system','optimize_fragmentation')) > 0)?get_config('system','optimize_fragmentation'):30), t("Minimum fragmenation level to start the automatic optimization - default value is 30%.")),
 
@@ -1174,7 +1183,7 @@ function admin_page_dbsync(App $a) {
                goaway('admin/dbsync');
        }
 
-       if (($a->argc > 2) AND (intval($a->argv[2]) OR ($a->argv[2] === 'check'))) {
+       if (($a->argc > 2) && (intval($a->argv[2]) || ($a->argv[2] === 'check'))) {
                require_once("include/dbstructure.php");
                $retval = update_structure(false, true);
                if (!$retval) {
@@ -1442,8 +1451,8 @@ function admin_page_users(App $a) {
        $_setup_users = function ($e) use ($adminlist) {
                $accounts = array(
                        t('Normal Account'),
-                       t('Soapbox Account'),
-                       t('Community/Celebrity Account'),
+                       t('Automatic Follower Account'),
+                       t('Public Forum Account'),
                                                t('Automatic Friend Account')
                );
                $e['page-flags'] = $accounts[$e['page-flags']];
@@ -1654,7 +1663,7 @@ function admin_page_plugins(App $a) {
                                $show_plugin = true;
 
                                // If the addon is unsupported, then only show it, when it is enabled
-                               if ((strtolower($info["status"]) == "unsupported") AND !in_array($id,  $a->plugins)) {
+                               if ((strtolower($info["status"]) == "unsupported") && !in_array($id,  $a->plugins)) {
                                        $show_plugin = false;
                                }
 
@@ -1792,7 +1801,7 @@ function admin_page_themes(App $a) {
                        $is_supported = 1-(intval(file_exists($file.'/unsupported')));
                        $is_allowed = intval(in_array($f,$allowed_themes));
 
-                       if ($is_allowed OR $is_supported OR get_config("system", "show_unsupported_themes")) {
+                       if ($is_allowed || $is_supported || get_config("system", "show_unsupported_themes")) {
                                $themes[] = array('name' => $f, 'experimental' => $is_experimental, 'supported' => $is_supported, 'allowed' => $is_allowed);
                        }
                }