Added a backup utility and updated the language catalog. Fixed the minor bugs.

git-svn-id: https://plugins.svn.wordpress.org/sqlite-integration/trunk@766763 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
kjmtsh 2013-09-04 07:45:37 +00:00
parent 953f18e719
commit bae9e47e0e
10 changed files with 812 additions and 609 deletions

View File

@ -14,6 +14,9 @@ jQuery(document).ready(function($) {
} else if (document.getElementById("patch-files") != null) { } else if (document.getElementById("patch-files") != null) {
$table = $('#patch-files'); $table = $('#patch-files');
$headers = $table.find('thead th').slice(1); $headers = $table.find('thead th').slice(1);
} else if (document.getElementById("backup-files") != null) {
$table = $('#backup-files');
$headers = $table.find('thead th').slice(1);
} }
$headers $headers
.wrapInner('<a href="#"></a>') .wrapInner('<a href="#"></a>')

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -167,13 +167,15 @@ SQLite Integrationのアップグレードに失敗するようなら、FTPを
== Changelog == == Changelog ==
= 1.3 (2013-08-11) = = 1.3 (2013-09-04) =
* データベースファイルのスナップショットをzipアーカイブとしてバックアップするユーティリティを追加しました。
* ダッシュボードのスタイルをMP6プラグインに合わせたものに変えました。 * ダッシュボードのスタイルをMP6プラグインに合わせたものに変えました。
* 言語カタログが読み込まれていないときのエラーメッセージの出力方法を一部変更しました。 * 言語カタログが読み込まれていないときのエラーメッセージの出力方法を一部変更しました。
* query_create.class.phpの_rewrite_field_types()を変更しました。dbDelta()関数が意図したとおりに実行されます。 * query_create.class.phpの_rewrite_field_types()を変更しました。dbDelta()関数が意図したとおりに実行されます。
* BETWEENステートメントが使えるようになりました。 * BETWEENステートメントが使えるようになりました。
* クエリからインデックスヒントを全て削除して実行するようにしました。 * クエリからインデックスヒントを全て削除して実行するようにしました。
* New StatPressプラグインが使えるように、ALTER TABLE CHANGE COLUMNの扱いを修正しました。 * New StatPressプラグインが使えるように、ALTER TABLE CHANGE COLUMNの扱いを修正しました。
* いくつかの小さなバグを修正しました。
= 1.2.1 (2013-08-04) = = 1.2.1 (2013-08-04) =
* wp-db.phpの変更にともなって、wpdb::real_escapeプロパティを削除しました。WordPress 3.6 との互換性を保つための変更です。 * wp-db.phpの変更にともなって、wpdb::real_escapeプロパティを削除しました。WordPress 3.6 との互換性を保つための変更です。

View File

@ -158,13 +158,15 @@ When auto upgrading of SQLite Integration fails, please try manual upgrade via F
== Changelog == == Changelog ==
= 1.3 (2013-08-10) = = 1.3 (2013-09-04) =
* Added the backup utility that creates the zipped archive of the current snapshot of the database file.
* Changed the dashboard style to match MP6 plugin. * Changed the dashboard style to match MP6 plugin.
* Changed the way of putting out the error messages when language catalogs are not loaded. * Changed the way of putting out the error messages when language catalogs are not loaded.
* Modified the _rewrite_field_types() in query_create.class.php for the dbDelta() function to work properly. * Modified the _rewrite_field_types() in query_create.class.php for the dbDelta() function to work properly.
* Added the support for BETWEEN statement. * Added the support for BETWEEN statement.
* Changed the regular expression to remove all the index hints from the query string. * Changed the regular expression to remove all the index hints from the query string.
* Fixed the manipulation of ALTER TABLE CHANGE COLUMN query for NewStatPress plugin to work. * Fixed the manipulation of ALTER TABLE CHANGE COLUMN query for NewStatPress plugin to work.
* Fixed minor bugs.
= 1.2.1 (2013-08-04) = = 1.2.1 (2013-08-04) =
* Removed wpdb::real_escape property following the change of the wpdb.php file which makes the plugin compatible with Wordpress 3.6. * Removed wpdb::real_escape property following the change of the wpdb.php file which makes the plugin compatible with Wordpress 3.6.

