1) return round($rawSize/1048576, 1) . ' MB'; else if ($rawSize / 1024 > 1) return round($rawSize/1024, 1) . ' KB'; else return round($rawSize, 1) . ' bytes'; } ### Check Folder Whether There Is Any File Inside function is_emtpy_folder($folder){ if(is_dir($folder) ){ $handle = opendir($folder); while( (gettype( $name = readdir($handle)) != 'boolean')){ $name_array[] = $name; } foreach($name_array as $temp) $folder_content .= $temp; if($folder_content == '...') return true; else return false; closedir($handle); } else return true; // folder doesnt exist } ### Form Processing if($_POST['do']) { // Lets Prepare The Variables $database_file = trim($_POST['database_file']); $optimize = $_POST['optimize']; $delete = $_POST['delete']; $nice_file_date = date('l, jS F Y @ H:i', substr($database_file, 0, 10)); // Decide What To Do switch($_POST['do']) { case 'Backup': $gzip = intval($_POST['gzip']); if($gzip == 1) { $backup['filename'] = $backup['date'].'_-_'.DB_NAME.'.sql.gz'; $backup['filepath'] = $backup['path'].'/'.$backup['filename']; $backup['command'] = $backup['mysqldumppath'].' -h'.DB_HOST.' -u'.DB_USER.' -p'.DB_PASSWORD.' --add-drop-table '.DB_NAME.' | gzip > '.$backup['filepath']; } else { $backup['filename'] = $backup['date'].'_-_'.DB_NAME.'.sql'; $backup['filepath'] = $backup['path'].'/'.$backup['filename']; $backup['command'] = $backup['mysqldumppath'].' -h'.DB_HOST.' -u'.DB_USER.' -p'.DB_PASSWORD.' --add-drop-table '.DB_NAME.' > '.$backup['filepath']; } passthru($backup['command'], $error); if(!is_writable($backup['path'])) { $text = "Database Failed To Backup On '".date('l, jS F Y @ H:i')."'. Backup Folder Not Writable"; } elseif(filesize($backup['filepath']) == 0) { unlink($backup['filepath']); $text = "Database Failed To Backup On '".date('l, jS F Y @ H:i')."'. Backup File Size Is 0KB"; } elseif(!is_file($backup['filepath'])) { $text = "Database Failed To Backup On '".date('l, jS F Y @ H:i')."'. Invalid Backup File Path"; } elseif($error) { $text = "Database Failed To Backup On '".date('l, jS F Y @ H:i')."'"; } else { $text = "Database Backed Up Successfully On '".date('l, jS F Y @ H:i')."'"; } break; case 'Restore': if(!empty($database_file)) { if(stristr($database_file, '.gz')) { $backup['command'] = 'gunzip < '.$backup['path'].'/'.$database_file.' | '.$backup['mysqlpath'].' -h'.DB_HOST.' -u'.DB_USER.' -p'.DB_PASSWORD.' '.DB_NAME; } else { $backup['command'] = $backup['mysqlpath'].' -h'.DB_HOST.' -u'.DB_USER.' -p'.DB_PASSWORD.' '.DB_NAME.' < '.$backup['path'].'/'.$database_file; } passthru($backup['command'], $error); if($error) { $text = "Database On '$nice_file_date' Failed To Restore"; } else { $text = "Database On '$nice_file_date' Restored Successfully"; } } else { $text = 'No Backup Database File Selected'; } break; case 'Delete': if(!empty($delete)) { foreach($delete as $dbbackup) { $nice_file_date = date('l, jS F Y @ H:i', substr($dbbackup, 0, 10)); if(is_file($backup['path'].'/'.$dbbackup)) { if(!unlink($backup['path'].'/'.$dbbackup)) { $text .= "Unable To Delete Database Backup File On '$nice_file_date'
"; } else { $text .= "Database Backup File On '$nice_file_date' Deleted Successfully
"; } } else { $text = "Invalid Database Backup File On '$nice_file_date'"; } } } else { $text = 'No Backup Database File Selected'; } break; case 'Download': if(!empty($database_file)) { $file_path = $backup['path'].'/'.$database_file; $nice_file_name = date('jS_F_Y', substr($database_file, 0, 10)).'-'.substr($database_file, 13); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header("Content-Disposition: attachment; filename=".basename($nice_file_name).";"); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($file_path)); @readfile($file_path); } else { $text = 'No Backup Database File Selected'; } break; case 'Optimize': foreach($optimize as $key => $value) { if($value == 'yes') { $tables_string .= ', '.$key; } } $selected_tables = substr($tables_string, 2); if(!empty($selected_tables)) { $optimize2 = $wpdb->query("OPTIMIZE TABLE $selected_tables"); if(!$optimize2) { $text = "Table(s) '$selected_tables' Failed To Be Optimized"; } else { $text = "Table(s) '$selected_tables' Optimized Successfully"; } } else { $text = 'No Tables Selected'; } break; case 'Run': $sql_queries2 = trim($_POST['sql_query']); $totalquerycount = 0; $successquery = 0; if($sql_queries2) { $sql_queries = array(); $sql_queries2 = explode("\n", $sql_queries2); foreach($sql_queries2 as $sql_query2) { $sql_query2 = trim(stripslashes($sql_query2)); $sql_query2 = preg_replace("/[\r\n]+/", '', $sql_query2); if(!empty($sql_query2)) { $sql_queries[] = $sql_query2; } } if($sql_queries) { foreach($sql_queries as $sql_query) { if (preg_match("/^\\s*(insert|update|replace|delete|create) /i",$sql_query)) { $run_query = $wpdb->query($sql_query); if(!$run_query) { $text .= "$sql_query
"; } else { $successquery++; $text .= "$sql_query
"; } $totalquerycount++; } elseif (preg_match("/^\\s*(select|drop|show|grant) /i",$sql_query)) { $text .= "$sql_query
"; $totalquerycount++; } } $text .= "$successquery/$totalquerycount Query(s) Executed Successfully"; } else { $text = "Empty Query"; } } else { $text = "Empty Query"; } break; } } ### Switch $mode switch($mode) { // Backup Database case 'backup': $title = 'Backup Database'; $standalone = 0; require("./admin-header.php"); if ($user_level < 9) { die('

Insufficient Level

'); } $backup['filename'] = $backup['date'].'_-_'.DB_NAME.'.sql'; ?>

Backup Database

Database Name:
Database Backup To:
Database Backup Date:
Database Backup File Name: /
Database Backup Type: Full (Structure and Data)
MYSQL Dump Location
GZIP Database Backup File? Yes  No
  
Insufficient Level

'); } $tables = $wpdb->get_results("SHOW TABLES"); ?>

Optimize Database

Tables_in_'.DB_NAME; eval("\$table_name = \"$table_name\";"); echo "\n"; echo ""; } ?>
Tables Options
$table_nameNo  Yes
Database should be optimize once every month.
  
Insufficient Level

'); } ?>

Restore/Download Database

-1; $i--) { if($no%2 == 0) { $style = 'style=\'background-color: #eee\''; } else { $style = 'style=\'background-color: none\''; } $no++; $database_text = substr($database_files[$i], 13); $date_text = date('l, jS F Y @ H:i', substr($database_files[$i], 0, 10)); $size_text = filesize($backup['path'].'/'.$database_files[$i]); echo "\n"; echo ""; echo ""; echo ''; echo "\n\n"; $totalsize += $size_text; } } else { echo ''; } } else { echo ''; } ?>
Choose A Backup Date To Restore Or Download
No. Database File Date/Time Size Select
$no$database_text$date_text'.format_size($size_text).'
There Are No Database Backup Files Available
There Are No Database Backup Files Available
Backup File(s)  
    
Insufficient Level

'); } ?>

Delete Database Backup Files

-1; $i--) { if($no%2 == 0) { $style = 'style=\'background-color: #eee\''; } else { $style = 'style=\'background-color: none\''; } $no++; $database_text = substr($database_files[$i], 13); $date_text = date('l, jS F Y @ H:i', substr($database_files[$i], 0, 10)); $size_text = filesize($backup['path'].'/'.$database_files[$i]); echo "\n"; echo ""; echo ""; echo ''; echo "\n\n"; $totalsize += $size_text; } } else { echo ''; } } else { echo ''; } ?>
Choose Database Backup Files To Delete
No. Database File Date/Time Size Select
$no$database_text$date_text'.format_size($size_text).'
There Are No Database Backup Files Available
There Are No Database Backup Files Available
Backup File(s)  
  
Insufficient Level

'); } ?>

Run SQL Query

Seperate Multiple Queries With A New Line
Use Only INSERT, UPDATE, REPLACE, DELETE and CREATE statements.

  

1. CREATE statement will return an error, which is perfectly normal due to the database class. To confirm that your table has been created check the Manage Database page.
2. UPDATE statement may return an error sometimes due to the newly updated value being the same as the previous value.

Insufficient Level

'); } // Get MYSQL Version $sqlversion = $wpdb->get_var("SELECT VERSION() AS version"); ?>

Last Action

'.$text.'
'; } ?>

Database Information

Setting Value
Database Host
Database Name
Database User
Database Type MYSQL
Database Version v

Tables Information

= '3.23') { $tablesstatus = $wpdb->get_results("SHOW TABLE STATUS"); foreach($tablesstatus as $tablestatus) { if($no%2 == 0) { $style = 'style=\'background-color: #eee\''; } else { $style = 'style=\'background-color: none\''; } $no++; echo "\n\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; $row_usage += $tablestatus->Rows; $data_usage += $tablestatus->Data_length; $index_usage += $tablestatus->Index_length; $overhead_usage += $tablestatus->Data_free; } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo ""; echo ""; } else { echo ''; } ?>
No. Tables Records Data Usage Index Usage Overhead
$no$tablestatus->Name".number_format($tablestatus->Rows)."".format_size($tablestatus->Data_length)."".format_size($tablestatus->Index_length)."".format_size($tablestatus->Data_free)."
Total:$no Tables".number_format($row_usage)."".format_size($data_usage)."".format_size($index_usage)."".format_size($overhead_usage)."
Could Not Show Table Status Due To Your MYSQL Version Is Lower Than 3.23.