]> git.mxchange.org Git - friendica.git/blobdiff - mod/admin.php
proc_run was replaced
[friendica.git] / mod / admin.php
index 50e1ff18ec42e197e75267b66392fc302367acb5..144539dcef5198d57eb06d36034e53dcd41502a2 100644 (file)
@@ -6,10 +6,14 @@
  * @brief Friendica admin
  */
 
-use \Friendica\Core\Config;
+use Friendica\App;
+use Friendica\Core\System;
+use Friendica\Core\Config;
+use Friendica\Core\Worker;
 
 require_once("include/enotify.php");
 require_once("include/text.php");
+require_once('include/items.php');
 
 /**
  * @brief Process send data from the admin panels subpages
@@ -112,6 +116,9 @@ function admin_post(App $a) {
                        case 'blocklist':
                                admin_page_blocklist_post($a);
                                break;
+                       case 'deleteitem':
+                               admin_page_deleteitem_post($a);
+                               break;
                }
        }
 
@@ -171,6 +178,7 @@ function admin_content(App $a) {
                'queue'  =>     array("admin/queue/", t('Inspect Queue'), "queue"),
                'blocklist' => array("admin/blocklist/", t('Server Blocklist'), "blocklist"),
                'federation' => array("admin/federation/", t('Federation Statistics'), "federation"),
+               'deleteitem' => array("admin/deleteitem/", t('Delete Item'), 'deleteitem'),
        );
 
        /* get plugins admin page */
@@ -243,6 +251,9 @@ function admin_content(App $a) {
                        case 'blocklist':
                                $o = admin_page_blocklist($a);
                                break;
+                       case 'deleteitem':
+                               $o = admin_page_deleteitem($a);
+                               break;
                        default:
                                notice(t("Item not found."));
                }
@@ -272,14 +283,13 @@ function admin_content(App $a) {
  */
 function admin_page_blocklist(App $a) {
        $blocklist = Config::get('system', 'blocklist');
-       var_dump($blocklist);
        $blocklistform = array();
        if (is_array($blocklist)) {
                foreach($blocklist as $id => $b) {
                        $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"))
                        );
                }
        }
@@ -299,7 +309,7 @@ function admin_page_blocklist(App $a) {
                '$threason' => t('Reason for the block'),
                '$delentry' => t('Delete entry from blocklist'),
                '$entries' => $blocklistform,
-               '$baseurl' => App::get_baseurl(true),
+               '$baseurl' => System::baseUrl(true),
                '$confirm_delete' => t('Delete entry from blocklist?'),
                '$form_security_token'  => get_form_security_token("admin_blocklist")
        ));
@@ -348,6 +358,67 @@ function admin_page_blocklist_post(App $a) {
        return; // NOTREACHED
 }
 
