]> git.mxchange.org Git - friendica.git/blobdiff - mod/admin.php
File was missing
[friendica.git] / mod / admin.php
index d49673fc0fb9e9521dc31a080577d7798d8c80dd..f4cc0cf6fb55f8c717317cdeec86ad1e01145cbf 100644 (file)
@@ -269,34 +269,43 @@ function admin_page_federation(&$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('Friendica', 'Diaspora', '%%red%%', 'Hubzilla', 'GNU Social', 'StatusNet');
+       $platforms = array('Friendica', 'Diaspora', '%%red%%', 'Hubzilla', 'BlaBlaNet', 'GNU Social', 'StatusNet', 'Mastodon');
        $colors    = array('Friendica' => '#ffc018',     // orange from the logo
-                           'Diaspora'  => '#a1a1a1',     // logo is black and white, makes a gray
+                          'Diaspora'  => '#a1a1a1',     // logo is black and white, makes a gray
                           '%%red%%'   => '#c50001',     // fire red from the logo
                           'Hubzilla'  => '#43488a',     // blue from the logo
+                          '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
+                          'StatusNet' => '#789240',     // the green from the logo (red and blue have already others
+                          'Mastodon'  => '#1a9df9');    // blue from the Mastodon logo
        $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 = q('SELECT COUNT(*) AS `total`, `platform`, `network`, `version` FROM `gserver`
-                               WHERE `platform` LIKE "%s" AND `last_contact` > `last_failure` AND `version` != ""
+               $c = qu('SELECT COUNT(*) AS `total`, `platform`, `network`, `version` FROM `gserver`
+                               WHERE `platform` LIKE "%s" AND `last_contact` > `last_failure`
                                ORDER BY `version` ASC;', $p);
                $total = $total + $c[0]['total'];
 
                // what versions for that platform do we know at all?
                // again only the active nodes
-               $v = q('SELECT COUNT(*) AS `total`, `version` FROM `gserver`
-                               WHERE `last_contact` > `last_failure` AND `platform` LIKE "%s"  AND `version` != ""
+               $v = qu('SELECT COUNT(*) AS `total`, `version` FROM `gserver`
+                               WHERE `last_contact` > `last_failure` AND `platform` LIKE "%s"
                                GROUP BY `version`
                                ORDER BY `version`;', $p);
 
                //
                // clean up version numbers
                //
+               // some platforms do not provide version information, add a unkown there
+               // to the version string for the displayed list.
+               foreach ($v as $key => $value) {
+                       if ($v[$key]['version'] == '') {
+                               $v[$key] = array('total'=>$v[$key]['total'], 'version'=>t('unknown'));
+                       }
+               }
                // in the DB the Diaspora versions have the format x.x.x.x-xx the last
                // part (-xx) should be removed to clean up the versions from the "head
                // commit" information and combined into a single entry for x.x.x.x
@@ -419,6 +428,21 @@ function admin_page_queue(&$a) {
  * @return string
  */
 function admin_page_summary(&$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()));
+       $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 <tt>convert_innodb.sql</tt> in the <tt>/util</tt> directory of your Friendica installation.<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.');
+       }
        $r = q("SELECT `page-flags`, COUNT(`uid`) AS `count` FROM `user` GROUP BY `page-flags`");
        $accounts = array(
                array(t('Normal Account'), 0),
@@ -434,17 +458,17 @@ function admin_page_summary(&$a) {
 
        logger('accounts: '.print_r($accounts,true),LOGGER_DATA);
 
-       $r = q("SELECT COUNT(`id`) AS `count` FROM `register`");
+       $r = qu("SELECT COUNT(`id`) AS `count` FROM `register`");
        $pending = $r[0]['count'];
 
-       $r = q("SELECT COUNT(*) AS `total` FROM `deliverq` WHERE 1");
+       $r = qu("SELECT COUNT(*) AS `total` FROM `deliverq` WHERE 1");
        $deliverq = (($r) ? $r[0]['total'] : 0);
 
-       $r = q("SELECT COUNT(*) AS `total` FROM `queue` WHERE 1");
+       $r = qu("SELECT COUNT(*) AS `total` FROM `queue` WHERE 1");
        $queue = (($r) ? $r[0]['total'] : 0);
 
        if (get_config('system','worker')) {
-               $r = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE 1");
+               $r = qu("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE 1");
                $workerqueue = (($r) ? $r[0]['total'] : 0);
        } else {
                $workerqueue = 0;
@@ -460,6 +484,7 @@ function admin_page_summary(&$a) {
                '$title' => t('Administration'),
                '$page' => t('Summary'),
                '$queues' => $queues,
+               '$workeractive' => get_config('system','worker'),
                '$users' => array(t('Registered users'), $users),
                '$accounts' => $accounts,
                '$pending' => array(t('Pending registrations'), $pending),
@@ -468,7 +493,9 @@ function admin_page_summary(&$a) {
                '$platform' => FRIENDICA_PLATFORM,
                '$codename' => FRIENDICA_CODENAME,
                '$build' =>  get_config('system','build'),
-               '$plugins' => array(t('Active plugins'), $a->plugins)
+               '$plugins' => array(t('Active plugins'), $a->plugins),
+               '$showwarning' => $showwarning,
+               '$warningtext' => $warningtext
        ));
 }
 
@@ -641,6 +668,7 @@ function admin_page_site_post(&$a) {
        $worker                 =       ((x($_POST,'worker'))                   ? True                                          : False);
        $worker_queues          =       ((x($_POST,'worker_queues'))            ? intval($_POST['worker_queues'])               : 4);
        $worker_dont_fork       =       ((x($_POST,'worker_dont_fork'))         ? True                                          : False);
+       $worker_fastlane        =       ((x($_POST,'worker_fastlane'))          ? True                                          : False);
 
        if($a->get_path() != "")
                $diaspora_enabled = false;
@@ -790,6 +818,7 @@ function admin_page_site_post(&$a) {
        set_config('system','worker', $worker);
        set_config('system','worker_queues', $worker_queues);
        set_config('system','worker_dont_fork', $worker_dont_fork);
+       set_config('system','worker_fastlane', $worker_fastlane);
 
        if($rino==2 and !function_exists('mcrypt_create_iv')) {
                notice(t("RINO2 needs mcrypt php extension to work."));
@@ -817,7 +846,7 @@ function admin_page_site_post(&$a) {
 function admin_page_site(&$a) {
 
        /* Installed langs */
-       $lang_choices = get_avaiable_languages();
+       $lang_choices = get_available_languages();
 
        if(strlen(get_config('system','directory_submit_url')) AND
                !strlen(get_config('system','directory'))) {
@@ -1020,6 +1049,7 @@ function admin_page_site(&$a) {
                '$worker'               => array('worker', t("Enable 'worker' background processing"), get_config('system','worker'), t("The worker background processing limits the number of parallel background jobs to a maximum number and respects the system load.")),
                '$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.")),
 
                '$form_security_token'  => get_form_security_token("admin_site")
 
@@ -1123,18 +1153,20 @@ function admin_page_dbsync(&$a) {
  * @param App $a
  */
 function admin_page_users_post(&$a){
-       $pending        =       (x($_POST, 'pending')                   ? $_POST['pending']             : array());
-       $users          =       (x($_POST, 'user')                      ? $_POST['user']                : array());
-       $nu_name        =       (x($_POST, 'new_user_name')             ? $_POST['new_user_name']       : '');
-       $nu_nickname    =       (x($_POST, 'new_user_nickname')         ? $_POST['new_user_nickname']   : '');
-       $nu_email       =       (x($_POST, 'new_user_email')            ? $_POST['new_user_email']      : '');
+       $pending     =  (x($_POST, 'pending')                   ? $_POST['pending']             : array());
+       $users       =  (x($_POST, 'user')                      ? $_POST['user']                : array());
+       $nu_name     =  (x($_POST, 'new_user_name')             ? $_POST['new_user_name']       : '');
+       $nu_nickname =  (x($_POST, 'new_user_nickname')         ? $_POST['new_user_nickname']   : '');
+       $nu_email    =  (x($_POST, 'new_user_email')            ? $_POST['new_user_email']      : '');
+       $nu_language = get_config('system', 'language');
 
        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));
+               $result = create_user(array('username'=>$nu_name, 'email'=>$nu_email, 
+                       'nickname'=>$nu_nickname, 'verified'=>1, 'language'=>$nu_language));
                if(! $result['success']) {
                        notice($result['message']);
                        return;
@@ -1265,7 +1297,7 @@ function admin_page_users(&$a){
 
 
        /* get users */
-       $total = q("SELECT COUNT(*) AS `total` FROM `user` WHERE 1");
+       $total = qu("SELECT COUNT(*) AS `total` FROM `user` WHERE 1");
        if(count($total)) {
                $a->set_pager_total($total[0]['total']);
                $a->set_pager_itemspage(100);
@@ -1273,14 +1305,14 @@ function admin_page_users(&$a){
 
        /* ordering */
        $valid_orders = array(
-               'contact.name', 
+               'contact.name',
                'user.email',
                'user.register_date',
                'user.login_date',
-               'lastitem.lastitem_date',
+               'lastitem_date',
                'user.page-flags'
        );
-       
+
        $order = "contact.name";
        $order_direction = "+";
        if (x($_GET,'o')){
@@ -1289,38 +1321,28 @@ function admin_page_users(&$a){
                        $order_direction = "-";
                        $new_order = substr($new_order,1);
                }
-               
+
                if (in_array($new_order, $valid_orders)){
                        $order = $new_order;
                }
                if (x($_GET,'d')){
                        $new_direction = $_GET['d'];
-                       
                }
        }
        $sql_order = "`".str_replace('.','`.`',$order)."`";
        $sql_order_direction = ($order_direction==="+")?"ASC":"DESC";
-       
-       $users = q("SELECT `user`.* , `contact`.`name` , `contact`.`url` , `contact`.`micro`, `lastitem`.`lastitem_date`, `user`.`account_expired`
-                               FROM
-                                       (SELECT MAX(`item`.`changed`) as `lastitem_date`, `item`.`uid`
-                                       FROM `item`
-                                       WHERE `item`.`type` = 'wall'
-                                       GROUP BY `item`.`uid`) AS `lastitem`
-                                                RIGHT OUTER JOIN `user` ON `user`.`uid` = `lastitem`.`uid`,
-                                          `contact`
-                               WHERE
-                                          `user`.`uid` = `contact`.`uid`
-                                               AND `user`.`verified` =1
-                                       AND `contact`.`self` =1
-                               ORDER BY $sql_order $sql_order_direction LIMIT %d, %d
-                               ",
+
+       $users = qu("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`
+                               ORDER BY $sql_order $sql_order_direction LIMIT %d, %d",
                                intval($a->pager['start']),
                                intval($a->pager['itemspage'])
                                );
-    
+
        //echo "<pre>$users"; killme();
-                               
+
        $adminlist = explode(",", str_replace(" ", "", $a->config['admin_email']));
        $_setup_users = function ($e) use ($adminlist){
                $accounts = array(
@@ -1383,6 +1405,7 @@ function admin_page_users(&$a){
                '$h_deleted' => t('User waiting for permanent deletion'),
                '$th_pending' => array(t('Request date'), t('Name'), t('Email')),
                '$no_pending' =>  t('No registrations.'),
+               '$pendingnotetext' => t('Note from the user'),
                '$approve' => t('Approve'),
                '$deny' => t('Deny'),
                '$delete' => t('Delete'),
@@ -1864,6 +1887,12 @@ function admin_page_logs(&$a){
                LOGGER_DATA     => 'Data',
                LOGGER_ALL      => 'All'
        );
+       
+       if (ini_get('log_errors')) {
+               $phplogenabled = t('PHP log currently enabled.');
+       } else {
+               $phplogenabled = t('PHP log currently disabled.');
+       }
 
        $t = get_markup_template("admin_logs.tpl");
 
@@ -1884,6 +1913,7 @@ function admin_page_logs(&$a){
                '$phpheader' => t("PHP logging"),
                '$phphint' => t("To enable logging of PHP errors and warnings you can add the following to the .htconfig.php file of your installation. The filename set in the 'error_log' line is relative to the friendica top-level directory and must be writeable by the web server. The option '1' for 'log_errors' and 'display_errors' is to enable these options, set to '0' to disable them."),
                '$phplogcode' => "error_reporting(E_ERROR | E_WARNING | E_PARSE);\nini_set('error_log','php.out');\nini_set('log_errors','1');\nini_set('display_errors', '1');",
+               '$phplogenabled' => $phplogenabled,
        ));
 }