Plugin Directory

Changeset 3202005


Ignore:
Timestamp:
12/03/2024 11:59:41 PM (15 months ago)
Author:
codecompiled
Message:

Updated database information displayed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-settings/trunk/wp-settings.php

    r3201989 r3202005  
    44Plugin URI: https://wordpress.org/plugins/wp-settings/
    55Description:Displays the important information about WordPress installation such as important wordpress settings,database settings,theme details and php information.You can generate DB Backup Script for restoring the database and for keeping database backups.
    6 Version: 2.2
     6Version: 2.3
    77Author: CodeCompiled
    88Author URI: http://www.codecompiled.com
     
    9191
    9292function wpsettings_getMySqlDetails() {
    93          global $wpdb;
    94          $results = $wpdb->get_results('select version() as mysqlversion');
    95          $sqlInfoVer;
    96           foreach( $results as $result ) {
    97             $sqlInfoVer= $result->mysqlversion;
    98     }
    99        $ws_mysqldetails=array();
    100        $ws_mysqldetails["VERSION"]= $sqlInfoVer;//DB_NAME;
    101        $ws_mysqldetails["DATABASE NAME"]=DB_NAME;
    102        $ws_mysqldetails["DATABASE USER NAME"]=DB_USER;
    103        $ws_mysqldetails["DATABASE HOST"]=DB_HOST;
    104        $ws_mysqldetails["DATABASE SIZE(MB)"] = $wpdb->get_var("SELECT sum( data_length + index_length ) / 1024 / 1024 'dbsize' FROM information_schema.TABLES WHERE table_schema ='".DB_NAME."'");
    105        $ws_mysqldetails["NO. OF TABLES"]= $wpdb->get_var("SELECT count(*) FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='".DB_NAME."'");
    106        return $ws_mysqldetails;
    107     }
     93    global $wpdb;
     94   
     95    // Query for MySQL version
     96    $results = $wpdb->get_results('SELECT VERSION() as mysqlversion');
     97    $sqlInfoVer = '';
     98    foreach ($results as $result) {
     99        $sqlInfoVer = $result->mysqlversion;
     100    }
     101
     102    // Table schema name (DB_NAME) for information_schema queries
     103    $tableSchema = DB_NAME;
     104
     105    // Fetching MySQL details
     106    $ws_mysqldetails = array();
     107    $ws_mysqldetails["VERSION"] = $sqlInfoVer;
     108    $ws_mysqldetails["DATABASE NAME"] = DB_NAME;
     109    $ws_mysqldetails["DATABASE USER NAME"] = DB_USER;
     110    $ws_mysqldetails["DATABASE HOST"] = DB_HOST;
     111    $ws_mysqldetails["DATABASE SIZE (MB)"] = $wpdb->get_var(
     112        $wpdb->prepare(
     113            "SELECT SUM(data_length + index_length) / 1024 / 1024 AS dbsize
     114             FROM information_schema.TABLES
     115             WHERE table_schema = %s",
     116            $tableSchema
     117        )
     118    );
     119    $ws_mysqldetails["NO. OF TABLES"] = $wpdb->get_var(
     120        $wpdb->prepare(
     121            "SELECT COUNT(*)
     122             FROM information_schema.TABLES
     123             WHERE table_schema = %s",
     124            $tableSchema
     125        )
     126    );
     127
     128    // Fetching table names
     129    $tableNames = $wpdb->get_col(
     130        $wpdb->prepare(
     131            "SELECT table_name
     132             FROM information_schema.TABLES
     133             WHERE table_schema = %s",
     134            $tableSchema
     135        )
     136    );
     137
     138    // Convert array to comma-separated values
     139    $ws_mysqldetails["TABLE NAMES"] = is_array($tableNames) ? implode(', ', $tableNames) : '';
     140
     141    return $ws_mysqldetails;
     142}
    108143function wpsettings_bloginfo_array() {
    109144    $fields = array('name', 'description', 'wpurl', 'url', 'admin_email', 'version','categories','pages','pingback_url', 'language');
Note: See TracChangeset for help on using the changeset viewer.