]> git.mxchange.org Git - friendica.git/blobdiff - mod/admin.php
proc_run was replaced
[friendica.git] / mod / admin.php
index 291907667539724f1abaf20cba1f996023c76564..144539dcef5198d57eb06d36034e53dcd41502a2 100644 (file)
@@ -9,6 +9,7 @@
 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");
@@ -363,7 +364,7 @@ function admin_page_blocklist_post(App $a) {
  * 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
  */
@@ -441,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
@@ -449,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);
@@ -464,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);
@@ -605,10 +607,9 @@ 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)) {
@@ -625,6 +626,15 @@ function admin_page_summary(App $a) {
                $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),
@@ -643,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 NOT `done`");
+       $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
@@ -682,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'] != "") {
@@ -711,7 +726,7 @@ function admin_page_site_post(App $a) {
                $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);
@@ -728,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');
                        }
                }
@@ -753,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.");
@@ -818,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);
@@ -842,7 +856,7 @@ function admin_page_site_post(App $a) {
        // Has the directory url changed? If yes, then resubmit the existing profiles there
        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() != "") {
@@ -927,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);
@@ -966,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);
 
@@ -1099,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');
@@ -1144,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'),
@@ -1163,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.")),
@@ -1193,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,
@@ -1227,7 +1240,7 @@ 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"), System::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")),
 
@@ -1394,7 +1407,7 @@ function admin_page_users_post(App $a) {
                $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,
@@ -1486,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);
@@ -1521,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`