Plugin Directory

Changeset 2020051


Ignore:
Timestamp:
01/27/2019 09:56:28 PM (7 years ago)
Author:
bledileka
Message:

Upgrading queries to the latest WordPress version 5.0.3

Location:
dboptimizer/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • dboptimizer/trunk/WP_DB-admin.php

    r302344 r2020051  
    11<?php
     2global $wpdb;
    23if (isset($_POST['button4'])) {
    3 echo "<br />
    4 <strong>Optimizing :</strong><br />";
    5 $alltables = mysql_query("SHOW TABLES");
     4echo "<br /><strong>Optimizing tables:</strong><br /><hr>";
     5$alltables = $wpdb->get_results("SHOW TABLE STATUS");
    66ob_start();
    7 while ($table = mysql_fetch_assoc($alltables))
     7foreach ($alltables as $id=>$table)
    88{
    9    foreach ($table as $db => $tablename)
    10    {
    11        ob_flush();
    12        echo "Optimizing table : ".$tablename;
    13        $qry = ("OPTIMIZE TABLE $tablename");
    14        $rez = mysql_query($qry);
    15        if ($rez) { echo " - OK <br />"; } else { echo " - Error in optimizing this table !<br />";}
    16        ob_flush();
    17         flush();
    18         usleep(500000);
    19    }
     9     ob_flush();
     10       echo "Optimizing table : ".$table->Name;
     11       $qry = ("OPTIMIZE TABLE ".$table->Name);
     12       $rez = $wpdb->query($qry);
     13      if ($rez==1) { echo " - OK <br />"; } else { echo " - Error in optimizing this table !<br />";}
     14      ob_flush();
     15    flush();
     16        usleep(1000);
    2017}
    21 echo "<br />
    22 <br />
    23 Optimization process finished. <a href=\"?page=DBOptimizer\"> Return </a> to Database optimizer.<br />
    24 ";
    25 
    26 
     18echo "<br /><br />
     19Table optimization process finished. <a href=\"?page=DBOptimizer\"> Return </a> to Database optimizer.<br />";
     20} else {
     21  if (isset($_POST['button5'])) {
     22    echo "<br /><br />
     23    <strong>Reparing tables:</strong><br /><hr>";
     24    $alltables = $wpdb->get_results("SHOW TABLE STATUS");
     25    ob_start();
     26    foreach ($alltables as $id=>$table)
     27    {
     28         ob_flush();
     29         echo "Reparing table : ".$table->Name;
     30         $qry = ("REPAIR TABLE ".$table->Name);
     31         $rez = $wpdb->query($qry);
     32         print_r($rez);
     33        if ($rez==1) { echo " - OK <br />"; } else { echo " - Error encountered while repairing this table !<br />";}
     34        ob_flush();
     35        flush();
     36        usleep(1000);
     37    }
     38    echo "<br />
     39    <br />
     40    Table reparing process finished. <a href=\"?page=DBOptimizer\"> Return </a> to Database optimizer.<br />
     41    ";
    2742} else {
    2843?>
    2944<form id="form3" name="form3" method="post" action="">
    30   <br />
    31   Database name : <?=DB_NAME?>
    32   <input type="submit" name="button4" id="button4" value="Optimize Now !" />
     45  <br />Database name : <?=DB_NAME?><hr>
     46  <input type="submit" class="button" name="button4" id="button4" value="Optimize Now !" />
     47  <input type="submit" class="button" name="button5" id="button5" value="Repair Tables" />
    3348</form>
    3449<br />
    35 <table width="100%" class="widefat fixed">
    36 
     50<table width="100%" class="wp-list-table widefat fixed striped posts">
    3751  <thead>
    38 
    3952    <tr>
    40 
    4153      <th width="15%" scope="col">Table Name</th>
    42 
    4354      <th width="16%" scope="col">Table Size</th>
    44 
    45 
    4655      <th width="16%" scope="col">Table Rows</th>
    4756    </tr>
    4857  </thead>
    49 
    5058  <tbody>
    5159<?php
    5260$tables = array();
    53  
    54 $result = mysql_query("SHOW TABLE STATUS");
    55  $tot=0;
    56  $rs =0;
    57  $nrs=0;
    58 while($row = mysql_fetch_array($result)) {
    59     /* We return the size in Kilobytes */
    60     $total_size = ($row[ "Data_length" ] +  $row[ "Index_length" ]) / 1024;
    61     //$tables[$row['Name']] = sprintf("%.2f", $total_size);
    62     $rs++;
    63     $tbl = $row['Name'];
    64     $tot = $tot + $total_size;
    65     ?>
    66        <tr>
    67 
    68       <td> <?=$tbl?></td>
    69 
    70       <td> <?=$total_size?> Kb. (<?php echo number_format($total_size/1024,'2','.','');?>) Mb.</td>
    71 
    72       <td><?php
    73       $q=("select * from $tbl");$rez=mysql_query($q);echo $rowss=mysql_num_rows($rez);$nrs=$nrs+$rowss;
    74       ?> Rows</td>
     61$result = $wpdb->get_results("SHOW TABLE STATUS");
     62$tot=0;
     63$rs =0;
     64$nrs=0;
     65foreach($result as $id=>$row) {
     66    $total_size = ($row->Data_length +  $row->Index_length) / 1024;
     67    $rs++;
     68    $tbl = $row->Name;
     69    $tot = $tot + $total_size;
     70?>
     71    <tr>
     72      <td><?=$tbl?></td>
     73      <td><?=$total_size?> Kb. (<?php echo number_format($total_size/1024,'2','.','');?>) Mb.</td>
     74      <td>
     75      <?php
     76        $rowss = $wpdb->get_var( "SELECT COUNT(*) FROM $tbl" );
     77        echo $rowss;
     78        $nrs=$nrs+$rowss;
     79        ?> Rows
     80      </td>
    7581    </tr>
    76        <?php }?>
    77        <tr>
    78          <td>Total : <?=$rs?> Tables</td>
    79          <td>Total : <?=$tot?> Kb (<?php echo number_format($tot/1024,'2','.','');?>) Mb.</td>
    80          <td>Total : <?=$nrs?> Rows</td>
    81        </tr>
    82 
     82    <?php }?>
     83    <tr>
     84      <td>Total : <?=$rs?> Tables</td>
     85      <td>Total : <?=$tot?> Kb (<?php echo number_format($tot/1024,'2','.','');?>) Mb.</td>
     86      <td>Total : <?=$nrs?> Rows</td>
     87    </tr>
    8388  </tbody>
    8489</table>
    85 <?php }?>
     90<?php }
     91}?>
  • dboptimizer/trunk/db_optimizer.php

    r302344 r2020051  
    22/**
    33 * @package Database Optimizer
    4  * @version 1.0.0
     4 * @version 2.0.0
    55 */
    66/*
    77Plugin Name: Database Optimizer
    88Plugin URI: http://wordpress.org/#
    9 Description: Database optimization for Wordpress
     9Description: Database optimization and repairing for Wordpress
    1010Author: Bledar Leka
    11 Version: 1.0.0
    12 Author URI: http://www.pikaweb.com/
     11Version: 2.0.0
     12Author URI: http://bweb.solution/
    1313*/
    1414
    1515function DTB_menu()
    1616{
    17 echo "<br />
    18 <br />
    19 Database optimization Tool for Wordpress";     
     17echo "<br /><h1 class=\"wp-heading-inline\">DBOptimizer</h1>
     18<hr>
     19Database optimization and repairing Tool for WordPress";       
    2020include('WP_DB-admin.php');
    2121}
  • dboptimizer/trunk/readme.txt

    r302344 r2020051  
    11=== DBOptimizer ===
    22Contributors: bledileka
    3 Donate link: http://www.pikaweb.com/
    4 Tags: database, optimize
    5 Requires at least: 2.0.2
    6 Tested up to: 3.0.1
    7 Stable tag: 1.0
     3Donate link: http://bweb.solutions/
     4Tags: database, optimize, repair
     5Requires at least: 5.0.0
     6Tested up to: 5.0.3
     7Stable tag: 2.0
    88
    9 This plugin is just a simple tool that may be useful to keep your wordpress databases optimized.
     9This plugin is just a simple tool that may be useful to keep your wordpress databases optimized. You can also try to repair tables.
    1010
    1111== Description ==
     
    17171. Upload `db-optimizer` to the `/wp-content/plugins/` directory
    18182. Activate the plugin through the 'Plugins' menu in WordPress
    19 3. Just open the DBOptimizer page from your left side menu and optimize your db :)
     193. Just open the DBOptimizer page from your left side menu and optimize your db.
    2020
    2121== Frequently Asked Questions ==
Note: See TracChangeset for help on using the changeset viewer.