View File

@ -168,6 +168,7 @@ class SQLiteIntegration {
add_action('admin_print_scripts-'.$util_page, array($this, 'add_sqlite_script')); add_action('admin_print_scripts-'.$util_page, array($this, 'add_sqlite_script'));
add_action('admin_print_scripts-'.$doc_page, array($this, 'add_sqlite_script')); add_action('admin_print_scripts-'.$doc_page, array($this, 'add_sqlite_script'));
add_action('admin_print_scripts-'.$patch_page, array($this, 'add_sqlite_script')); add_action('admin_print_scripts-'.$patch_page, array($this, 'add_sqlite_script'));
add_action('admin_print_scripts-'.$edit_db, array($this, 'add_sqlite_script'));
} }
} }
@ -191,6 +192,7 @@ class SQLiteIntegration {
add_action('admin_print_scripts-'.$util_page, array($this, 'add_sqlite_script')); add_action('admin_print_scripts-'.$util_page, array($this, 'add_sqlite_script'));
add_action('admin_print_scripts-'.$doc_page, array($this, 'add_sqlite_script')); add_action('admin_print_scripts-'.$doc_page, array($this, 'add_sqlite_script'));
add_action('admin_print_scripts-'.$patch_page, array($this, 'add_sqlite_script')); add_action('admin_print_scripts-'.$patch_page, array($this, 'add_sqlite_script'));
add_action('admin_print_scripts-'.$edit_db, array($this, 'add_sqlite_script'));
} }
} }

View File

@ -108,10 +108,10 @@ p {
} }
table#sys-info{ table#sys-info{
/* width: 600px; */ /* width: 600px; */
width: 450px; width: 480px;
} }
table#status { table#status {
width: 450px; width: 480px;
} }
table#sqlite-table { table#sqlite-table {
/* width: 700px; */ /* width: 700px; */
@ -172,7 +172,8 @@ input.button-primary {
.alt { .alt {
background: rgb(247, 254, 236); background: rgb(247, 254, 236);
} }
table#patch-files .item { table#patch-files .item,
table#backup-files .item {
width: 40px; width: 40px;
} }
.alert { .alert {

View File

@ -202,7 +202,7 @@ class PatchUtils {
} }
echo '</div>'; echo '</div>';
} else { } else {
$message = __('Error! Please remove files manually'); $message = __('Error! Please remove files manually', $domain);
echo '<div id="message" class="updated fade">'.$message.'</div>'; echo '<div id="message" class="updated fade">'.$message.'</div>';
} }
} }

View File