+/**
+ * @brief Subpage where the admin can delete an item from their node given the GUID
+ *
+ * This subpage of the admin panel offers the nodes admin to delete an item from
+ * the node, given the GUID or the display URL such as http://example.com/display/123456.
+ * The item will then be marked as deleted in the database and processed accordingly.
+ *
+ * @param App $a
+ * @return string
+ */
+function admin_page_deleteitem(App $a) {
+       $t = get_markup_template("admin_deleteitem.tpl");
+
+       return replace_macros($t, array(
+               '$title' => t('Administration'),
+               '$page' => t('Delete Item'),
+               '$submit' => t('Delete this Item'),
+               '$intro1' => t('On this page you can delete an item from your node. If the item is a top level posting, the entire thread will be deleted.'),
+               '$intro2' => 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' => array('deleteitemguid', t("GUID"), '', t("The GUID of the item you want to delete."), 'required', 'autofocus'),
+               '$baseurl' => System::baseUrl(),
+               '$form_security_token'  => get_form_security_token("admin_deleteitem")
+       ));
+}
+/**
+ * @brief Process send data from Admin Delete Item Page
+ *
+ * The GUID passed through the form should be only the GUID. But we also parse
+ * URLs like the full /display URL to make the process more easy for the admin.
+ *
+ * @param App $a
+ */
+function admin_page_deleteitem_post(App $a) {
+       if (!x($_POST['page_deleteitem_submit'])) {
+               return;
+       }
+
+       check_form_security_token_redirectOnErr('/admin/deleteitem/', 'admin_deleteitem');
+
+       if (x($_POST['page_deleteitem_submit'])) {
+               $guid = trim(notags($_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, '/')) {
+                       $guid = substr($guid, strrpos($guid, '/')+1);
+               }
+               // Now that we have the GUID get all IDs of the associated entries in the
+               // item table of the DB and drop those items, which will also delete the
+               // associated threads.
+               $r = dba::select('item', array('id'), array('guid'=>$guid));
+               while ($row = dba::fetch($r)) {
+                       drop_item($row['id'], false);
+               }
+               dba::close($r);
+       }
+
+       info(t('Item marked for deletion.').EOL);
+       goaway('admin/deleteitem');
+       return; // NOTREACHED
+}
+
 /**
  * @brief Subpage with some stats about "the federation" network
  *
@@ -371,7 +442,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');
+       $platforms = array('Friendi%%a', 'Diaspora', '%%red%%', 'Hubzilla', 'BlaBlaNet', 'GNU Social', 'StatusNet', 'Mastodon', 'Pleroma');
        $colors    = array('Friendi%%a' => '#ffc018',     // orange from the logo
                           'Diaspora'  => '#a1a1a1',     // logo is black and white, makes a gray
                           '%%red%%'   => '#c50001',     // fire red from the logo
@@ -379,14 +450,15 @@ function admin_page_federation(App $a) {
                           'BlaBlaNet' => '#3B5998',     // blue from the navbar at blablanet-dot-com
                           '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
+                          'Mastodon'  => '#1a9df9',    // blue from the Mastodon logo
+                          'Pleroma'  => '#E46F0F');    // Orange from the text that is used on Pleroma instances
        $counts = array();
        $total = 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 = qu('SELECT COUNT(*) AS `total`, ANY_VALUE(`platform`) AS `platform`,
+               $c = q('SELECT COUNT(*) AS `total`, 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);
@@ -394,7 +466,7 @@ function admin_page_federation(App $a) {
 
                // what versions for that platform do we know at all?
                // again only the active nodes
-               $v = qu('SELECT COUNT(*) AS `total`, `version` FROM `gserver`
+               $v = q('SELECT COUNT(*) AS `total`, `version` FROM `gserver`
                                WHERE `last_contact` >= `last_failure` AND `platform` LIKE "%s"
                                GROUP BY `version`
                                ORDER BY `version`;', $p);
@@ -483,7 +555,7 @@ function admin_page_federation(App $a) {
                '$counts' => $counts,
                '$version' => FRIENDICA_VERSION,
                '$legendtext' => sprintf(t('Currently this node is aware of %d nodes from the following platforms:'), $total),
-               '$baseurl' => App::get_baseurl(),
+               '$baseurl' => System::baseUrl(),
        ));
 }
 
@@ -535,29 +607,42 @@ function admin_page_queue(App $a) {
  * @return string
  */
 function admin_page_summary(App $a) {
-       global $db;
        // are there MyISAM tables in the DB? If so, trigger a warning message
        $r = q("SELECT `engine` FROM `information_schema`.`tables` WHERE `engine` = 'myisam' AND `table_schema` = '%s' LIMIT 1",
-               dbesc($db->database_name()));
+               dbesc(dba::database_name()));
        $showwarning = false;
        $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');
        }
-       // 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.');
+       }
+
+       $last_worker_call = Config::get('system', 'last_poller_execution', false);
+       if (!$last_worker_call) {
+               $showwarning = true;
+               $warningtext[] = t('The worker was never executed. Please check your database structure!');
+       } elseif ((strtotime(datetime_convert()) - strtotime($last_worker_call)) > 60 * 60) {
+               $showwarning = true;
+               $warningtext[] = sprintf(t('The last worker execution was on %s UTC. This is older than one hour. Please check your crontab settings.'), $last_worker_call);
        }
+
        $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;
