Skip to content

Commit 76ccd1f

Browse files
committed
Use MySQLi
1 parent ca25bcb commit 76ccd1f

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

phpwpinfo.php

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
Version 1.1
3+
Version 1.2
44
Copyright 2012-2015 - Amaury Balmer ([email protected])
55
66
This program is free software; you can redistribute it and/or modify
@@ -44,7 +44,7 @@ function phpwpinfo() {
4444
class PHP_WP_Info {
4545
private $debug_mode = true;
4646
private $php_version = '5.2.4';
47-
private $mysql_version = '5.0';
47+
private $mysqli_version = '5.0';
4848

4949
private $db_infos = array();
5050
private $db_link = null;
@@ -87,7 +87,7 @@ public function init_all_tests() {
8787
$this->test_versions();
8888
$this->test_php_config();
8989
$this->test_php_extensions();
90-
$this->test_mysql_config();
90+
$this->test_mysqli_config();
9191
$this->test_apache_modules();
9292
$this->test_form_mail();
9393

@@ -120,26 +120,26 @@ public function test_versions() {
120120
}
121121

122122
// 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' );
125125
} 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' );
128128
}
129129

130130
// 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' );
135135
} 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' );
137137
}
138138
} else {
139139
// Show MySQL Form
140140
$this->html_form_mysql( ( $this->db_infos === false ) ? true : false );
141141

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' );
143143
}
144144

145145
$this->html_table_close();
@@ -410,16 +410,16 @@ public function test_php_config() {
410410
/**
411411
* @return bool
412412
*/
413-
public function test_mysql_config() {
413+
public function test_mysqli_config() {
414414
if ( $this->db_link == false ) {
415415
return false;
416416
}
417417

418418
$this->html_table_open( 'MySQL Configuration', '', 'Required', 'Recommended', 'Current' );
419419

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 );
421421
if ( $result != false ) {
422-
while ( $row = mysql_fetch_assoc( $result ) ) {
422+
while ( $row = mysqli_fetch_assoc( $result ) ) {
423423
if ( strtolower( $row['Value'] ) == 'yes' ) {
424424
$this->html_table_row( "Query cache", 'Yes*', 'Yes', 'Yes', 'success' );
425425
} else {
@@ -428,9 +428,9 @@ public function test_mysql_config() {
428428
}
429429
}
430430

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 );
432432
if ( $result != false ) {
433-
while ( $row = mysql_fetch_assoc( $result ) ) {
433+
while ( $row = mysqli_fetch_assoc( $result ) ) {
434434
if ( intval( $row['Value'] ) >= 8388608 ) { // 8mb
435435
$status = (intval( $row['Value'] ) >= (8388608 * 8)) ? 'success' : 'warning'; // 64mb
436436
$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() {
440440
}
441441
}
442442

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 );
444444
if ( $result != false ) {
445-
while ( $row = mysql_fetch_assoc( $result ) ) {
445+
while ( $row = mysqli_fetch_assoc( $result ) ) {
446446
if ( strtolower( $row['Value'] ) == 'on' || strtolower( $row['Value'] ) == '1' ) {
447447
$this->html_table_row( "Query cache type", '1 or on', '1 or on', strtolower( $row['Value'] ), 'success' );
448448
} else {
@@ -451,9 +451,9 @@ public function test_mysql_config() {
451451
}
452452
}
453453

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 );
455455
if ( $result != false ) {
456-
while ( $row = mysql_fetch_assoc( $result ) ) {
456+
while ( $row = mysqli_fetch_assoc( $result ) ) {
457457
if ( strtolower( $row['Value'] ) == 'yes' || strtolower( $row['Value'] ) == 'on' ) {
458458
$is_log_slow_queries = true;
459459
$this->html_table_row( "Log slow queries", 'No', 'Yes', 'Yes', 'success' );
@@ -464,9 +464,9 @@ public function test_mysql_config() {
464464
}
465465
}
466466

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 );
468468
if ( $is_log_slow_queries == true && $result != false ) {
469-
while ( $row = mysql_fetch_assoc( $result ) ) {
469+
while ( $row = mysqli_fetch_assoc( $result ) ) {
470470
if ( intval( $row['Value'] ) <= 2 ) {
471471
$this->html_table_row( "Long query time (sec)", '2', '1', ( (int) $row['Value'] ), 'success' );
472472
} else {
@@ -914,8 +914,8 @@ private function _check_request_mysql() {
914914
}
915915

916916
// 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'] );
919919
if ( $this->db_link == false ) {
920920
unset( $_SESSION['credentials'] );
921921
$this->db_infos = false;
@@ -924,19 +924,19 @@ private function _check_request_mysql() {
924924

925925
// Check GET for MYSQL variables
926926
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' );
928928
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();
930930
exit();
931931
}
932932

933-
if ( mysql_num_rows( $result ) == 0 ) {
933+
if ( mysqli_num_rows( $result ) == 0 ) {
934934
echo "No rows found, nothing to print so am exiting";
935935
exit();
936936
}
937937

938938
$output = array();
939-
while ( $row = mysql_fetch_assoc( $result ) ) {
939+
while ( $row = mysqli_fetch_assoc( $result ) ) {
940940
$output[ $row['Variable_name'] ] = $row['Value'];
941941
}
942942
$this->get_header();

0 commit comments

Comments
 (0)