Skip to content

Commit

Permalink
Work in progress.
Browse files Browse the repository at this point in the history
  • Loading branch information
dev4press committed Feb 3, 2023
1 parent 325e54c commit a91b495
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 14 deletions.
29 changes: 29 additions & 0 deletions core/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,35 @@ function debugpress_format_size( $size, int $decimal = 2, string $sep = ' ' ) :
return round( $size, $decimal ) . $sep . $units[ $pow ];
}

/**
* Check if specified file exist even in the include paths.
*
* @param string $file file name to find
*
* @return bool true if the file is found in current path or include path.
*/
function debugpress_file_exists( $file ) : bool {
if ( function_exists( 'stream_resolve_include_path' ) ) {
return ! ( stream_resolve_include_path( $file ) === false );
} else {
$paths = get_include_path();

if ( $paths === false ) {
return false;
}

$paths = explode( PATH_SEPARATOR, $paths );

foreach ( $paths as $path ) {
if ( file_exists( $path . DIRECTORY_SEPARATOR . $file ) ) {
return true;
}
}

return false;
}
}

/**
* Extract part of the string from the left, based on the position of the other string.
*
Expand Down
34 changes: 28 additions & 6 deletions core/main/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,23 +421,45 @@ public static function php_apc() : string {
}

public static function php_pear() : string {
try {
@include_once( 'System.php' );
$file = 'System.php';

if ( class_exists( '\System' ) === true ) {
return __( "loaded", "debugpress" );
if ( debugpress_file_exists( $file ) ) {
try {
@include_once( $file );

if ( class_exists( '\System' ) === true ) {
return __( "loaded", "debugpress" );
}
} catch ( Exception $exception ) {
}
} catch ( Exception $exception ) {
}

return '<strong style="color: #cc0000;">' . __( "not loaded", "debugpress" ) . '</strong>';
}

public static function php_include_path() : string {
$path = get_include_path();

return $path === false ? '' : $path;
}

public static function php_loaded_extensions( bool $zend = false ) : array {
return get_loaded_extensions( $zend );
}

public static function php_extension( $name ) : string {
if ( extension_loaded( $name ) ) {
return __( "OK", "debugpress" );
} else {
return '<strong style="color: #cc0000;">' . __( "not available", "debugpress" ) . '</strong>';
}
}

public static function php_function( $name ) : string {
if ( function_exists( $name ) ) {
return __( "OK", "debugpress" );
} else {
return '<strong style="color: #cc0000;">' . __( "not available", "debugpress" ) . '</strong>';
}
}
}
}
45 changes: 40 additions & 5 deletions core/panel/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
exit;
}

use Dev4Press\Plugin\DebugPress\Main\DB;
use Dev4Press\Plugin\DebugPress\Main\Info;
use Dev4Press\Plugin\DebugPress\Main\Panel;

Expand Down Expand Up @@ -37,6 +38,15 @@ public function left() {
$this->table_init_standard();
$this->table_head();
$this->table_row( array( __( "Version", "debugpress" ), Info::mysql_version() ) );
$this->table_row( array( __( "Charset", "debugpress" ), DB::instance()->wpdb()->charset ) );
$this->table_row( array( __( "Collation", "debugpress" ), DB::instance()->wpdb()->collate ) );
$this->table_foot();
$this->block_footer();

$this->title( __( "mySQL Connection", "debugpress" ) );
$this->block_header();
$this->table_init_standard();
$this->table_head();
$this->table_row( array( __( "Host", "debugpress" ), DB_HOST ) );
$this->table_row( array( __( "Database", "debugpress" ), DB_NAME ) );
$this->table_row( array( __( "User", "debugpress" ), DB_USER ) );
Expand All @@ -60,7 +70,8 @@ public function right() {
$this->table_row( array( __( "Max POST Size", "debugpress" ), Info::php_post_size() ) );
$this->table_row( array( __( "Max Upload Size", "debugpress" ), Info::php_upload_size() ) );
$this->table_row( array( __( "Max Execution Time", "debugpress" ), Info::php_execution_time() ) );
$this->table_row( array( __( "Allow URL fopen", "debugpress" ), Info::php_allow_url_fopen() ) );
$this->table_row( array( __( "Allow URL `fopen`", "debugpress" ), Info::php_allow_url_fopen() ) );
$this->table_row( array( __( "Include path", "debugpress" ), Info::php_include_path() ) );
$this->table_foot();
$this->block_footer();

Expand All @@ -78,18 +89,42 @@ public function right() {
$this->table_foot();
$this->block_footer();

$this->title( __( "PHP Extensions", "debugpress" ) );
$this->title( __( "PHP Important Extensions", "debugpress" ) );
$this->block_header();
$this->table_init_standard();
$this->table_head();
$this->table_row( array( 'Zend OPCache', Info::php_opcache() ) );
$this->table_row( array( 'PDO', Info::php_pdo() ) );
$this->table_row( array( 'zLib', Info::php_zlib() ) );
$this->table_row( array( 'cURL', Info::php_curl() ) );
$this->table_row( array( 'GD', Info::php_gd() ) );
$this->table_row( array( 'APC', Info::php_apc() ) );
$this->table_row( array( 'PEAR', Info::php_pear() ) );
$this->table_foot();
$this->block_footer();

$this->title( __( "PHP Cache Extensions", "debugpress" ) );
$this->block_header();
$this->table_init_standard();
$this->table_head();
$this->table_row( array( 'Zend OPCache', Info::php_opcache() ) );
$this->table_row( array( 'APC', Info::php_apc() ) );
$this->table_row( array( 'Memcache', Info::php_extension( 'memcache' ) ) );
$this->table_row( array( 'Memcached', Info::php_extension( 'memcached' ) ) );
$this->table_foot();
$this->block_footer();

$this->title( __( "PHP Loaded Extensions", "debugpress" ) );
$this->block_header();
$this->table_init_standard();
$this->table_head();
$this->table_row( array(
__( "Standard", "debugpress" ),
debugpress_rx( Info::php_loaded_extensions(), false )
) );
$this->table_row( array(
__( "ZEND", "debugpress" ),
debugpress_rx( Info::php_loaded_extensions( true ), false )
) );
$this->table_foot();
$this->block_footer();
}
}
}
2 changes: 1 addition & 1 deletion debugpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@
require_once( DEBUGPRESS_PLUGIN_PATH . 'core/admin.php' );

debugpress_admin();
}
}
12 changes: 10 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,15 @@ If you have enabled debugger (for admin side and/or frontend), Debugger is activ
To enable WordPress debug mode via `wp-config.php`, check out the article here: [WordPress Setup](https://debug.press/documentation/wordpress-setup/).

== Changelog ==
= 2.2 (2023.02.01) =
* New: Updated some system requirements
= 2.2 (2023.02.03) =
* New: Updated some plugin system requirements
* New: Server panel shows PHP Include Path value
* New: Server panel shows Memcache/Memcached status
* New: Server panel shows all loaded extensions
* New: Server panel shows expanded MySQL information
* Edit: Various improvements to some panels display conditions
* Fix: Several more issues related to changes in PHP 8.1 and 8.2
* Fix: Issue with detection of the PEAR System.php file

= 2.1 (2022.12.30) =
* New: Tested with PHP 8.2 and WordPress 6.1
Expand Down Expand Up @@ -244,6 +249,9 @@ To enable WordPress debug mode via `wp-config.php`, check out the article here:
* First official release

== Upgrade Notice ==
= 2.2 =
Various updates, improvements and fixes.

= 2.1 =
Various updates and improvements. Updated Kint Library.

Expand Down

0 comments on commit a91b495

Please sign in to comment.