@ -329,6 +329,79 @@ class SQLiteIntegrationUtils {
} }
} }
/**
* function to parse FQDBDIR and return backup database files
*/
private function get_backup_files() {
$db_name = basename(FQDB);
$names_to_exclude = array('.', '..', '.htaccess', 'debug.txt', '.ht.sqlite', $db_name);
$backup_files = array();
if (is_dir(FQDBDIR)) {
if ($dir_handle = opendir(FQDBDIR)) {
while (($file_name = readdir($dir_handle)) !== false) {
if (in_array($file_name, $names_to_exclude)) continue;
$backup_files[] = $file_name;
}
}
}
return $backup_files;
}
/**
* function to create backup file
*/
private function backup_db() {
$result = array();
$database_file = FQDB;
$db_name = basename(FQDB);
if (!file_exists($database_file)) {
return false;
}
$today = date("Ymd");
if (!extension_loaded('zip')) {
$backup_file = $database_file . '.' . $today . '.back';
if (copy($database_file, $backup_file)) {
$result['success'] = basename($backup_file) . __(' was created.', $domain);
} else {
$result['error'] = basename($backup_file) . __(' was not created.', $domain);
}
} else {
$backup_file = $database_file . '.' . $today . '.zip';
$zip = new ZipArchive();
$res = $zip->open($backup_file, ZipArchive::CREATE | ZipArchive::OVERWRITE);
if ($res === true) {
$zip->addFile($database_file, $db_name);
$result['success'] = basename($backup_file) . __(' was created.', $domain);
} else {
$result['error'] = basename($backup_file) . __(' was not created.', $domain);
}
$zip->close();
}
return $result;
}
private function delete_backup_db() {
global $utils;
$domain = $utils->text_domain;
$file_names = array();
$results = array();
if (isset($_POST['backup_checked'])) {
$file_names = $_POST['backup_checked'];
} else {
return false;
}
if (chdir(FQDBDIR)) {
foreach ($file_names as $file) {
if (unlink($file)) {
$results[$file] = sprintf(__('File %s was deleted.', $domain), $file);
} else {
$results[$file] = sprintf(__('Error! File was not deleted.', $domain), $file);
}
}
}
return $results;
}
function welcome() { function welcome() {
$domain = $this->text_domain; $domain = $this->text_domain;
if (isset($_GET['page']) && $_GET['page'] == 'sqlite-integration') :?> if (isset($_GET['page']) && $_GET['page'] == 'sqlite-integration') :?>
@ -608,6 +681,35 @@ class SQLiteIntegrationUtils {
echo '<div id="message" class="updated fade">'.$messages.'</div>'; echo '<div id="message" class="updated fade">'.$messages.'</div>';
} }
} }
if (isset($_POST['backup_db'])) {
check_admin_referer('sqliteintegration-backup-manip-stats');
$results = $this->backup_db();
if ($results === false) {
$message = __('Couldn\'t find your database file.');
echo '<div id="message" class="updated fade">'.$message.'</div>';
} elseif (is_array($results) && array_key_exists('success', $results)) {
echo '<div id="message" class="updated fade">'.$results['success'].'</div>';
} else {
echo '<div id="message" class="update fade">'.$results['error'].'</div>';
}
}
if (isset($_POST['delete_backup_files'])) {
check_admin_referer('sqliteintegration-backup-manip-stats');
$results = $this->delete_backup_db();
if ($results === false) {
$message = __('Please select backup file(s).', $domain);
echo '<div id="message" class="updated fade">'.$message.'</div>';
} elseif (is_array($results) && count($results) > 0) {
echo '<div id="message" class="updated fade">';
foreach ($results as $key => $val) {
echo $val.'<br />';
}
echo '</div>';
} else {
$message = __('Error! Please remove file(s) manyally.', $domain);
echo '<div id="message" class="updated fade">'.$message.'</div>';
}
}
if (isset($_GET['page']) && $_GET['page'] == 'setting-file') :?> if (isset($_GET['page']) && $_GET['page'] == 'setting-file') :?>
<div class="navigation"> <div class="navigation">
<ul class="navi-menu"> <ul class="navi-menu">
@ -632,7 +734,43 @@ class SQLiteIntegrationUtils {
<input type="submit" name="sqlitewordpress_db_optimize" value="<?php _e('Optimize', $domain)?>" onclick="return confirm('<?php _e('Are you sure to optimize your database?\n\nClick [Cancel] to stop, [OK] to continue.', $domain);?>')" class="button-primary"> <input type="submit" name="sqlitewordpress_db_optimize" value="<?php _e('Optimize', $domain)?>" onclick="return confirm('<?php _e('Are you sure to optimize your database?\n\nClick [Cancel] to stop, [OK] to continue.', $domain);?>')" class="button-primary">
</p> </p>
</form> </form>
<h3><?php _e('SQLite Integration Error Log', $domain)?></h3> <h3><?php _e('Create or Delete backup file(s)', $domain);?></h3>
<p>
<?php _e('Click the backup button below if you want to create a current snapshot of your database file. The backup file is named &lsquo;DB_FILE_NAME.yyyymmdd.zip&rsquo; if PHP zip extension is loaded or &lsquo;DB_FILE_NAME.yyyymmdd.back&rsquo; if not loaded, and is put in the same directory that the database is in.', $domain);?>
</p>
<p>
<?php _e('If you want to delete the file(s), check the file name and click the Delete button. You can check multiple files.', $domain);?>
</p>
<?php $backup_files = $this->get_backup_files();?>
<form action="" method="post" id="delete-backup-form">
<?php if (function_exists('wp_nonce_field')) {
wp_nonce_field('sqliteintegration-backup-manip-stats');
}
?>
<table class="widefat page fixed" id="backup-files">
<thead>
<tr>
<th class="item"><?php _e('Delete', $domain);?></th>
<th data-sort='{"key":"name"}'><?php _e('Backup Files', $domain);?></th>
</tr>
</thead>
<tbody>
<?php if (!empty($backup_files)) : ?>
<?php foreach ($backup_files as $file) : ?>
<tr data-table='{"name":"<?php echo $file;?>"}'>
<td><input type="checkbox" id="backup_check" name="backup_checked[]" value="<?php echo $file;?>"/></td>
<td><?php echo $file;?></td>
</tr>
<?php endforeach;?>
<?php endif;?>
</tbody>
</table>
<p>
<input type="submit" name="backup_db" class="button-primary" value="<?php _e('Backup', $domain);?>" onclick="return confirm('<?php _e('Are you sure to make a backup file?\n\nClick [Cancel] to stop, [OK] to continue.', $domain);?>')" />
<input type="submit" name="delete_backup_files" class="button-primary" value="<?php _e('Delete file', $domain);?>" onclick="return confirm('<?php _e('Are you sure to delete backup file(s)?\n\nClick [Cancel] to stop, [OK] to continue.', $domain);?>')" />
</p>
</form>
<h3><?php _e('SQLite Integration Error Log', $domain);?></h3>
<p> <p>
<?php _e('This is the contents of SQLite Integration error log file(default: wp-content/database/debug.txt). If you want to clear this file, click the Clear Log button.', $domain)?> <?php _e('This is the contents of SQLite Integration error log file(default: wp-content/database/debug.txt). If you want to clear this file, click the Clear Log button.', $domain)?>
</p> </p>
@ -641,7 +779,7 @@ class SQLiteIntegrationUtils {
wp_nonce_field('sqlitewordpress-log-reset-stats'); wp_nonce_field('sqlitewordpress-log-reset-stats');
} }
?> ?>
<textarea name="errorlog" id="errorlog" cols="85" rows="10"> <textarea name="errorlog" id="errorlog" cols="70" rows="10">
<?php $ret_val = $this->show_error_log(); <?php $ret_val = $this->show_error_log();
if ($ret_val === false || empty($ret_val)) { if ($ret_val === false || empty($ret_val)) {
$message = __('No error messages are found', $domain); $message = __('No error messages are found', $domain);
@ -665,7 +803,7 @@ class SQLiteIntegrationUtils {
wp_nonce_field('sqlitewordpress-db-save-stats'); wp_nonce_field('sqlitewordpress-db-save-stats');
} }
?> ?>
<textarea name="dbfile" id="dbfile" cols="85" rows="30"> <textarea name="dbfile" id="dbfile" cols="70" rows="10">
<?php $this->show_db_php();?></textarea> <?php $this->show_db_php();?></textarea>
<p> <p>
<input type="submit" name="sqlitewordpress_db_save" value="<?php _e('Save')?>" onclick="return confirm('<?php _e('Are you sure to save this file?\n\nClick [Cancel] to stop, [OK] to continue.', $domain);?>')" class="button-primary"> <input type="submit" name="sqlitewordpress_db_save" value="<?php _e('Save')?>" onclick="return confirm('<?php _e('Are you sure to save this file?\n\nClick [Cancel] to stop, [OK] to continue.', $domain);?>')" class="button-primary">