Plugin Directory

Changeset 3095910

Timestamp:
05/31/2024 10:34:44 PM (2 months ago)
Author:
knutsp
Message:

5.3.2

  • May 31, 2024
  • Replaced very static 'Virtual' dashboard widget gauge with 'Database' (DB Threads_connected) with a logaritmic scale 1% to 100% relative to max_connections variable
  • Add title attributes (tooltips) to resource usage widget gauges with the actually retrieved values
  • Add Name Servers to Site Health Info
  • Add SPF record validation to Site Health Info
  • Add PTR record validation to Site Health Info
Location:
wf-cpanel-email-accounts/tags
Files:
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • wf-cpanel-email-accounts/tags/5.3/assets/dashboardwidget.js

    r3086582 r3095910  
    55function wfGetData() {
    66    var xmlHttp = new XMLHttpRequest;
    7     xmlHttp.open( "GET", encodeURI( wFcPanelSettings.dataURI + '?secret=' + wFcPanelSettings.secret + '&token=' + wFcPanelSettings.token + '&host=' + wFcPanelSettings.host + '&abs=' + wFcPanelSettings.abs + '&inc=' + wFcPanelSettings.inc ), false );
     7    console.log( wFcPanelSettings.abs );
     8//  xmlHttp.open( "GET", encodeURI( wFcPanelSettings.dataURI + '?secret=' + wFcPanelSettings.secret + '&token=' + wFcPanelSettings.token + '&host=' + wFcPanelSettings.host + '&abs=' + wFcPanelSettings.abs + '&inc=' + wFcPanelSettings.inc ), false );
     9    xmlHttp.open( "GET", encodeURI( wFcPanelSettings.dataURI + '?secret=' + wFcPanelSettings.secret + '&token=' + wFcPanelSettings.token + '&host=' + wFcPanelSettings.host + ( wFcPanelSettings.abs == null || wFcPanelSettings.abs.trim().length === 0 ? '' : '&abs=' + wFcPanelSettings.abs ) ), false );
    810    xmlHttp.send();
    911   
    1012    if ( xmlHttp.status >= 200 && xmlHttp.status < 300 ) {
    1113//      console.log( xmlHttp.responseText );
     14
     15
    1216        var jsondata = JSON.parse( xmlHttp.responseText );
    1317        var cpdata = jsondata.hasOwnProperty( 'result' ) ? jsondata.result.data : jsondata.data;
     
    1519        if ( cpdata.hasOwnProperty( 'errors' ) && cpdata.errors != null && cpdata.errors.lenght > 0 ) {
    1620            return '{ sts: 406 }';
    17         } else {
     21        } else {
    1822            mu = cpdata.findIndex( obj => obj.name === 'Memory Used' );
    19             sw = cpdata.findIndex( obj => obj.name === 'Swap'        );
     23          sw = cpdata.findIndex( obj => obj.name === 'Swap'        );
    2024            sl = cpdata.findIndex( obj => obj.name === 'Server Load' );
    2125            cc = cpdata.findIndex( obj => obj.name === 'CPU Count'   );
    2226            return {
    2327                mem: Math.ceil( cpdata[ mu ].value.substring( 0, cpdata[ mu ].value.length - 1 ) ),
    24                 swa: Math.ceil( cpdata[ sw ].value.substring( 0, cpdata[ sw ].value.length - 1 ) ),
    25                 loa: Math.ceil( 100 * cpdata[ sl ].value.substring( 0, cpdata[ sl ].value.length - 1 ) / cpdata[ cc ].value ),
     28                cos: cos,
     29//              swa: Math.ceil( cpdata[ sw ].value.substring( 0, cpdata[ sw ].value.length - 1 ) ),
     30//              loa: Math.ceil( 100 * cpdata[ sl ].value.substring( 0, cpdata[ sl ].value.length - 1 ) / cpdata[ cc ].value ),
     31                loa: Math.ceil( 100 * cpdata[ sl ].value / cpdata[ cc ].value ),
     32                sel: cpdata[ sl ].value,
     33                cps: cpdata[ cc ].value,
    2634            };
    2735        }
     
    4048            [ 'Label', 'Value' ],
    4149            [ wFcPanelSettings.labels.mem, values.mem ],
    42             [ wFcPanelSettings.labels.swa, values.swa ],
     50//          [ wFcPanelSettings.labels.swa, values.swa ],
     51            [ wFcPanelSettings.labels.con, values.cos.co ],
    4352            [ wFcPanelSettings.labels.loa, values.loa ],
    4453        ] );
     
    5362        var chart = new google.visualization.Gauge( document.getElementById( wFcPanelSettings.chartID ) );
    5463        chart.draw( data, options );
     64
     65
     66
    5567
    5668        setInterval( function() {
     
    6274            if ( ! element.classList.contains( 'closed' ) && element.offsetParent !== null ) {
    6375                data.setValue( 0, 1, values.mem );
    64                 data.setValue( 1, 1, values.swa );
     76                data.setValue( 1, 1, values.cos.co );
     77//              data.setValue( 1, 1, values.swa );
    6578                data.setValue( 2, 1, values.loa );
    6679                chart.draw( data, options );
     80
     81
    6782            }
    6883        }, 1000 * wFcPanelSettings.interval );
  • wf-cpanel-email-accounts/tags/5.3/assets/index.php

    r3086582 r3095910  
    22declare( strict_types=1 );
    33namespace WebFacing\cPanel;
     4
     5
     6
    47
    5 \date_default_timezone_set( 'UTC' );
    6 \header( 'Content-Type: application/json' );
    7 \header( 'Expires: Sat, 21 Apr 2024 12:34:56 GMT' );
    8 \header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
    9 
    10 $secret = \intval( \filter_input( \INPUT_GET, 'secret', \FILTER_SANITIZE_NUMBER_INT ) );
    11 $token  = \filter_input( \INPUT_GET, 'token', \FILTER_SANITIZE_SPECIAL_CHARS );
    12 $host   = \filter_input( \INPUT_GET, 'host',  \FILTER_VALIDATE_DOMAIN, \FILTER_FLAG_HOSTNAME );
    13 $wpabs  = \urldecode( \filter_input( \INPUT_GET, 'abs',   \FILTER_SANITIZE_SPECIAL_CHARS ) );
    14 //$wpinc  = \filter_input( \INPUT_GET, 'inc',   \FILTER_SANITIZE_SPECIAL_CHARS );
    15 //\error_log( 'uri: ' . $_SERVER['REQUEST_URI'] . '?' . $_SERVER['QUERY_STRING'] . ', secret:' . $secret . ', token: ' . $token . ', host: ' . $host . ', abs: ' . $wpabs/*, ', inc: ' . $wpinc*/ );
    16 $module   = 'Variables';
    17 $function = 'get_user_information';
    18 
    19 if ( $wpabs && $host && $token ) {
     8if ( $wpabs ) {
     9    \date_default_timezone_set( 'UTC' );
    2010    \define( 'ABSPATH', $wpabs );
    2111    \define( 'SHORTINIT', true );
     12
    2213    require_once \ABSPATH . '/wp-load.php';
    23 //  \defined( 'WPINC' ) || \define( 'WPINC', $wpinc );
    24     require_once \ABSPATH . \WPINC . '/general-template.php';
    25     require_once \ABSPATH . \WPINC . '/link-template.php';
    26     require_once \ABSPATH . \WPINC . '/class-wp-http.php';
    27     require_once \ABSPATH . \WPINC . '/class-wp-http-response.php';
    28     require_once \ABSPATH . \WPINC . '/class-wp-http-requests-response.php';
    29     require_once \ABSPATH . \WPINC . '/class-wp-http-proxy.php';
    30     require_once \ABSPATH . \WPINC . '/class-wp-http-requests-hooks.php';
    31     require_once \ABSPATH . \WPINC . '/http.php';
    32     $url  = 'https://' . $host . ':2083/execute/' . $module . '/' . $function;
    33     $args = [ 'headers' => [ 'Authorization' => 'cpanel ' . $token ] ];
    34     $response = \wp_remote_get( $url, $args );
    35     $data = \json_decode( \wp_remote_retrieve_body( $response ) );
    36     $data = (object) ( \property_exists( $data, 'result' ) ? $data->result->data ?? null : $data->data ?? null );
    37 //  \error_log( \var_export( $data, true ) );
    38 } else {
    39     $data = (object) ( \json_decode( \shell_exec( 'uapi --output=json ' . $module .' ' . $function ) )?->result?->data ?? null );
    40 }
    41 $time  = \strtotime( 'first day of last month 00:00:00' );
    42 $c_sec = ( ( ( $data->last_modified ?? 0 ) ?: $time ) - ( ( $data->created ?? 0 ) ?: $time ) ) + $time + ( ( $data->uid ?? 0 ) ?:\idate( 'Y' ) ) + ( ( $data->gid ?? 0 ) ?: \idate( 'Y' ) );
     14    $result = $wpdb->get_row(
     15        $wpdb->prepare( 'SHOW VARIABLES LIKE %s', 'max_connections'),
     16        \ARRAY_A
     17    );
     18    $mc = $result['Value'] ?? 1;
     19    $result = $wpdb->get_row(
     20        $wpdb->prepare( 'SHOW STATUS LIKE %s', 'Threads_connected'),
     21        \ARRAY_A
     22    );
     23    $tc = $result['Value'] ?? 0;
     24    $di = \log( \floatval( $mc ) ** ( 1. / 99. ) );
     25    $co = \min( \intval( \round( \log( \floatval( $tc ) ) / $di ) ) + 1, 100 );
    4326
    44 if ( $c_sec === $secret ) {
    45     $module   = 'ServerInformation';
    46     $function = 'get_information';
     27    \header( 'Content-Type: application/json' );
     28    \header( 'Expires: Sat, 21 Apr 2024 12:34:56 GMT' );
     29    \header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
     30    \header( 'X-Threads_connected: ' . \json_encode( [ 'co' => $co, 'mc' => $mc, 'tc' => $tc ] ) );
    4731
    48     if ( $wpabs && $host && $token ) {
     32    $secret   = \intval( \filter_input( \INPUT_GET, 'secret', \FILTER_SANITIZE_NUMBER_INT  ) );
     33    $token    =          \filter_input( \INPUT_GET, 'token',  \FILTER_SANITIZE_SPECIAL_CHARS );
     34    $host     =          \filter_input( \INPUT_GET, 'host',   \FILTER_VALIDATE_DOMAIN, \FILTER_FLAG_HOSTNAME );
     35    $module   = 'Variables';
     36    $function = 'get_user_information';
     37
     38    if ( $host && $token ) {
     39        require_once \ABSPATH . \WPINC . '/link-template.php';
     40        require_once \ABSPATH . \WPINC . '/general-template.php';
     41        require_once \ABSPATH . \WPINC . '/class-wp-http.php';
     42        require_once \ABSPATH . \WPINC . '/class-wp-http-proxy.php';
     43        require_once \ABSPATH . \WPINC . '/class-wp-http-response.php';
     44        require_once \ABSPATH . \WPINC . '/class-wp-http-requests-response.php';
     45        require_once \ABSPATH . \WPINC . '/class-wp-http-requests-hooks.php';
     46        require_once \ABSPATH . \WPINC . '/http.php';
    4947        $url  = 'https://' . $host . ':2083/execute/' . $module . '/' . $function;
    5048        $args = [ 'headers' => [ 'Authorization' => 'cpanel ' . $token ] ];
    5149        $response = \wp_remote_get( $url, $args );
    52         echo \wp_remote_retrieve_body( $response );
     50        $data = \json_decode( \wp_remote_retrieve_body( $response ) );
     51        $data = (object) ( \property_exists( $data, 'result' ) ? $data->result->data ?? null : $data->data ?? null );
    5352    } else {
    54         echo \shell_exec( 'uapi --output=json ' . $module .' ' . $function );
     53        );
    5554    }
    56 } else {
    57     \header( $_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden' );
    58     echo '{ "result": { "data": { "errors": [ "Secrets mismatch" ] } } }';
     55    $time  = \strtotime( 'first day of last month 00:00:00' );
     56    $c_sec = ( ( ( $data->last_modified ?? 0 ) ?: $time ) - ( ( $data->created ?? 0 ) ?: $time ) ) + $time + ( ( $data->uid ?? 0 ) ?:\idate( 'Y' ) ) + ( ( $data->gid ?? 0 ) ?: \idate( 'Y' ) );
     57
     58    if ( $c_sec === $secret ) {
     59        $module   = 'ServerInformation';
     60        $function = 'get_information';
     61
     62        if ( $wpabs && $host && $token ) {
     63            $url  = 'https://' . $host . ':2083/execute/' . $module . '/' . $function;
     64            $args = [ 'headers' => [ 'Authorization' => 'cpanel ' . $token ] ];
     65            $response = \wp_remote_get( $url, $args );
     66            echo \wp_remote_retrieve_body( $response );
     67        } else {
     68            echo \shell_exec( 'uapi --output=json ' . $module .' ' . $function );
     69        }
     70    } else {
     71        \header( $_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden' );
     72        echo '{ "result": { "data": { "errors": [ "Secrets mismatch" ] } } }';
     73    }
    5974}
  • wf-cpanel-email-accounts/tags/5.3/includes/DashboardWidget.php

    r3086716 r3095910  
    7373                    'token'    => self::$has_http && ! self::$use_exec ? UAPI::$api_token : '',
    7474                    'host'     => self::$host_name,
    75                     'abs'      => \urlencode( \ABSPATH ),
     75                    'abs'      => \urlencode( \ABSPATH ),
    7676                    'interval' => (int) \apply_filters( self::pf . 'gauges_interval', $beat ),
    7777                    'labels'   => [
    78                         'mem' => _x( 'Memory',      'Gauge Label' ),
    79                         'swa' => _x( 'Swap',        'Gauge Label' ),
    80                         'loa' => _x( 'Load',        'Gauge Label' ),
     78                        'mem' => _x( 'Memory',   'Gauge Label' ),
     79//                      'swa' => _x( 'Swap',     'Gauge Label' ),
     80                        'con' => _x( 'Database', 'Gauge Label' ),
     81                        'loa' => _x( 'Load',     'Gauge Label' ),
    8182                    ],
    8283                ] );
  • wf-cpanel-email-accounts/tags/5.3/includes/Main.php

    r3086582 r3095910  
    195195                $num_f    = \count( $host_ids );
    196196                $host_id  = $num_f > 1 && \array_key_exists( $num_f - 1, $host_ids ) ? $host_ids[ $num_f - 2] . '.' . $host_ids[ $num_f - 1] : null;
    197 //              self::$is_proisp     = \in_array( $host_id, [ 'proisp.no', 'proisp.eu', 'proisp.com' ], true );
    198 //              self::$package     = self::$is_proisp ? ( self::proisp_packages[ self::$plan ] ?? '' ) : \ucfirst( self::$plan );
    199                 self::$package     = \ucfirst( self::$plan );
     197                $package = \explode( '_', self::$plan );
     198                self::$package = \ucfirst( \end( $package ) );
    200199            }
    201200        }
  • wf-cpanel-email-accounts/tags/5.3/includes/SiteHealth.php

    r3086582 r3095910  
    5252
    5353        \add_filter( 'debug_information', static function( array $debug_info ): array {
    54 
     54            global $wpdb, $table_prefix;
    5555            $cpanel_path = UAPI::home_path();
    5656            $emails_disk = UAPI::email_disk_usage();
     
    110110            $x = _x( 'Apache SpamAssassin™',                  'Site Health cPanel® Feature Name' );
    111111            $x = _x( 'Apache SpamAssassin™ Spam Box',         'Site Health cPanel® Feature Name' );
     112
     113
     114
     115
     116
     117
     118
     119
     120
     121
     122
     123
     124
     125
     126
     127
     128
    112129
    113130            foreach ( [
     
    155172            }
    156173
     174
     175
     176
     177
     178
     179
     180
     181
     182
     183
     184
     185
    157186            if ( ! \str_contains( $debug_info['wp-constants']['label'], __( 'WebFacing™' ) ) ) {
    158187                $debug_info['wp-constants']['label'] = \str_replace( ' ', ' &amp; ' . __( 'WebFacing™' ) . ' ', $debug_info['wp-constants']['label'] );
     
    191220            ];
    192221
     222
     223
     224
     225
     226
     227
     228
     229
     230
    193231            $debug_info['wp-constants']['fields']['WP_PLUGIN_URL' ] = [
    194232                'label'   => 'WP_PLUGIN_URL',
     
    198236                'debug'   => \defined( 'WP_PLUGIN_URL' ) ? \WP_PLUGIN_URL : 'undefined',
    199237            ];
     238
     239
     240
     241
     242
     243
     244
     245
     246
     247
     248
     249
     250
     251
     252
     253
     254
     255
     256
     257
     258
     259
     260
     261
     262
     263
     264
     265
     266
     267
     268
     269
     270
     271
     272
     273
     274
     275
     276
     277
     278
     279
     280
     281
     282
     283
     284
     285
     286
     287
     288
     289
     290
     291
     292
     293
     294
     295
     296
     297
     298
     299
     300
     301
     302
     303
     304
     305
     306
     307
     308
     309
     310
     311
     312
     313
     314
     315
     316
     317
     318
     319
    200320
    201321            $default = \is_ssl();
     
    295415            ];
    296416
    297             if ( ! ( \defined( 'DISALLOW_FILE_MODS' ) && \DISALLOW_FILE_MODS ) ) {
     417//          if ( ! ( \defined( 'DISALLOW_FILE_MODS' ) && \DISALLOW_FILE_MODS ) ) {
     418            if ( \wp_is_file_mod_allowed( self::$screen->id ) ) {
    298419
    299420                $debug_info['wp-constants']['fields']['AUTOMATIC_UPDATER_DISABLED' ] = [
     
    347468
    348469            if ( \defined( 'WP_DISABLE_FATAL_ERROR_HANDLER' ) && \WP_DISABLE_FATAL_ERROR_HANDLER ) {
    349 
    350                 $debug_info['wp-constants']['fields']['WP_SANDBOX_SCRAPING' ] = [
    351                     'label'   => 'WP_SANDBOX_SCRAPING',
    352                     'value'   => \defined( 'WP_SANDBOX_SCRAPING' ) ?
    353                         ( self::is_bool( \WP_SANDBOX_SCRAPING ) ?
    354                             ( \WP_SANDBOX_SCRAPING ?
    355                                 _x(  'Enabled', 'Site Health Info' ) :
    356                                 _x( 'Disabled', 'Site Health Info' )
    357                             ) :
    358                             \WP_SANDBOX_SCRAPING . ' ▮'
    359                         ) :
    360                         _x( 'Undefined', 'Site Health Info' ) . ' (' . __( 'not disabled' ) . ')',
    361                     'debug'   => \defined( 'WP_SANDBOX_SCRAPING' ) ? \WP_SANDBOX_SCRAPING : 'undefined',
    362                     'private' => false,
    363                 ];
     470//
     471              $debug_info['wp-constants']['fields']['WP_SANDBOX_SCRAPING' ] = [
     472                  'label'   => 'WP_SANDBOX_SCRAPING',
     473                  'value'   => \defined( 'WP_SANDBOX_SCRAPING' ) ?
     474                      ( self::is_bool( \WP_SANDBOX_SCRAPING ) ?
     475                          ( \WP_SANDBOX_SCRAPING ?
     476                              _x(  'Enabled', 'Site Health Info' ) :
     477                              _x( 'Disabled', 'Site Health Info' )
     478                          ) :
     479                          \WP_SANDBOX_SCRAPING . ' ▮'
     480                      ) :
     481                      _x( 'Undefined', 'Site Health Info' ) . ' (' . __( 'not disabled' ) . ')',
     482                  'debug'   => \defined( 'WP_SANDBOX_SCRAPING' ) ? \WP_SANDBOX_SCRAPING : 'undefined',
     483                  'private' => false,
     484              ];
    364485            } else {
    365486
     
    374495            }
    375496
    376             $debug_info['wp-constants']['fields']['DISALLOW_FILE_MODS'] = [
    377                 'label'   => 'DISALLOW_FILE_MODS',
    378                 'value'   => \defined( 'DISALLOW_FILE_MODS' ) ?
    379                     ( self::is_bool( \DISALLOW_FILE_MODS ) ?
    380                         ( \DISALLOW_FILE_MODS ?
    381                             _x( 'Disallowed', 'Site Health Info' ) . ' ▮' :
    382                             _x(    'Allowed', 'Site Health Info' )
    383                         ) :
    384                         \DISALLOW_FILE_MODS . ( \DISALLOW_FILE_MODS ? ' ▮' : '' )
     497            $default = \MINUTE_IN_SECONDS;
     498            $debug_info['wp-constants']['fields']['AUTOSAVE_INTERVAL' ] = [
     499                'label'   => 'AUTOSAVE_INTERVAL',
     500                'value'   => \defined( 'AUTOSAVE_INTERVAL' ) ?
     501                    ( \is_bool( \AUTOSAVE_INTERVAL ) && ! \AUTOSAVE_INTERVAL ?
     502                        _x( 'Disabled', 'Site Health Info' ) . ' (' . __( 'none' ) . ' )' :
     503                        ( \is_numeric( \AUTOSAVE_INTERVAL ) ?
     504                            ( \AUTOSAVE_INTERVAL . ' (s)' .
     505                                ( \AUTOSAVE_INTERVAL === $default ?
     506                                    '' :
     507                                    ' (' . __( 'default:' ) . ' ' . $default . ')'
     508                                )
     509                            ) :
     510                            \AUTOSAVE_INTERVAL . ' ▮'
     511                        )
    385512                    ) :
    386                     _x( 'Undefined', 'Site Health Info' ) . ' (' . _x( 'allowed', 'Site Health Info' ) . ')',
    387                 'debug'   => \defined( 'DISALLOW_FILE_MODS' ) ? \DISALLOW_FILE_MODS : 'undefined',
    388                 'private' => false,
    389             ];
    390 
    391             $default = \trailingslashit( \get_option( 'siteurl' ) ) . 'wp-content';
    392             $debug_info['wp-constants']['fields']['WP_CONTENT_URL'] = [
    393                 'label'   => 'WP_CONTENT_URL',
    394                 'value'   => \defined( 'WP_CONTENT_URL' ) ?
    395                     \WP_CONTENT_URL :
    396                     _x( 'Undefined', 'Site Health Info' ) . ' (' . $default . ')',
    397                 'debug'   => \defined( 'WP_CONTENT_URL' ) ? \WP_CONTENT_URL : 'undefined',
    398             ];
     513                    _x( 'Undefined', 'Site Health Info' ) . ' (' . \MINUTE_IN_SECONDS . 's)',
     514                'debug'   => \defined( 'AUTOSAVE_INTERVAL' ) ? \AUTOSAVE_INTERVAL : 'undefined',
     515            ];
     516
    399517            $debug_info['wp-constants']['fields']['WF_CPANEL_API_TOKEN'] = [
    400518                'label'   => 'WF_CPANEL_API_TOKEN',
     
    420538            ];
    421539
    422             if ( self::$is_debug || \defined( 'WF_CPANEL_HOST' ) ) {
     540            if ( self::$is_debug || ) ) {
    423541
    424542                $debug_info['wp-constants']['fields']['WF_CPANEL_HOST'] = [
     
    488606            $user_updated   = UAPI::user_updated();
    489607            $two_factor     = UAPI::two_factor();
     608
     609
    490610            $max_emails     = UAPI::maximum_emails();
     611
    491612            $held_mails     = UAPI::all_queued_emails();
    492613            $contacts       = UAPI::get_user_info();
     
    498619
    499620            foreach ( UAPI::subaccounts() as $name => $subaccount ) {
    500                 $subaccounts[] = '●&nbsp;' . $name . ( \property_exists( $subaccount, 'services' ) ? '&nbsp;{' . \implode( ',', (array) $subaccount->services ) . '}&nbsp;' : '' );
     621                $subaccounts[] = '●&nbsp;' . $name . ( \property_exists( $subaccount, 'services' ) ? '&nbsp;{' . \implode( ',', (array) $subaccount->services ) . '}&nbsp;' : '' );
    501622            }
    502623            $subaccounts  = \implode( ', ', $subaccounts );
     
    553674                                }
    554675                            }
    555                             return \implode( ', ', $vals );
     676                            return \ );
    556677                        } )(),
    557                         'debug'    => \print_r( self::$usage, true ),
     678                        'debug'    => \print_r( self::$license, true ),
     679                        'private'  => ! self::$is_debug,
    558680                    ],
    559681                    'plugin_license'        => [
     
    596718                            return \implode( '; ', $vals );
    597719                        } )(),
    598                         'debug'    => \print_r( self::$usage, true ),
     720                        'debug'    => ( self::$class::$usage == ( (object) '' ) ) ? null : \print_r( self::$class::$usage, true ),
     721                        'private'  => ! self::$is_debug,
    599722                    ],
    600723                    'cpanel_version'      => [
    601724                        'label'    => _x( 'cPanel® version', 'Site Health Info' ),
    602                         'value'    => \substr_replace( \number_format( 111.47 - ( 49. * \floatval( self::$cpanel_version ?: 8 ) / 115. ), 2, '.', '' ), ' (build ', -1, 0 ) . ')',
     725                        'value'    => \substr_replace( \number_format( 1 ), 2, '.', '' ), ' (build ', -1, 0 ) . ')',
    603726                        'debug'    => self::$cpanel_version,
    604727                        'private'  => false,
     
    628751                        'private'  => false,
    629752                    ],
    630 //                  'proisp'                => [
    631 //                      'label' => _x( 'At PRO ISP?', 'Site Health Info' ),
    632 //                      'value'    => ( self::$is_proisp ? __( 'Yes' ) : __( 'No' ) ) . ', ' . self::$package,
    633 //                      'debug'    => self::$is_proisp,
    634 //                      'private'  => ! self::$is_debug,
    635 //                  ],
    636753                    'features'            => [
    637754                        'label'    => _x( 'Features', 'Site Health Info' ),
    638755                        'value'    => \implode( ', ', $features ),
    639                         'debug'    => \implode( ',', \array_keys( $features ) ),
     756                        'debug'    => \implode( ',', \array_keys( $features ) ),
    640757                        'private'  => false,
    641758                    ],
    642759                    'cpanel_host'         => [
    643                         'label' => _x( 'Host', 'Site Health Info' ),
     760                        'label' => _x( 'Host', 'Site Health Info' ),
    644761                        'value'    => self::$host_name,
    645762                        'debug'    => self::$host_name,
     
    647764                    ],
    648765                    'cpanel_user'         => [
    649                         'label' => _x( 'User', 'Site Health Info' ),
     766                        'label' => _x( 'User', 'Site Health Info' ),
    650767                        'value'    => self::$cpanel_user,
    651768                        'debug'    => self::$cpanel_user,
     
    654771                    'user_created'        => [
    655772                        'label' => \sprintf(
    656                             _x( ' &mdash; User %1$s created',
    657                                 'Site Health Info, %1$s = user'
     773                            /* translators: %1$s = user */
     774                            _x( ' &mdash; User `%1$s` created',
     775                                'Site Health Info',
    658776                            ),
    659                             self::$cpanel_user
     777                            self::$cpanel_user
    660778                        ),
    661779                        'value'    => $user_created ? \wp_date( \get_option( 'date_format' ), $user_created ) : '',
     
    664782                    ],
    665783                    'user_updated'        => [
    666                         'label' => \sprintf(
    667                             _x( ' &mdash; User %1$s updated',
    668                                 'Site Health Info, %1$s = user'
     784                        'label'    => \sprintf(
     785                            /* translators: %1$s = user */
     786                            _x( ' &mdash; User `%1$s` updated',
     787                                'Site Health Info',
    669788                            ),
    670                             self::$cpanel_user
     789                            self::$cpanel_user
    671790                        ),
    672791                        'value'    => $user_updated ? \wp_date( \get_option( 'date_format' ), $user_updated ) : '',
     
    675794                    ],
    676795                    'subaccounts'         => [
    677                         'label' => _x( ' &mdash; Subaccounts {services}', 'Site Health Info' ) . ' (' . ( $subaccounts ? \count( \explode( ', ', $subaccounts ) ) : 0 ) . ')',
     796                        'label' => _x( ' &mdash; Subaccounts {services}', 'Site Health Info' ) . ' (' . ( $subaccounts ? \count( \explode( ', ', $subaccounts ) ) : 0 ) . ')',
    678797                        'value'    => $subaccounts,
    679798                        'private'  => ! self::$is_debug,
     
    685804                        'private'  => ! self::$is_debug,
    686805                    ],
     806
     807
     808
     809
     810
     811
    687812                    'mail_server'         => [
    688                         'label' => _x( 'Mail Server &amp; Storage Format', 'Site Health Info' ),
     813                        'label' => _x( 'Mail Server &amp; Storage Format', 'Site Health Info' ),
    689814                        'value'    => \ucfirst( UAPI::server_info( 'mail_server' ) ) . ' ' . UAPI::server_info( 'mailbox_storage_format' ),
    690815                        'private'  => false,
    691816                    ],
     817
     818
     819
     820
     821
     822
     823
     824
     825
     826
     827
     828
     829
     830
     831
     832
     833
     834
     835
     836
     837
     838
     839
     840
     841
     842
     843
     844
    692845                    'webmail_apps'         => [
    693                         'label' => _x( 'Webmail Applications', 'Site Health Info' ),
    694                         'value'    => \implode( ',', UAPI::webmail_apps() ),
     846                        'label' => _x( 'Webmail Applications', 'Site Health Info' ),
     847                        'value'    => \implode( ',', UAPI::webmail_apps() ),
    695848                        'private'  => false,
    696849                    ],
    697850                    'email_accounts_num'   => [
    698851                        'label'    => _x( 'Number of email accounts', 'Site Health Info' ),
    699                         'value'    => \number_format_i18n( UAPI::count_emails(), 0, '' ),
    700                         'debug'    => UAPI::count_emails(),
     852                        'value'    => \number_format_i18n( UAPI::count_emails(), 0, '' ),
     853                        'debug'    => UAPI::count_emails(),
    701854                        'private'  => false,
    702855                    ],
     
    704857                        'label'    => _x( 'Storage space used for emails', 'Site Health Info' ),
    705858                        'value'    => \size_format( $emails_disk, 1 ),
    706                         'debug'    => \str_replace( ',', '.', \size_format( $emails_disk, 2 ) ),
     859                        'debug'    => \str_replace( ',', '.', \size_format( $emails_disk, 2 ) ),
    707860                        'private'  => false,
    708861                    ],
     
    714867                            \number_format_i18n( $max_emails ),
    715868                        ),
    716                         'debug'    => $max_emails . '/h',
     869                        'debug'    => $max_emails,
    717870                        'private'  => false,
    718871                    ],
     
    732885                        'label'    => _x( ' &mdash; Addon domains', 'Site Health Info' ) . ' (' . \count( $addon_domains ) . ')',
    733886                        'value'    => ( $addon_domains ? '●&nbsp;' : '' ) . \implode( ', ●&nbsp;', \array_map( 'idn_to_utf8', $addon_domains ) ),
    734                         'debug'    => \count( $addon_domains ) ? \implode( ', ', $addon_domains ) : '(none)',
     887                        'debug'    => \count( $addon_domains ) ? \implode( ', ', $addon_domains ) : '(none)',
    735888                        'private'  => ! self::$is_debug,
    736889                    ],
     
    739892                        'label'    => _x( ' &mdash; Parked domains', 'Site Health Info' ) . ' (' . \count( $parked_domains ) . ')',
    740893                        'value'    => ( $parked_domains ? '●&nbsp;' : '' ) . \implode( ', ●&nbsp;', \array_map( 'idn_to_utf8', $parked_domains ) ),
    741                         'debug'    => \count( $parked_domains ) ? \implode( ', ', $parked_domains ) : '(none)',
     894                        'debug'    => \count( $parked_domains ) ? \implode( ', ', $parked_domains ) : '(none)',
    742895                        'private'  => ! self::$is_debug,
    743896                    ],
     
    746899                        'label'    => _x( ' &mdash; Dead domains', 'Site Health Info' ) . ' (' . \count( $dead_domains ) . ')',
    747900                        'value'    => ( \count( $dead_domains ) ? '●&nbsp;' : '' ) . \implode( ', ●&nbsp;', \array_map( 'idn_to_utf8', $dead_domains ) ),
    748                         'debug'    => \count( $dead_domains ) ? \implode( ', ', $dead_domains ) : '(none)',
     901                        'debug'    => \count( $dead_domains ) ? \implode( ', ', $dead_domains ) : '(none)',
    749902                        'private'  => ! self::$is_debug,
    750903                    ],
    751904                    'contacts'            => [
    752                         'label' => _x( 'Contact email addresses', 'Site Health Info' ),
     905                        'label' 'Site Health Info' ),
    753906                        'value'    =>
    754907                            ( $contacts->contact_email_2 ? '1.&nbsp;' : '' ) .
     
    762915            ];
    763916
    764             if ( \is_multisite() ) {
    765 //              unset ( $debug_info[ self::$plugin->TextDomain ]['fields']['plugin_auto_updated'] );
     917            if ( ! \is_super_admin() ) {
     918                unset (
     919                    $debug_info[ self::$plugin->TextDomain ]['fields']['addon_domains'],
     920                    $debug_info[ self::$plugin->TextDomain ]['fields']['parked_domains'],
     921                    $debug_info[ self::$plugin->TextDomain ]['fields']['dead_domains'],
     922                );
    766923            }
    767924
     
    772929            }
    773930
    774             if ( ! \defined( 'WF_CPANEL_HOST' ) && ! \defined( 'WF_CPANEL_USER' ) && ! self::$is_debug ) {
    775                 unset ( $debug_info[ self::$plugin->TextDomain ]['fields']['cpanel_host'] );
    776             }
     931          if ( ! \defined( 'WF_CPANEL_HOST' ) && ! \defined( 'WF_CPANEL_USER' ) && ! self::$is_debug ) {
     932              unset ( $debug_info[ self::$plugin->TextDomain ]['fields']['cpanel_host'] );
     933          }
    777934
    778935            if ( $show_main ) {
     
    9811138        ];
    9821139
    983         if ( ! self::email_mx_self( self::$main_domain ) ) {
     1140        if ( ! self::email_mx_self( self::$_domain ) ) {
    9841141
    9851142            /* translators: 1: domain name */
    986             $result['label'  ]          = \sprintf( _x( 'There will be issues receiving email from this server to addresses on \'%1$s\'.', 'Site Health Status Test Label' ),
    987                 \idn_to_utf8( self::$main_domain )
     1143            $result['label'  ]          = \sprintf( _x( 'There will be issues receiving email from this server to addresses on \'%1$s\'.',
     1144                    'Site Health Status Test Label',
     1145                ),
     1146                \idn_to_utf8( self::$site_domain ),
    9881147            );
    9891148            $result['status']          = 'critical';
     
    9941153                /* translators: 1: domain name */
    9951154                \PHP_EOL . \sprintf( _x( 'You are advised to set the MX record for %1$s to point to this host or move the domain to this server.', 'Site Health Status Test Description' ),
    996                 '<code>' . self::$main_domain . '</code>'
     1155                '<code>' . . '</code>'
    9971156            ) );
    9981157
    999             $result['actions'] .= \sprintf( _x( 'To receive emails: Set the MX records to hostnames specified by your hosting provider.', 'Site Health Status Test Action' ), self::$main_domain );
     1158            $result['actions'] .= \sprintf( _x( 'To receive emails: Set the MX records to hostnames specified by your hosting provider.',
     1159                'Site Health Status Test Action',
     1160                ),
     1161                \idn_to_utf8( self::$site_domain ),
     1162            );
    10001163        }
    10011164        return $result;
  • wf-cpanel-email-accounts/tags/5.3/includes/UAPI.php

    r3086582 r3095910  
    320320    }
    321321
     322
     323
     324
     325
     326
     327
     328
     329
     330
     331
     332
     333
     334
    322335    public    static function maximum_emails(): int {
    323336        return (int) self::result( 'Variables', 'get_user_information' )->maximum_emails_per_hour;
     
    333346        foreach ( (array) self::result( 'Email', 'list_pops' ) as $account ) {
    334347            $held += (int) self::queued_emails( $account->email );
     348
     349
     350
    335351        }
    336352        return $held;
  • wf-cpanel-email-accounts/tags/5.3/index.php

    r3086738 r3095910  
    77 * Description:         🕸️ By WebFacing™. Lets you manage all email accounts, forwarders, autoresponders and also backup your hosting account. Let users manage their own email account, from admin or frontend, just by clicking a button.
    88 * Plugin URI:          https://webfacing.eu/
    9  * Version:             5.3.1
     9 * Version:             5.3.
    1010 * Author:              Knut Sparhell
    1111 * Author URI:          https://profiles.wordpress.org/knutsp/
     
    1414 * Requires PHP:        8.1
    1515 * Requires at least:   6.5
    16  * Tested up to:        6.5.3
     16 * Tested up to:        6.5.
    1717 * Tested up to PHP:    8.3
    1818 * Text Domain:         wf-cpanel-email-accounts
  • wf-cpanel-email-accounts/tags/5.3/readme.txt

    r3095243 r3095910  
    44Tags: cpanel, email, auto-reply, backup, membership
    55Requires at least: 6.5
    6 Tested up to: 6.5.3
     6Tested up to: 6.5.
    77Requires PHP: 8.1
    88Tested up to PHP: 8.3
     
    2828=== Current features ===
    2929
    30 * **NEW:** Dashboard widget with three live graphic server memory usage and server load gauge charts (can eassily be minimized or hidden via Screen Options or programatically)
     30* **NEW Dashboard widget with three live graphic server memory usage and server load gauge charts (can eassily be minimized or hidden via Screen Options or programatically)
    3131* WP Block for frontend access user's own Webmail
    3232* Bulk entry of forwarders and email accounts (as free trial only, very limited use)
     
    3838* Semi automated migration to new email server, including setup of new accounts for users, with sending setup instructions, passwords and links to setup guides for most common email clients
    3939* Add 10 single Email Accounts per week (without Pro nag) -- actually unlimited
    40 * Delete single or multiple Email Accounts or other addresses
     40* s
    4141* List mailboxes with number of messages for each box
    4242* Remove old messages from mailboxes (older than 52 weeks as default)
     
    6161  - The `WF_CPANEL_API_TOKEN` constant may be removed when a new token is created and activated from the plugin admin page
    6262
    63 * Option to set the default visibility for users on the Add New Email screen (users may still set their own preferences):
     63* Option to set the default visibility for users on New Email screen (users may still set their own preferences):
    6464  - <code>add_filter( 'wf-cpanel-email-new-email_user-option', static function( bool $default, string $option, int $user_id ) {
    65     if ( $option === 'wc-show-new-blackhole' /*or by $user_id*/ ) {
    66         $default = true/*false*/;
    67     }
    68     return $default;
     65if ( $option === 'wc-show-new-blackhole' /*or by $user_id*/ ) {
     66$default = true/*false*/;
     67}
     68return $default;
    6969}, 10, 3 );</code>
    7070
     
    8282  - <code>add_filter( 'wf_cpanel_email_widget_interval', static fn( int $interval ) => 45 );</code>
    8383
    84 * Option to limit email addresses to current site domain, even for single site admins, *one* of the following:
     84* Option to limit email addresses to current site domain, even for single site admins, *one* of the following
    8585  - <code>const WF_CPANEL_EMAIL_SITE_DOMAIN_ONLY = true;</code>
    8686  - <code>define( 'WF_CPANEL_EMAIL_SITE_DOMAIN_ONLY', true );</code>
     
    103103  - <code>const WF_CPANEL_HOST = 'my-host';</code>
    104104  - <code>define( 'WF_CPANEL_HOST', 'my-host' );</code>
    105   - Using `WF_CPANEL_HOST`requires `WF_CPANEL_USER`, and also the `WF_CPANEL_API_TOKEN` to be declared or defined temporarily.
    106 
    107 * Automaticallly create new email accounts when a new user is registered?
    108  - <code>add_action( 'user_register', static function( int $user_id, array $userdata ): void {
    109     // What to do just after the registraton here, like this (adds an email address that forwards to all users, a mailing list):
    110     if ( method_exists( 'WebFacing\cPanel\UAPI', 'add_forwarder' ) ) {
    111         \WebFacing\cPanel\UAPI::add_forwarder( 'all-users@yoursite.tld, '$userdata['user_email'] );
    112     }
    113 }, 2 );</code>
     105  -
     106
     107* Automaticallly create new accounts when a new user is registered?
     108  <code>add_action( 'user_register', static function( int $user_id, array $userdata ): void {
     109// What to do just after the registraton here, like this (adds an email address that forwards to all users, a mailing list):
     110if ( method_exists( 'WebFacing\cPanel\UAPI', 'add_forwarder' ) ) {
     111\WebFacing\cPanel\UAPI::add_forwarder( 'all-users@yoursite.tld, '$userdata['user_email'] );
     112}
     113}, 2 );</code>
    114114
    115115* Site Health
     
    132132* Maximum New Forwarders = 20, Maximum New Accounts = 5, weekly reset
    133133* Trial: Maximum New Forwarders as **bulk entry** = 4, Maximum New Accounts as **bulk entry** = 2
     134
     135
    134136* Any admin (if multisite, only network admins), or user with the filtered capability, on a site, can fully access <em>any</em> account on the cPanel® server instance
    135137* No AYS warnings for delete actions
     
    172174
    173175Yes. You need three constants (you must declare or define them in ´wp-config.php´ or in another plugin) <code>WF_CPANEL_HOST</code>,
    174 <code>WF_CPANEL_USER</code> and (temporarily) `WF_CPANEL_API_TOKEN`.
     176<code>WF_CPANEL_USER</code> and (temporarily)
    175177
    176178= Does it work without being on cPanel®? =
     
    205207== Changelog ==
    206208
     209
     210
     211
     212
     213
     214
     215
     216
     217
    207218= 5.3 =
    208219
    209220- May 14, 2024
    210 - Add resource usage dashboard widget with 3 graphical gauge charts
     221- Add resource usage dashboard widget with 3 grapical gauge charts
    211222
    212223= 5.2.9 =
    213224
    214225- May 12, 2024
    215 - Fix fatal error: Uncaught TypeError in `UAPI-php`.
     226- Fix fatal error: Uncaught TypeError in .
    216227
    217228= 5.2.7 =
     
    222233
    223234- Nov 14, 2023
    224 - Fix fatal error: Uncaught TypeError in `UAPI-php`.
    225 - Fix warning: Attempt to read property "type" on null in `UAPI.php`.
     235- Fix fatal error: Uncaught TypeError in .
     236- Fix warning: Attempt to read property "type" on null in .
    226237
    227238= 5.2.5 =
Note: See TracChangeset for help on using the changeset viewer.