jasteele123

concrete5 tools/check-tables.php

Nov 20th, 2012
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.91 KB | None | 0 0
  1. <?php /* tools/check-tables.php */
  2. defined('C5_EXECUTE') or die(_('Access Denied'));
  3. $u = new User();
  4. if(!$u->isSuperUser()) { die(_('Access Denied.')); }    // cheap security
  5.  
  6. $db = Loader::db();     // load helper for database
  7.  
  8. $outp = '<h3>Optimize</h3>';
  9. $tables = array();
  10. $r = $db->query('SHOW TABLES FROM '. DB_DATABASE);
  11. while ($row = $r->fetchRow()) {
  12.     $tables[] = $row['Tables_in_'. DB_DATABASE];
  13. }
  14. sort($tables);
  15. foreach($tables as $table) {
  16.     $r = $db->query('CHECK TABLE '. $table);
  17.     $row = $r->fetchRow();
  18.     $outp .= $table. ': '. $row['Msg_text']. '<br />';
  19. }
  20. echo $outp;
  21.  
  22. if(isset($_GET['show'])) {
  23.     if($r = $db->query("SHOW VARIABLES LIKE '%timeout%'"))
  24.         while ($row = $r->fetchRow())
  25.             echo '<br />'. $row['Variable_name']. ': '. $row['Value'];
  26.     if($r = $db->query("SHOW STATUS LIKE '%slow%'"))
  27.         while ($row = $r->fetchRow())
  28.             echo '<br />'. $row['Variable_name']. ': '. $row['Value'];
  29. }
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment