1
1
<?php
2
2
/*
3
- Version 1.1
3
+ Version 1.2
4
4
Copyright 2012-2015 - Amaury Balmer ([email protected] )
5
5
6
6
This program is free software; you can redistribute it and/or modify
@@ -44,7 +44,7 @@ function phpwpinfo() {
44
44
class PHP_WP_Info {
45
45
private $ debug_mode = true ;
46
46
private $ php_version = '5.2.4 ' ;
47
- private $ mysql_version = '5.0 ' ;
47
+ private $ mysqli_version = '5.0 ' ;
48
48
49
49
private $ db_infos = array ();
50
50
private $ db_link = null ;
@@ -87,7 +87,7 @@ public function init_all_tests() {
87
87
$ this ->test_versions ();
88
88
$ this ->test_php_config ();
89
89
$ this ->test_php_extensions ();
90
- $ this ->test_mysql_config ();
90
+ $ this ->test_mysqli_config ();
91
91
$ this ->test_apache_modules ();
92
92
$ this ->test_form_mail ();
93
93
@@ -120,26 +120,26 @@ public function test_versions() {
120
120
}
121
121
122
122
// Test MYSQL Client extensions/version
123
- if ( ! extension_loaded ( 'mysql ' ) || ! is_callable ( 'mysql_connect ' ) ) {
124
- $ this ->html_table_row ( 'PHP MySQL Extension ' , 'Yes ' , 'Yes ' , 'Not installed ' , 'error ' );
123
+ if ( ! extension_loaded ( 'mysqli ' ) || ! is_callable ( 'mysqli_connect ' ) ) {
124
+ $ this ->html_table_row ( 'PHP MySQLi Extension ' , 'Yes ' , 'Yes ' , 'Not installed ' , 'error ' );
125
125
} else {
126
- $ this ->html_table_row ( 'PHP MySQL Extension ' , 'Yes ' , 'Yes ' , 'Installed ' , 'success ' );
127
- $ this ->html_table_row ( 'PHP MySQL Client Version ' , $ this ->mysql_version , '> 5.5 ' , mysql_get_client_info (), 'info ' );
126
+ $ this ->html_table_row ( 'PHP MySQLi Extension ' , 'Yes ' , 'Yes ' , 'Installed ' , 'success ' );
127
+ $ this ->html_table_row ( 'PHP MySQLi Client Version ' , $ this ->mysqli_version , '> 5.5 ' , mysqli_get_client_info (), 'info ' );
128
128
}
129
129
130
130
// Test MySQL Server Version
131
- if ( $ this ->db_link != false && is_callable ( 'mysql_get_server_info ' ) ) {
132
- $ mysql_version = preg_replace ( '/[^0-9.].*/ ' , '' , mysql_get_server_info ( $ this ->db_link ) );
133
- if ( version_compare ( $ mysql_version , $ this ->mysql_version , '>= ' ) ) {
134
- $ this ->html_table_row ( 'MySQL Version ' , $ this ->mysql_version , '> 5.5 ' , $ mysql_version , 'success ' );
131
+ if ( $ this ->db_link != false && is_callable ( 'mysqli_get_server_info ' ) ) {
132
+ $ mysqli_version = preg_replace ( '/[^0-9.].*/ ' , '' , mysqli_get_server_info ( $ this ->db_link ) );
133
+ if ( version_compare ( $ mysqli_version , $ this ->mysqli_version , '>= ' ) ) {
134
+ $ this ->html_table_row ( 'MySQL Version ' , $ this ->mysqli_version , '> 5.5 ' , $ mysqli_version , 'success ' );
135
135
} else {
136
- $ this ->html_table_row ( 'MySQL Version ' , $ this ->mysql_version , '> 5.5 ' , $ mysql_version , 'error ' );
136
+ $ this ->html_table_row ( 'MySQL Version ' , $ this ->mysqli_version , '> 5.5 ' , $ mysqli_version , 'error ' );
137
137
}
138
138
} else {
139
139
// Show MySQL Form
140
140
$ this ->html_form_mysql ( ( $ this ->db_infos === false ) ? true : false );
141
141
142
- $ this ->html_table_row ( 'MySQL Version ' , $ this ->mysql_version , '- ' , 'Not available, needs credentials. ' , 'warning ' );
142
+ $ this ->html_table_row ( 'MySQL Version ' , $ this ->mysqli_version , '- ' , 'Not available, needs credentials. ' , 'warning ' );
143
143
}
144
144
145
145
$ this ->html_table_close ();
@@ -410,16 +410,16 @@ public function test_php_config() {
410
410
/**
411
411
* @return bool
412
412
*/
413
- public function test_mysql_config () {
413
+ public function test_mysqli_config () {
414
414
if ( $ this ->db_link == false ) {
415
415
return false ;
416
416
}
417
417
418
418
$ this ->html_table_open ( 'MySQL Configuration ' , '' , 'Required ' , 'Recommended ' , 'Current ' );
419
419
420
- $ result = mysql_query ( "SHOW VARIABLES LIKE 'have_query_cache' " , $ this ->db_link );
420
+ $ result = mysqli_query ( "SHOW VARIABLES LIKE 'have_query_cache' " , $ this ->db_link );
421
421
if ( $ result != false ) {
422
- while ( $ row = mysql_fetch_assoc ( $ result ) ) {
422
+ while ( $ row = mysqli_fetch_assoc ( $ result ) ) {
423
423
if ( strtolower ( $ row ['Value ' ] ) == 'yes ' ) {
424
424
$ this ->html_table_row ( "Query cache " , 'Yes* ' , 'Yes ' , 'Yes ' , 'success ' );
425
425
} else {
@@ -428,9 +428,9 @@ public function test_mysql_config() {
428
428
}
429
429
}
430
430
431
- $ result = mysql_query ( "SHOW VARIABLES LIKE 'query_cache_size' " , $ this ->db_link );
431
+ $ result = mysqli_query ( "SHOW VARIABLES LIKE 'query_cache_size' " , $ this ->db_link );
432
432
if ( $ result != false ) {
433
- while ( $ row = mysql_fetch_assoc ( $ result ) ) {
433
+ while ( $ row = mysqli_fetch_assoc ( $ result ) ) {
434
434
if ( intval ( $ row ['Value ' ] ) >= 8388608 ) { // 8mb
435
435
$ status = (intval ( $ row ['Value ' ] ) >= (8388608 * 8 )) ? 'success ' : 'warning ' ; // 64mb
436
436
$ this ->html_table_row ( "Query cache size " , '8M ' , '64MB ' , $ this ->_format_bytes ( (int ) $ row ['Value ' ] ), $ status );
@@ -440,9 +440,9 @@ public function test_mysql_config() {
440
440
}
441
441
}
442
442
443
- $ result = mysql_query ( "SHOW VARIABLES LIKE 'query_cache_type' " , $ this ->db_link );
443
+ $ result = mysqli_query ( "SHOW VARIABLES LIKE 'query_cache_type' " , $ this ->db_link );
444
444
if ( $ result != false ) {
445
- while ( $ row = mysql_fetch_assoc ( $ result ) ) {
445
+ while ( $ row = mysqli_fetch_assoc ( $ result ) ) {
446
446
if ( strtolower ( $ row ['Value ' ] ) == 'on ' || strtolower ( $ row ['Value ' ] ) == '1 ' ) {
447
447
$ this ->html_table_row ( "Query cache type " , '1 or on ' , '1 or on ' , strtolower ( $ row ['Value ' ] ), 'success ' );
448
448
} else {
@@ -451,9 +451,9 @@ public function test_mysql_config() {
451
451
}
452
452
}
453
453
454
- $ result = mysql_query ( "SHOW VARIABLES LIKE 'log_slow_queries' " , $ this ->db_link );
454
+ $ result = mysqli_query ( "SHOW VARIABLES LIKE 'log_slow_queries' " , $ this ->db_link );
455
455
if ( $ result != false ) {
456
- while ( $ row = mysql_fetch_assoc ( $ result ) ) {
456
+ while ( $ row = mysqli_fetch_assoc ( $ result ) ) {
457
457
if ( strtolower ( $ row ['Value ' ] ) == 'yes ' || strtolower ( $ row ['Value ' ] ) == 'on ' ) {
458
458
$ is_log_slow_queries = true ;
459
459
$ this ->html_table_row ( "Log slow queries " , 'No ' , 'Yes ' , 'Yes ' , 'success ' );
@@ -464,9 +464,9 @@ public function test_mysql_config() {
464
464
}
465
465
}
466
466
467
- $ result = mysql_query ( "SHOW VARIABLES LIKE 'long_query_time' " , $ this ->db_link );
467
+ $ result = mysqli_query ( "SHOW VARIABLES LIKE 'long_query_time' " , $ this ->db_link );
468
468
if ( $ is_log_slow_queries == true && $ result != false ) {
469
- while ( $ row = mysql_fetch_assoc ( $ result ) ) {
469
+ while ( $ row = mysqli_fetch_assoc ( $ result ) ) {
470
470
if ( intval ( $ row ['Value ' ] ) <= 2 ) {
471
471
$ this ->html_table_row ( "Long query time (sec) " , '2 ' , '1 ' , ( (int ) $ row ['Value ' ] ), 'success ' );
472
472
} else {
@@ -914,8 +914,8 @@ private function _check_request_mysql() {
914
914
}
915
915
916
916
// Check credentials
917
- if ( ! empty ( $ this ->db_infos ) && is_array ( $ this ->db_infos ) && is_callable ( 'mysql_connect ' ) ) {
918
- $ this ->db_link = mysql_connect ( $ this ->db_infos ['host ' ], $ this ->db_infos ['user ' ], $ this ->db_infos ['password ' ] );
917
+ if ( ! empty ( $ this ->db_infos ) && is_array ( $ this ->db_infos ) && is_callable ( 'mysqli_connect ' ) ) {
918
+ $ this ->db_link = mysqli_connect ( $ this ->db_infos ['host ' ], $ this ->db_infos ['user ' ], $ this ->db_infos ['password ' ] );
919
919
if ( $ this ->db_link == false ) {
920
920
unset( $ _SESSION ['credentials ' ] );
921
921
$ this ->db_infos = false ;
@@ -924,19 +924,19 @@ private function _check_request_mysql() {
924
924
925
925
// Check GET for MYSQL variables
926
926
if ( $ this ->db_link != false && isset ( $ _GET ) && isset ( $ _GET ['mysql-variables ' ] ) && $ _GET ['mysql-variables ' ] == 'true ' ) {
927
- $ result = mysql_query ( 'SHOW VARIABLES ' );
927
+ $ result = mysqli_query ( 'SHOW VARIABLES ' );
928
928
if ( ! $ result ) {
929
- echo "Could not successfully run query ( 'SHOW VARIABLES' ) from DB: " . mysql_error ();
929
+ echo "Could not successfully run query ( 'SHOW VARIABLES' ) from DB: " . mysqli_error ();
930
930
exit ();
931
931
}
932
932
933
- if ( mysql_num_rows ( $ result ) == 0 ) {
933
+ if ( mysqli_num_rows ( $ result ) == 0 ) {
934
934
echo "No rows found, nothing to print so am exiting " ;
935
935
exit ();
936
936
}
937
937
938
938
$ output = array ();
939
- while ( $ row = mysql_fetch_assoc ( $ result ) ) {
939
+ while ( $ row = mysqli_fetch_assoc ( $ result ) ) {
940
940
$ output [ $ row ['Variable_name ' ] ] = $ row ['Value ' ];
941
941
}
942
942
$ this ->get_header ();
0 commit comments