@@ -568,13 +653,13 @@ function admin_page_summary(App $a) {
 
        logger('accounts: '.print_r($accounts,true),LOGGER_DATA);
 
-       $r = qu("SELECT COUNT(`id`) AS `count` FROM `register`");
+       $r = q("SELECT COUNT(`id`) AS `count` FROM `register`");
        $pending = $r[0]['count'];
 
-       $r = qu("SELECT COUNT(*) AS `total` FROM `queue` WHERE 1");
+       $r = q("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 = q("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
@@ -591,7 +676,7 @@ function admin_page_summary(App $a) {
                '$accounts' => $accounts,
                '$pending' => array(t('Pending registrations'), $pending),
                '$version' => array(t('Version'), FRIENDICA_VERSION),
-               '$baseurl' => App::get_baseurl(),
+               '$baseurl' => System::baseUrl(),
                '$platform' => FRIENDICA_PLATFORM,
                '$codename' => FRIENDICA_CODENAME,
                '$build' =>  get_config('system','build'),
@@ -607,11 +692,16 @@ function admin_page_summary(App $a) {
  * @param App $a
  */
 function admin_page_site_post(App $a) {
-       if (!x($_POST,"page_site")) {
+       check_form_security_token_redirectOnErr('/admin/site', 'admin_site');
+
+       if (!empty($_POST['republish_directory'])) {
+               Worker::add(PRIORITY_LOW, 'directory');
                return;
        }
 
-       check_form_security_token_redirectOnErr('/admin/site', 'admin_site');
+       if (!x($_POST,"page_site")) {
+               return;
+       }
 
        // relocate
        if (x($_POST,'relocate') && x($_POST,'relocate_url') && $_POST['relocate_url'] != "") {
@@ -629,14 +719,14 @@ function admin_page_site_post(App $a) {
                 * send relocate for every local user
                 * */
 
-               $old_url = App::get_baseurl(true);
+               $old_url = System::baseUrl(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) {
-                       global $db, $a;
+                       global $a;
 
                        $dbold = dbesc($old_url);
                        $dbnew = dbesc($new_url);
@@ -653,7 +743,7 @@ function admin_page_site_post(App $a) {
                        $q = sprintf("UPDATE %s SET %s;", $table_name, $upds);
                        $r = q($q);
                        if (!$r) {
-                               notice("Failed updating '$table_name': ".$db->error);
+                               notice("Failed updating '$table_name': ".dba::errorMessage());
                                goaway('admin/site');
                        }
                }
@@ -678,7 +768,7 @@ function admin_page_site_post(App $a) {
                $users = q("SELECT `uid` FROM `user` WHERE `account_removed` = 0 AND `account_expired` = 0");
 
                foreach ($users as $user) {
-                       proc_run(PRIORITY_HIGH, 'include/notifier.php', 'relocate', $user['uid']);
+                       Worker::add(PRIORITY_HIGH, 'notifier', 'relocate', $user['uid']);
                }
 
                info("Relocation started. Could take a while to complete.");
@@ -732,6 +822,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);
@@ -742,7 +833,6 @@ function admin_page_site_post(App $a) {
        $nodeinfo               =       ((x($_POST,'nodeinfo'))                 ? intval(trim($_POST['nodeinfo']))              : false);
        $dfrn_only              =       ((x($_POST,'dfrn_only'))                ? True                                          : False);
        $ostatus_disabled       =       !((x($_POST,'ostatus_disabled'))        ? True                                          : False);
-       $ostatus_poll_interval  =       ((x($_POST,'ostatus_poll_interval'))    ? intval(trim($_POST['ostatus_poll_interval'])) :  0);
        $ostatus_full_threads   =       ((x($_POST,'ostatus_full_threads'))     ? True                                          : False);
        $diaspora_enabled       =       ((x($_POST,'diaspora_enabled'))         ? True                                          : False);
        $ssl_policy             =       ((x($_POST,'ssl_policy'))               ? intval($_POST['ssl_policy'])                  : 0);
@@ -764,9 +854,9 @@ 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');
+               Worker::add(PRIORITY_LOW, 'directory');
        }
 
        if ($a->get_path() != "") {
@@ -817,6 +907,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);
@@ -850,16 +941,16 @@ function admin_page_site_post(App $a) {
        set_config('system','language', $language);
        set_config('system','theme', $theme);
 
-       if ($theme_mobile === '---') {
+       if ($theme_mobile == '---') {
                del_config('system','mobile-theme');
        } else {
                set_config('system','mobile-theme', $theme_mobile);
-               }
-               if ($singleuser === '---') {
-                       del_config('system','singleuser');
-               } else {
-                       set_config('system','singleuser', $singleuser);
-               }
+       }
+       if ($singleuser == '---') {
+               del_config('system','singleuser');
+       } else {
+               set_config('system','singleuser', $singleuser);
+       }
        set_config('system', 'maximagesize', $maximagesize);
        set_config('system', 'max_image_length', $maximagelength);
        set_config('system', 'jpeg_quality', $jpegimagequality);
@@ -889,7 +980,6 @@ function admin_page_site_post(App $a) {
        set_config('system', 'curl_timeout', $timeout);
        set_config('system', 'dfrn_only', $dfrn_only);
        set_config('system', 'ostatus_disabled', $ostatus_disabled);
-       set_config('system', 'ostatus_poll_interval', $ostatus_poll_interval);
        set_config('system', 'ostatus_full_threads', $ostatus_full_threads);
        set_config('system', 'diaspora_enabled', $diaspora_enabled);
 
@@ -897,10 +987,25 @@ function admin_page_site_post(App $a) {
 
        set_config('system', 'force_ssl', $force_ssl);
        set_config('system', 'hide_help', $hide_help);
+
+       if ($itemcache != '') {
+               $itemcache = App::realpath($itemcache);
+       }
+
        set_config('system', 'itemcache', $itemcache);
        set_config('system', 'itemcache_duration', $itemcache_duration);
        set_config('system', 'max_comments', $max_comments);
+
+       if ($temppath != '') {
+               $temppath = App::realpath($temppath);
+       }
+
        set_config('system', 'temppath', $temppath);
+
+       if ($basepath != '') {
+               $basepath = App::realpath($basepath);
+       }
+
        set_config('system', 'basepath', $basepath);
        set_config('system', 'proxy_disabled', $proxy_disabled);
        set_config('system', 'only_tag_search', $only_tag_search);
@@ -929,7 +1034,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');
@@ -951,7 +1056,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;
                        }
 
@@ -1007,7 +1112,7 @@ function admin_page_site(App $a) {
        /* Banner */
        $banner = get_config('system','banner');
        if ($banner == false) {
-               $banner = '<a href="http://friendica.com"><img id="logo-img" src="images/friendica-32.png" alt="logo" /></a><span id="logo-text"><a href="http://friendica.com">Friendica</a></span>';
+               $banner = '<a href="https://friendi.ca"><img id="logo-img" src="images/friendica-32.png" alt="logo" /></a><span id="logo-text"><a href="https://friendi.ca">Friendica</a></span>';
        }
        $banner = htmlspecialchars($banner);
        $info = get_config('config','info');
@@ -1052,6 +1157,7 @@ function admin_page_site(App $a) {
                '$title' => t('Administration'),
                '$page' => t('Site'),
                '$submit' => t('Save Settings'),
+               '$republish' => t('Republish users to directory'),
                '$registration' => t('Registration'),
                '$upload' => t('File upload'),
                '$corporate' => t('Policies'),
@@ -1060,7 +1166,7 @@ function admin_page_site(App $a) {
                '$performance' => t('Performance'),
                '$worker_title' => t('Worker'),
                '$relocate'=> t('Relocate - WARNING: advanced function. Could make this server unreachable.'),
-               '$baseurl' => App::get_baseurl(true),
+               '$baseurl' => System::baseUrl(true),
                // name, label, value, help string, extra data...
                '$sitename'             => array('sitename', t("Site name"), $a->config['sitename'],''),
                '$hostname'             => array('hostname', t("Host name"), $a->config['hostname'], ""),
@@ -1071,11 +1177,11 @@ function admin_page_site(App $a) {
                '$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())),
                '$language'             => array('language', t("System language"), get_config('system','language'), "", $lang_choices),
                '$theme'                => array('theme', t("System theme"), get_config('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"), get_config('system','mobile-theme'), t("Theme for mobile devices"), $theme_choices_mobile),
+               '$theme_mobile'         => array('theme_mobile', t("Mobile system theme"), Config::get('system', 'mobile-theme', '---'), t("Theme for mobile devices"), $theme_choices_mobile),
                '$ssl_policy'           => array('ssl_policy', t("SSL link policy"), (string) intval(get_config('system','ssl_policy')), t("Determines whether generated links should be forced to use SSL"), $ssl_choices),
                '$force_ssl'            => array('force_ssl', t("Force SSL"), get_config('system','force_ssl'), t("Force all Non-SSL requests to SSL - Attention: on some systems it could lead to endless loops.")),
                '$hide_help'            => array('hide_help', t("Hide help entry from navigation menu"), get_config('system','hide_help'), t("Hides the menu entry for the Help pages from the navigation menu. You can still access it calling /help directly.")),
-               '$singleuser'           => array('singleuser', t("Single user instance"), get_config('system','singleuser'), t("Make this instance multi-user or single-user for the named user"), $user_names),
+               '$singleuser'           => array('singleuser', t("Single user instance"), Config::get('system', 'singleuser', '---'), t("Make this instance multi-user or single-user for the named user"), $user_names),
                '$maximagesize'         => array('maximagesize', t("Maximum image size"), get_config('system','maximagesize'), t("Maximum size in bytes of uploaded images. Default is 0, which means no limits.")),
                '$maximagelength'       => array('maximagelength', t("Maximum image length"), get_config('system','max_image_length'), t("Maximum length in pixels of the longest side of uploaded images. Default is -1, which means no limits.")),
                '$jpegimagequality'     => array('jpegimagequality', t("JPEG image quality"), get_config('system','jpeg_quality'), t("Uploaded JPEGS will be saved at this quality setting [0-100]. Default is 100, which is full quality.")),
@@ -1101,7 +1207,6 @@ function admin_page_site(App $a) {
                '$community_page_style' => array('community_page_style', t("Community Page Style"), get_config('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),
                '$max_author_posts_community_page' => array('max_author_posts_community_page', t("Posts per user on community page"), get_config('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"), !get_config('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_poll_interval' => array('ostatus_poll_interval', t("OStatus conversation completion interval"), (string) intval(get_config('system','ostatus_poll_interval')), t("How often shall the poller check for new entries in OStatus conversations? This can be a very ressource task."), $ostatus_poll_choices),
                '$ostatus_full_threads' => array('ostatus_full_threads', t("Only import OStatus threads from our contacts"), get_config('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.")),
                '$ostatus_not_able'     => t("OStatus support can only be enabled if threading is enabled."),
                '$diaspora_able'        => $diaspora_able,
@@ -1114,6 +1219,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%.")),
 
@@ -1134,14 +1240,14 @@ function admin_page_site(App $a) {
                '$proxy_disabled'       => array('proxy_disabled', t("Disable picture proxy"), get_config('system','proxy_disabled'), t("The picture proxy increases performance and privacy. It shouldn't be used on systems with very low bandwith.")),
                '$only_tag_search'      => array('only_tag_search', t("Only search in tags"), get_config('system','only_tag_search'), t("On large systems the text search can slow down the system extremely.")),
 
-               '$relocate_url'         => array('relocate_url', t("New base url"), App::get_baseurl(), t("Change base url for this server. Sends relocate message to all DFRN contacts of all users.")),
+               '$relocate_url'         => array('relocate_url', t("New base url"), System::baseUrl(), t("Change base url for this server. Sends relocate message to all Friendica and Diaspora* contacts of all users.")),
 
                '$rino'                 => array('rino', t("RINO Encryption"), intval(get_config('system','rino_encrypt')), t("Encryption layer between nodes."), array("Disabled", "RINO1 (deprecated)", "RINO2")),
 
                '$worker_queues'        => array('worker_queues', t("Maximum number of parallel workers"), get_config('system','worker_queues'), t("On shared hosters set this to 2. On larger systems, values of 10 are great. Default value is 4.")),
                '$worker_dont_fork'     => array('worker_dont_fork', t("Don't use 'proc_open' with the worker"), get_config('system','worker_dont_fork'), t("Enable this if your system doesn't allow the use of 'proc_open'. This can happen on shared hosters. If this is enabled you should increase the frequency of poller calls in your crontab.")),
                '$worker_fastlane'      => array('worker_fastlane', t("Enable fastlane"), get_config('system','worker_fastlane'), t("When enabed, the fastlane mechanism starts an additional worker if processes with higher priority are blocked by processes of lower priority.")),
-               '$worker_frontend'      => array('worker_frontend', t('Enable frontend worker'), get_config('system','frontend_worker'), t('When enabled the Worker process is triggered when backend access is performed (e.g. messages being delivered). On smaller sites you might want to call yourdomain.tld/worker on a regular basis via an external cron job. You should only enable this option if you cannot utilize cron/scheduled jobs on your server. The worker background process needs to be activated for this.')),
+               '$worker_frontend'      => array('worker_frontend', t('Enable frontend worker'), get_config('system','frontend_worker'), sprintf(t('When enabled the Worker process is triggered when backend access is performed (e.g. messages being delivered). On smaller sites you might want to call %s/worker on a regular basis via an external cron job. You should only enable this option if you cannot utilize cron/scheduled jobs on your server.'), System::baseUrl())),
 
                '$form_security_token'  => get_form_security_token("admin_site")
 
@@ -1175,7 +1281,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) {
@@ -1224,13 +1330,13 @@ function admin_page_dbsync(App $a) {
        }
        if (! count($failed)) {
                $o = replace_macros(get_markup_template('structure_check.tpl'),array(
-                       '$base'   => App::get_baseurl(true),
+                       '$base'   => System::baseUrl(true),
                        '$banner' => t('No failed updates.'),
                        '$check'  => t('Check database structure'),
                ));
        } else {
                $o = replace_macros(get_markup_template('failed_updates.tpl'),array(
-                       '$base'   => App::get_baseurl(true),
+                       '$base'   => System::baseUrl(true),
                        '$banner' => t('Failed Updates'),
                        '$desc'   => t('This does not include updates prior to 1139, which did not return a status.'),
                        '$mark'   => t('Mark success (if update was manually applied)'),
@@ -1298,10 +1404,10 @@ 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, App::get_baseurl(), $nu['email'], $result['password'], $a->config['sitename']);
+               $body = sprintf($body, System::baseUrl(), $nu['email'], $result['password'], $a->config['sitename']);
 
                notification(array(
-                       'type' => "SYSTEM_EMAIL",
+                       'type' => SYSTEM_EMAIL,
                        'to_email' => $nu['email'],
                        'subject'=> sprintf(t('Registration details for %s'), $a->config['sitename']),
                        'preamble'=> $preamble,
@@ -1393,7 +1499,7 @@ function admin_page_users(App $a) {
 
 
        /* get users */
-       $total = qu("SELECT COUNT(*) AS `total` FROM `user` WHERE 1");
+       $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);
@@ -1428,7 +1534,7 @@ function admin_page_users(App $a) {
        $sql_order = "`".str_replace('.','`.`',$order)."`";
        $sql_order_direction = ($order_direction === "+")?"ASC":"DESC";
 
-       $users = qu("SELECT `user`.*, `contact`.`name`, `contact`.`url`, `contact`.`micro`, `user`.`account_expired`, `contact`.`last-item` AS `lastitem_date`
+       $users = q("SELECT `user`.*, `contact`.`name`, `contact`.`url`, `contact`.`micro`, `user`.`account_expired`, `contact`.`last-item` AS `lastitem_date`
                                FROM `user`
                                INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
                                WHERE `user`.`verified`
@@ -1443,8 +1549,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']];
@@ -1522,7 +1628,7 @@ function admin_page_users(App $a) {
                '$form_security_token' => get_form_security_token("admin_users"),
 
                // values //
-               '$baseurl' => App::get_baseurl(true),
+               '$baseurl' => System::baseUrl(true),
 
                '$pending' => $pending,
                'deleted' => $deleted,
@@ -1595,7 +1701,7 @@ function admin_page_plugins(App $a) {
                $readme=Null;
                if (is_file("addon/$plugin/README.md")) {
                        $readme = file_get_contents("addon/$plugin/README.md");
-                       $readme = Markdown($readme);
+                       $readme = Markdown($readme, false);
                } elseif (is_file("addon/$plugin/README")) {
                        $readme = "<pre>". file_get_contents("addon/$plugin/README") ."</pre>";
                }
@@ -1614,7 +1720,7 @@ function admin_page_plugins(App $a) {
                        '$page' => t('Plugins'),
                        '$toggle' => t('Toggle'),
                        '$settings' => t('Settings'),
-                       '$baseurl' => App::get_baseurl(true),
+                       '$baseurl' => System::baseUrl(true),
 
                        '$plugin' => $plugin,
                        '$status' => $status,
@@ -1639,10 +1745,10 @@ function admin_page_plugins(App $a) {
         */
 
        if (x($_GET,"a") && $_GET['a']=="r") {
-               check_form_security_token_redirectOnErr(App::get_baseurl().'/admin/plugins', 'admin_themes', 't');
+               check_form_security_token_redirectOnErr(System::baseUrl().'/admin/plugins', 'admin_themes', 't');
                reload_plugins();
                info("Plugins reloaded");
-               goaway(App::get_baseurl().'/admin/plugins');
+               goaway(System::baseUrl().'/admin/plugins');
        }
 
        $plugins = array();
@@ -1655,7 +1761,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;
                                }
 
@@ -1677,7 +1783,7 @@ function admin_page_plugins(App $a) {
                '$page' => t('Plugins'),
                '$submit' => t('Save Settings'),
                '$reload' => t('Reload active plugins'),
-               '$baseurl' => App::get_baseurl(true),
+               '$baseurl' => System::baseUrl(true),
                '$function' => 'plugins',
                '$plugins' => $plugins,
                '$pcount' => count($plugins),
@@ -1793,7 +1899,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);
                        }
                }
@@ -1847,7 +1953,7 @@ function admin_page_themes(App $a) {
                $readme = Null;
                if (is_file("view/theme/$theme/README.md")) {
                        $readme = file_get_contents("view/theme/$theme/README.md");
-                       $readme = Markdown($readme);
+                       $readme = Markdown($readme, false);
                } elseif (is_file("view/theme/$theme/README")) {
                        $readme = "<pre>". file_get_contents("view/theme/$theme/README") ."</pre>";
                }
@@ -1890,7 +1996,7 @@ function admin_page_themes(App $a) {
                        '$page' => t('Themes'),
                        '$toggle' => t('Toggle'),
                        '$settings' => t('Settings'),
-                       '$baseurl' => App::get_baseurl(true),
+                       '$baseurl' => System::baseUrl(true),
                        '$plugin' => $theme,
                        '$status' => $status,
                        '$action' => $action,
@@ -1909,7 +2015,7 @@ function admin_page_themes(App $a) {
 
        // reload active themes
        if (x($_GET,"a") && $_GET['a']=="r") {
-               check_form_security_token_redirectOnErr(App::get_baseurl().'/admin/themes', 'admin_themes', 't');
+               check_form_security_token_redirectOnErr(System::baseUrl().'/admin/themes', 'admin_themes', 't');
                if ($themes) {
                        foreach ($themes as $th) {
                                if ($th['allowed']) {
@@ -1919,7 +2025,7 @@ function admin_page_themes(App $a) {
                        }
                }
                info("Themes reloaded");
-               goaway(App::get_baseurl().'/admin/themes');
+               goaway(System::baseUrl().'/admin/themes');
        }
 
        /*
@@ -1940,7 +2046,7 @@ function admin_page_themes(App $a) {
                '$page'                => t('Themes'),
                '$submit'              => t('Save Settings'),
                '$reload'              => t('Reload active themes'),
-               '$baseurl'             => App::get_baseurl(true),
+               '$baseurl'             => System::baseUrl(true),
                '$function'            => 'themes',
                '$plugins'             => $xthemes,
                '$pcount'              => count($themes),
@@ -2014,7 +2120,7 @@ function admin_page_logs(App $a) {
                '$page' => t('Logs'),
                '$submit' => t('Save Settings'),
                '$clear' => t('Clear'),
-               '$baseurl' => App::get_baseurl(true),
+               '$baseurl' => System::baseUrl(true),
                '$logname' =>  get_config('system','logfile'),
 
                // name, label, value, help string, extra data...