home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Plugins / wp-dbmanager / dbmanager / database-repair.php < prev    next >
PHP Script  |  2008-02-19  |  3KB  |  87 lines

  1. <?php
  2. /*
  3. +----------------------------------------------------------------+
  4. |                                                                                            |
  5. |    WordPress 2.1 Plugin: WP-DBManager 2.20                                |
  6. |    Copyright (c) 2007 Lester "GaMerZ" Chan                                    |
  7. |                                                                                            |
  8. |    File Written By:                                                                    |
  9. |    - Lester "GaMerZ" Chan                                                            |
  10. |    - http://lesterchan.net                                                            |
  11. |                                                                                            |
  12. |    File Information:                                                                    |
  13. |    - Database Repair                                                                     |
  14. |    - wp-content/plugins/dbmanager/database-repair.php                     |
  15. |                                                                                            |
  16. +----------------------------------------------------------------+
  17. */
  18.  
  19.  
  20. ### Check Whether User Can Manage Database
  21. if(!current_user_can('manage_database')) {
  22.     die('Access Denied');
  23. }
  24.  
  25.  
  26. ### Variables Variables Variables
  27. $base_name = plugin_basename('dbmanager/database-manager.php');
  28. $base_page = 'admin.php?page='.$base_name;
  29.  
  30. ### Form Processing 
  31. if($_POST['do']) {
  32.     // Lets Prepare The Variables
  33.     $repair = $_POST['repair'];
  34.  
  35.     // Decide What To Do
  36.     switch($_POST['do']) {
  37.         case 'Repair':
  38.             if(!empty($repair)) {
  39.                 foreach($repair as $key => $value) {
  40.                     if($value == 'yes') {
  41.                         $tables_string .=  ', '.$key;
  42.                     }
  43.                 }
  44.             } else {
  45.                 $text = '<font color="red">'.__('No Tables Selected', 'wp-dbmanager').'</font>';
  46.             }
  47.             $selected_tables = substr($tables_string, 2);
  48.             if(!empty($selected_tables)) {
  49.                 $repair2 = $wpdb->query("REPAIR TABLE $selected_tables");
  50.                 $text = '<font color="green">'.sprintf(__('Table(s) \'%s\' Repaired', 'wp-dbmanager'), $selected_tables).'</font>';
  51.             }
  52.             break;
  53.     }
  54. }
  55.  
  56.  
  57. ### Show Tables
  58. $tables = $wpdb->get_col("SHOW TABLES");
  59. ?>
  60. <?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; } ?>
  61. <!-- Repair Database -->
  62. <div class="wrap">
  63.     <h2><?php _e('Repair Database', 'wp-dbmanager'); ?></h2>
  64.     <form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
  65.         <table width="100%" cellspacing="3" cellpadding="3" border="0">
  66.             <tr class="thead">
  67.                 <th align="left"><?php _e('Tables', 'wp-dbmanager'); ?></th>
  68.                 <th align="left"><?php _e('Options', 'wp-dbmanager'); ?></th>
  69.             </tr>
  70.                 <?php
  71.                     foreach($tables as $table_name) {
  72.                         if($no%2 == 0) {
  73.                             $style = 'style=\'background: none\'';                            
  74.                         } else {
  75.                             $style = 'style=\'background-color: #eee;\'';
  76.                         }
  77.                         $no++;
  78.                         echo "<tr $style><th align=\"left\" scope=\"row\">$table_name</th>\n";
  79.                         echo "<td><input type=\"radio\" name=\"repair[$table_name]\" value=\"no\" />".__('No', 'wp-dbmanager')."   <input type=\"radio\" name=\"repair[$table_name]\" value=\"yes\" checked=\"checked\" />".__('Yes', 'wp-dbmanager').'</td></tr>';
  80.                     }
  81.                 ?>
  82.             <tr>
  83.                 <td colspan="2" align="center"><input type="submit" name="do" value="<?php _e('Repair', 'wp-dbmanager'); ?>" class="button" />  <input type="button" name="cancel" value="<?php _e('Cancel', 'wp-dbmanager'); ?>" class="button" onclick="javascript:history.go(-1)" /></td>
  84.             </tr>
  85.         </table>
  86.     </form>
  87. </div>