tagging version 1.3

git-svn-id: https://plugins.svn.wordpress.org/sqlite-integration/tags/1.3@766773 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
kjmtsh 2013-09-04 07:53:31 +00:00
parent e17d3a382a
commit 1ff7bdf704
23 changed files with 1073 additions and 802 deletions

9
db.php
View File

@ -5,12 +5,11 @@
* wordpress/wp-content/db.php
*
* @package SQLite Integration
* @version 1.1
* @author Kojima Toshiyasu, Justin Adie
*
*/
function pdo_log_erro($message, $data = null) {
function pdo_log_error($message, $data = null) {
if (strpos($_SERVER['SCRIPT_NAME'], 'wp-admin') !== false) {
$admin_dir = '';
@ -38,15 +37,15 @@ HTML
}
if (version_compare( PHP_VERSION, '5.2.4', '<')) {
pdo_log_erro(__('PHP version on this server is too old.'), sprinf(__("Your server is running PHP version %d but this version of WordPress requires at least 5.2.4"), phpversion()));
pdo_log_error('PHP version on this server is too old.', sprinf("Your server is running PHP version %d but this version of WordPress requires at least 5.2.4", phpversion()));
}
if (!extension_loaded('pdo')) {
pdo_log_erro(__('PHP PDO Extension is not loaded.'), __('Your PHP installation appears to be missing the PDO extension which is required for this version of WordPress.'));
pdo_log_error('PHP PDO Extension is not loaded.', 'Your PHP installation appears to be missing the PDO extension which is required for this version of WordPress.');
}
if (!extension_loaded('pdo_sqlite')) {
pdo_log_erro(__('PDO Driver for SQLite is missing.'), __('Your PHP installtion appears not to have the right PDO drivers loaded. These are required for this version of WordPress and the type of database you have specified.'));
pdo_log_error('PDO Driver for SQLite is missing.', 'Your PHP installtion appears not to have the right PDO drivers loaded. These are required for this version of WordPress and the type of database you have specified.');
}
/**

View File

@ -1,7 +1,6 @@
<?php
/**
* @package SQLite Integration
* @version 1.1
* @author Kojima Toshiyasu, Justin Adie
*
*/

View File

@ -1,7 +1,6 @@
<?php
/**
* @package SQLite Integration
* @version 1.1
* @author Kojima Toshiyasu, Justin Adie
*
*/

View File

@ -1,13 +1,12 @@
<?php
/**
* @package SQLite Integration
* @version 1.1
* @author Kojima Toshiyasu, Justin Adie
*
*/
/**
* This function overrides wp_install() in wp-admin/upgrade.php
* This function overrides wp_install() in wp-admin/includes/upgrade.php
*/
function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '') {
if (!empty($deprecated))

View File

@ -14,6 +14,9 @@ jQuery(document).ready(function($) {
} else if (document.getElementById("patch-files") != null) {
$table = $('#patch-files');
$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
.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

@ -1,7 +1,6 @@
<?php
/**
* @package SQLite Integration
* @version 1.1
* @author Kojima Toshiyasu, Justin Adie
*
*/
@ -46,6 +45,16 @@ class PDODB extends wpdb {
return true;
}
/**
* dummy out the MySQL function
* @see wpdb::set_charset()
*/
function set_charset($dbh, $charset = null, $collate = null) {
if ( ! isset( $charset ) )
$charset = $this->charset;
if ( ! isset( $collate ) )
$collate = $this->collate;
}
/**
* dummy out the MySQL function
* @see wpdb::select()
@ -62,10 +71,7 @@ class PDODB extends wpdb {
* @see wpdb::_real_escape()
*/
function _real_escape($string) {
if ($this->dbh && $this->real_escape)
return $this->dbh->quote($string);
else
return addslashes($string);
return addslashes($string);
}
/**
@ -77,7 +83,7 @@ class PDODB extends wpdb {
if (!$str) {
$err = $this->dbh->get_error_message() ? $this->dbh->get_error_message() : '';
$str = $err[2];
if (!empty($err)) $str = $err[2]; else $str = '';
}
$EZSQL_ERROR[] = array('query' => $this->last_query, 'error_str' => $str);

View File

@ -1,7 +1,6 @@
<?php
/**
* @package SQLite Integration
* @version 1.1
* @author Kojima Toshiyasu, Justin Adie
*
*/
@ -115,14 +114,14 @@ class PDOEngine extends PDO {
if (!is_dir(FQDBDIR)) {
if (!@mkdir(FQDBDIR, 0777, true)) {
umask($u);
$message = __('Unable to create the required directory! Please check your server settings.', 'sqlite-integration');
$message = 'Unable to create the required directory! Please check your server settings.';
echo $message;
return false;
}
}
if (!is_writable(FQDBDIR)) {
umask($u);
$message = __('Unable to create a file in the directory! Please check your server settings.', 'sqlite-integration');
$message = 'Unable to create a file in the directory! Please check your server settings.';
echo $message;
return false;
}
@ -130,7 +129,7 @@ class PDOEngine extends PDO {
$fh = fopen(FQDBDIR . '.htaccess', "w");
if (!$fh) {
umask($u);
$message = __('Unable to create a file in the directory! Please check your server settings.', 'sqlite-integration');
$message = 'Unable to create a file in the directory! Please check your server settings.';
echo $message;
return false;
}

View File

@ -1,7 +1,6 @@
<?php
/**
* @package SQLite Integration
* @version 1.1
* @author Kojima Toshiyasu, Justin Adie
*/
@ -54,12 +53,15 @@ class PDOSQLiteDriver {
$this->_delete_index_hints();
$this->_rewrite_regexp();
$this->_rewrite_boolean();
$this->_fix_date_quoting();
$this->_rewrite_between();
break;
case 'insert':
$this->_strip_backticks();
$this->_execute_duplicate_key_update();
$this->_rewrite_insert_ignore();
$this->_rewrite_regexp();
$this->_fix_date_quoting();
break;
case 'update':
$this->_strip_backticks();
@ -68,6 +70,7 @@ class PDOSQLiteDriver {
$this->_rewrite_limit_usage();
$this->_rewrite_order_by_usage();
$this->_rewrite_regexp();
$this->_rewrite_between();
break;
case 'delete':
$this->_strip_backticks();
@ -95,7 +98,7 @@ class PDOSQLiteDriver {
*/
private function _handle_show_query(){
$table_name = '';
$pattern = '/^\\s*SHOW\\s*TABLES\\s*(LIKE\\s*(.*))$/im';
$pattern = '/^\\s*SHOW\\s*TABLES\\s*.*?(LIKE\\s*(.*))$/im';
if (preg_match($pattern, $this->_query, $matches)) {
$table_name = str_replace(array("'", ';'), '', $matches[2]);
}
@ -285,25 +288,28 @@ class PDOSQLiteDriver {
* @return void
*/
private function _delete_index_hints(){
$pattern = '/use\s+index\s*\(.*?\)/i';
$pattern = '/\\s*(use|ignore|force)\\s+index\\s*\(.*?\)/i';
$this->_query = preg_replace($pattern, '', $this->_query);
}
/**
* Justin Adie says:
* method to fix inconsistent use of quoted, unquoted etc date values in query function
* this is ironic, given the above rewrite badlyformed dates method
* examples
* Fix the date string and quote. This is required for the calendar widget.
*
* where month(fieldname)=08 becomes month(fieldname)='8'
* where month(fieldname)='08' becomes month(fieldname)='8'
*
* I don't understand...
* I use preg_replace_callback instead of 'e' option because of security reason.
* cf. PHP manual (regular expression)
*
* @return void
*/
private function _fix_date_quoting(){
$pattern = '/(month|year|second|day|minute|hour|dayofmonth)\s*\((.*?)\)\s*=\s*["\']?(\d{1,4})[\'"]?\s*/ei';
$this->_query = preg_replace($pattern, "'\\1(\\2)=\'' . intval('\\3') . '\' ' ", $this->_query);
private function _fix_date_quoting() {
$pattern = '/(month|year|second|day|minute|hour|dayofmonth)\\s*\((.*?)\)\\s*=\\s*["\']?(\d{1,4})[\'"]?\\s*/im';
$this->_query = preg_replace_callback($pattern, array($this, '__fix_date_quoting'), $this->_query);
}
private function __fix_date_quoting($match) {
$fixed_val = "{$match[1]}({$match[2]})='" . intval($match[3]) . "' ";
return $fixed_val;
}
private function _rewrite_regexp(){
@ -408,7 +414,7 @@ class PDOSQLiteDriver {
return;
}
// data check
if (preg_match('/^\((.*)\)\\s*VALUES\\s*\((.*)\)$/im', $insert_data, $match_1)) {
if (preg_match('/^\((.*)\)\\s*VALUES\\s*\((.*)\)$/ims', $insert_data, $match_1)) {
$col_array = explode(',', $match_1[1]);
$ins_data_array = explode(',', $match_1[2]);
foreach ($col_array as $col) {
@ -507,6 +513,16 @@ class PDOSQLiteDriver {
}
}
private function _rewrite_between() {
$pattern = '/\\s*(\\w+)?\\s*BETWEEN\\s*([^\\s]*)?\\s*AND\\s*([^\\s]*)?\\s*/ims';
if (preg_match($pattern, $this->_query, $match)) {
$column_name = trim($match[1]);
$min_value = trim($match[2]);
$max_value = trim($match[3]);
$replacement = " $column_name >= '$min_value' AND $column_name <= '$max_value'";
$this->_query = str_ireplace($match[0], $replacement, $this->_query);
}
}
/**
* workaround function to avoid DELETE with JOIN
* wp-admin/includes/upgrade.php contains 'DELETE ... JOIN' statement.

View File

@ -3,7 +3,6 @@
* The class for manipulating ALTER query
* newly supports multiple variants
* @package SQLite Integration
* @version 1.1
* @author Kojima Toshiyasu
*/
class AlterQuery {
@ -85,7 +84,11 @@ class AlterQuery {
$tokens['column_name'] = '('.trim($col_name).')';
} elseif (in_array($match_2, array('index', 'key'))) {
$tokens['command'] = $match_1.' '.$match_2;
$tokens['index_name'] = $match_3;
if ($match_3 == '') {
$tokens['index_name'] = str_replace(array('(', ')'), '', $the_rest);
} else {
$tokens['index_name'] = $match_3;
}
$tokens['column_name'] = trim($the_rest);
} else {
$tokens['command'] = $match_1.' column';
@ -133,9 +136,8 @@ class AlterQuery {
if ($match_2 == 'column') {
$tokens['command'] = $match_1.' '.$match_2;
$tokens['old_column'] = $match_3;
list($new_col) = preg_split('/\s/s', trim($the_rest), -1, PREG_SPLIT_DELIM_CAPTURE);
list($new_col, $col_def) = explode(' ', trim($the_rest), 2);
$tokens['new_column'] = $new_col;
$col_def = str_ireplace($new_col, '', $the_rest);
$tokens['column_def'] = trim($col_def);
} else {
$tokens['command'] = $match_1.' column';
@ -345,16 +347,16 @@ class AlterQuery {
$create_query = array_shift($index_queries);
$create_query = preg_replace("/{$tokenized_query['table_name']}/i", $temp_table, $create_query);
if (preg_match("/\\b{$tokenized_query['old_column']}\\s*(.+?)(?=,)/ims", $create_query, $match)) {
if ($tokenized_query['column_def'] == trim($match[1])) {
if ($column_def == trim($match[1])) {
return 'SELECT 1=1';
} else {
$create_query = preg_replace("/\\b{$tokenized_query['old_column']}\\s*.*?(?=,)/ims", "{$tokenized_query['new_column']} {$tokenized_query['column_def']}", $create_query);
$create_query = preg_replace("/\\b{$tokenized_query['old_column']}\\s*.*?(?=,)/ims", "{$tokenized_query['new_column']} {$column_def}", $create_query);
}
} elseif (preg_match("/\\b{$tokenized_query['old_column']}\\s*(.+?)(?=\))/ims", $create_query, $match)) {
if ($tokenized_query['column_def'] == trim($match[1])) {
if ($column_def == trim($match[1])) {
return 'SELECT 1=1';
} else {
$create_query = preg_replace("/\\b{$tokenized_query['old_column']}\\s*.*?(?=\))/ims", "{$tokenized_query['new_column']} {$tokenized_query['column_def']}", $create_query);
$create_query = preg_replace("/\\b{$tokenized_query['old_column']}\\s*.*?(?=\))/ims", "{$tokenized_query['new_column']} {$column_def}", $create_query);
}
}
$query[] = $create_query;
@ -411,28 +413,28 @@ class AlterQuery {
*/
private function convert_field_types($col_name, $col_def){
$array_types = array(
'bit' => 'INTEGER', 'bool' => 'INTEGER',
'boolean' => 'INTEGER', 'tinyint' => 'INTEGER',
'smallint' => 'INTEGER', 'mediumint' => 'INTEGER',
'int' => 'INTEGER', 'integer' => 'INTEGER',
'bigint' => 'INTEGER', 'float' => 'REAL',
'double' => 'REAL', 'decimal' => 'REAL',
'dec' => 'REAL', 'numeric' => 'REAL',
'fixed' => 'REAL', 'date' => 'TEXT',
'datetime' => 'TEXT', 'timestamp' => 'TEXT',
'time' => 'TEXT', 'year' => 'TEXT',
'char' => 'TEXT', 'varchar' => 'TEXT',
'binary' => 'INTEGER', 'varbinary' => 'BLOB',
'tinyblob' => 'BLOB', 'tinytext' => 'TEXT',
'blob' => 'BLOB', 'text' => 'TEXT',
'mediumblob' => 'BLOB', 'mediumtext' => 'TEXT',
'longblob' => 'BLOB', 'longtext' => 'TEXT'
'bit' => 'INTEGER', 'bool' => 'INTEGER',
'boolean' => 'INTEGER', 'tinyint' => 'INTEGER',
'smallint' => 'INTEGER', 'mediumint' => 'INTEGER',
'bigint' => 'INTEGER', 'integer' => 'INTEGER',
'int' => 'INTEGER', 'float' => 'REAL',
'double' => 'REAL', 'decimal' => 'REAL',
'dec' => 'REAL', 'numeric' => 'REAL',
'fixed' => 'REAL', 'datetime' => 'TEXT',
'date' => 'TEXT', 'timestamp' => 'TEXT',
'time' => 'TEXT', 'year' => 'TEXT',
'varchar' => 'TEXT', 'char' => 'TEXT',
'varbinary' => 'BLOB', 'binary' => 'BLOB',
'tinyblob' => 'BLOB', 'mediumblob' => 'BLOB',
'longblob' => 'BLOB', 'blob' => 'BLOB',
'tinytext' => 'TEXT', 'mediumtext' => 'TEXT',
'longtext' => 'TEXT', 'text' => 'TEXT'
);
$array_curtime = array('current_timestamp', 'current_time', 'current_date');
$array_reptime = array("'0000-00-00 00:00:00'", "'0000-00-00 00:00:00'", "'0000-00-00'");
$def_string = str_replace('`', '', $col_def);
foreach ($array_types as $o=>$r){
$pattern = "/\\b" . $o . "\\s*(\([^\)]*\))?\\s*/imsx";
$pattern = "/\\b$o\\s*(\([^\)]*\)*)?\\s*/ims";
if (preg_match($pattern, $def_string)) {
$def_string = preg_replace($pattern, "$r ", $def_string);
break;

View File

@ -1,7 +1,6 @@
<?php
/**
* @package SQLite Integration
* @version 1.1
* @author Kojima Toshiyasu, Justin Adie
*/
@ -31,8 +30,9 @@ class CreateQuery{
} else {
return $this->_query;
}
} elseif (preg_match('/^CREATE\\s*(TEMP|TEMPORARY|)\\s*TRIGGER\\s*/im', $this->_query)) {
return $this->_query;
}
$this->strip_backticks();
$this->get_table_name();
$this->rewrite_comments();
$this->rewrite_field_types();
@ -46,6 +46,7 @@ class CreateQuery{
$this->rewrite_set();
$this->rewrite_key();
$this->add_if_not_exists();
$this->strip_backticks();
return $this->post_process();
}
@ -86,8 +87,12 @@ class CreateQuery{
'longblob' => 'blob', 'longtext' => 'text'
);
foreach ($array_types as $o=>$r){
$pattern = '/\\b(?<!`)'.$o.'\\b\\s*(\([^\)]*\)*)?\\s*/imsx';
$this->_query = preg_replace($pattern, " $r ", $this->_query);
$pattern = "/\\b(?<!`)$o\\b\\s*(\([^\)]*\)*)?\\s*/ims";
if (preg_match("/^\\s*.*?\\s*\(.*?$o.*?\)/im", $this->_query)) {
;
} else {
$this->_query = preg_replace($pattern, " $r ", $this->_query);
}
}
}

View File

@ -6,8 +6,8 @@ Tags: database, SQLite, PDO
Author: Kojima Toshiyasu
Author URI: http://dogwood.skr.jp/
Requires at least: 3.3
Tested up to: 3.5.2
Stable tag: 1.1
Tested up to: 3.6
Stable tag: 1.3
License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@ -158,18 +158,39 @@ wp-config.phpの準備が終わったら、次のステップに進みます。
* [Yet Another Related Posts](http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/)
* [Better Related Posts](http://wordpress.org/extend/plugins/better-related/)
たぶん、もっとあるでしょう。
たぶん、もっとあるでしょう。動作しないプラグインを見つけたら、お知らせいただけると助かります。
== Changelog ==
= 1.1 (2013-07-24) =
* DROP INDEX 単独のクエリが動作していなかったのを修正しました。
* shutdown_hook で descructor を実行していたのをやめました。
* LOCATE() 関数を使えるようにしました。
= 1.0 (2013-07-07) =
最初のリリース。
== Upgrade Notice ==
SQLite Integrationのアップグレードに失敗するようなら、FTPを使っての手動アップグレードを試してみてください。
== Changelog ==
= 1.3 (2013-09-04) =
* データベースファイルのスナップショットをzipアーカイブとしてバックアップするユーティリティを追加しました。
* ダッシュボードのスタイルをMP6プラグインに合わせたものに変えました。
* 言語カタログが読み込まれていないときのエラーメッセージの出力方法を一部変更しました。
* query_create.class.phpの_rewrite_field_types()を変更しました。dbDelta()関数が意図したとおりに実行されます。
* BETWEENステートメントが使えるようになりました。
* クエリからインデックスヒントを全て削除して実行するようにしました。
* New StatPressプラグインが使えるように、ALTER TABLE CHANGE COLUMNの扱いを修正しました。
* いくつかの小さなバグを修正しました。
= 1.2.1 (2013-08-04) =
* wp-db.phpの変更にともなって、wpdb::real_escapeプロパティを削除しました。WordPress 3.6 との互換性を保つための変更です。
= 1.2 (2013-08-03) =
* カレンダー・ウィジェットでの不具合に対応するため、日付フォーマットとそのクオートを修正しました。
* Windows マシンでパッチファイルが削除できなかったのを修正しました。
* パッチファイルをアップロードするときに textdomain のエラーが出るのを修正しました。
* ON DUPLICATE KEY UPDATEをともなったクエリの処理を変更しました。
* readme.txt と readme-ja.txt の間違いを直しました。
= 1.1 (2013-07-24) =
* DROP INDEX 単独のクエリが動作していなかったのを修正しました。
* shutdown_hook で destruct() を実行していたのをやめました。
* LOCATE() 関数を使えるようにしました。
= 1.0 (2013-07-07) =
* 最初のリリース。

View File

@ -6,8 +6,8 @@ Tags: database, SQLite, PDO
Author: Kojima Toshiyasu
Author URI: http://dogwood.skr.jp/
Requires at least: 3.3
Tested up to: 3.5.2
Stable tag: 1.1
Tested up to: 3.6
Stable tag: 1.3
License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@ -46,7 +46,7 @@ Please contact us with the methods below:
Post to [Support Forum](http://wordpress.org/support/plugin/sqlite-integration/).
Notes: WordPress.org doesn't officially support using any other database than MySQL. So there will be no supports from WordPress.org. Even if you post to the general Forum, you have few chances to get the answer. And if you use patched plugins, you will have be no support from the plugin authors, eithter.
Notes: WordPress.org doesn't officially support using any other database than MySQL. So there will be no supports from WordPress.org. Even if you post to the general Forum, you have few chances to get the answer. And if you use patched plugins, you will have no support from the plugin authors, eithter.
= Translation =
@ -150,18 +150,38 @@ These are other examples:
* [Yet Another Related Posts](http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/)
* [Better Related Posts](http://wordpress.org/extend/plugins/better-related/)
Probably there are more, I'm afraid.
== Changelog ==
= 1.1 (2013-07-24) =
* Fixed the manipulation of DROP INDEX query.
* Removed desctructor() from shutdown_hook.
* Enabled LOCATE() function in the query string.
= 1.0 (2013-07-07) =
First release version of the plugin.
Probably there are more, I'm afraid. If you find one, please let me know.
== Upgrade Notice ==
When auto upgrading of SQLite Integration fails, Please try manual upgrade via FTP.
When auto upgrading of SQLite Integration fails, please try manual upgrade via FTP.
== Changelog ==
= 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 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.
* Added the support for BETWEEN statement.
* 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 minor bugs.
= 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.
= 1.2 (2013-08-03) =
* Fixed the date string format and its quotation for calendar widget.
* Fixed the patch utility program for using on the Windows machine.
* Fixed the textdomain error in utilities/patch.php file when uploading the patch file.
* Changed the manipulation of the query with ON DUPLICATE KEY UPDATE.
* Fixed the typos in readme.txt and readme-ja.txt.
= 1.1 (2013-07-24) =
* Fixed the manipulation of DROP INDEX query.
* Removed destruct() from shutdown_hook.
* Enabled LOCATE() function in the query string.
= 1.0 (2013-07-07) =
* First release version of the plugin.

View File

@ -1,7 +1,6 @@
<?php
/**
* @package SQLite Integration
* @version 1.1
* @author Kojima Toshiyasu, Justin Adie
*/
@ -23,8 +22,8 @@ function make_db_sqlite() {
$pdo = new PDO('sqlite:'.FQDB, null, null, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
} catch (PDOException $err) {
$err_data = $err->errorInfo;
$message = __("Database connection error!<br />", 'sqlite-integration');
$message .= sprintf(__("Error message is: %s", 'sqlite-integration'), $err_data[2]);
$message = 'Database connection error!<br />';
$message .= sprintf("Error message is: %s", $err_data[2]);
echo $message;
return false;
}
@ -77,8 +76,8 @@ function make_db_sqlite() {
$pdo->commit();
} else {
$pdo->rollBack();
$message = sprintf(__("Error occured while creating tables or indexes...<br />Query was: %s<br />", 'sqlite-integration'), var_export($rewritten_query, true));
$message .= sprintf(__("Error message is: %s", 'sqlite-integration'), $err_data[2]);
$message = sprintf("Error occured while creating tables or indexes...<br />Query was: %s<br />", var_export($rewritten_query, true));
$message .= sprintf("Error message is: %s", $err_data[2]);
echo $message;
return false;
}

View File

@ -1,10 +1,10 @@
<?php
/*
Plugin Name: SQLite Integration
Plugin URI: http://wordpress.org/extend/plugins/sqlite-integration
Plugin URI: http://dogwood.skr.jp/wordpress/sqlite-integration/
Description: SQLite Integration is the plugin that enables WordPress to use SQLite. If you don't have MySQL and want to build a WordPress website, it's for you.
Author: Kojima Toshiyasu
Version: 1.1
Version: 1.3
Author URI: http://dogwood.skr.jp
Text Domain: sqlite-integration
Domain Path: /languages
@ -168,6 +168,7 @@ class SQLiteIntegration {
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-'.$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-'.$doc_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

@ -1,21 +1,8 @@
@CHARSET "UTF-8";
#sqlite-admin-wrap h2,
#sqlite-admin-side-wrap h2 {
background: rgb(73, 90, 88);
background: -moz-linear-gradient(bottom, rgba(73, 90, 88, 1), rgba(73, 90, 88, 0.5), rgba(73, 90, 88, 0));
background: -webkit-gradient(linear, bottom, top, from(rgba(73, 90, 88, 1)), color-stop(0.5, rgba(73, 90, 88, 0.5)), to(rgba(73, 90, 88, 0)));
background: linear-gradient(to top, rgba(73, 90, 88, 1), rgba(73, 90, 88, 0.2));
color: rgb(247, 254, 236);
-webkit-border-top-right-radius: 6px;
-webkit-border-top-left-radius: 6px;
-moz-border-radius-topright: 6px;
-moz-border-radius-topleft: 6px;
border-top-right-radius: 6px;
border-top-left-radius: 6px;
text-shadow: -1px -1px 0 rgb(93, 69, 35),
1px -1px 0 rgb(93, 69, 35),
-1px 1px 0 rgb(93, 69, 35),
1px 1px 0 rgb(93, 69, 35);
background: rgb(34, 34, 34);
color: rgb(256, 256, 256);
padding-left: 5px;
}
.navigation {
@ -37,13 +24,8 @@
margin-right: 10px;
padding: 5px;
border: .5px solit #000;
-webkit-border-top-right-radius: 6px;
-webkit-border-top-left-radius: 6px;
-moz-border-radius-topright: 6px;
-moz-border-radius-topleft: 6px;
border-top-right-radius: 6px;
border-top-left-radius: 6px;
box-shadow: 5px 5px 5px #eee;
background: rgb(51, 51, 51);
color: (256, 256, 256);
}
.menu-selected {
font-size: 20px;
@ -54,30 +36,18 @@
margin-right: 10px;
padding: 5px;
border: .5px solit #000;
-webkit-border-top-right-radius: 6px;
-webkit-border-top-left-radius: 6px;
-moz-border-radius-topright: 6px;
-moz-border-radius-topleft: 6px;
border-top-right-radius: 6px;
border-top-left-radius: 6px;
box-shadow: 5px 5px 5px #eee;
background: rgb(73, 90, 88);
background: -moz-linear-gradient(bottom, rgba(73, 90, 88, 1), rgba(73, 90, 88, 0.5), rgba(73, 90, 88, 0));
background: -webkit-gradient(linear, bottom, top, from(rgba(73, 90, 88, 1)), color-stop(0.5, rgba(73, 90, 88, 0.5)), to(rgba(73, 90, 88, 0)));
background: linear-gradient(to top, rgba(73, 90, 88, 1), rgba(73, 90, 88, 0.2));
color: rgb(247, 254, 236);
text-shadow: -1px -1px 0 rgb(93, 69, 35),
1px -1px 0 rgb(93, 69, 35),
-1px 1px 0 rgb(93, 69, 35),
1px 1px 0 rgb(93, 69, 35);
background: rgb(0, 116, 162);
color: rgb(256, 256, 256);
}
.menu-item a {
text-decoration: none;
color: rgb(256, 256, 256);
}
#sqlite-admin-wrap {
color: #1d1d1d;
font-size: 10pt;
border: 1px solid #ddd;
background: rgb(256, 256, 256);
/* border-top: 0; */
-webkit-border-bottom-right-radius: 6px;
-webkit-border-bottom-left-radius: 6px;
@ -85,6 +55,12 @@
-moz-border-radius-bottomleft: 6px;
border-bottom-right-radius: 6px;
border-bottom-left-radius: 6px;
-webkit-border-top-right-radius: 6px;
-webkit-border-top-left-radius: 6px;
-moz-border-radius-topright: 6px;
-moz-border-radius-topleft: 6px;
border-top-right-radius: 6px;
border-top-left-radius: 6px;
display: block;
float: left;
min-height: 100px;
@ -99,6 +75,7 @@
color: #1d1d1d;
font-size: 10pt;
border: 1px solid #ddd;
background: rgb(256, 256, 256);
/* border-top: 0; */
-webkit-border-bottom-right-radius: 6px;
-webkit-border-bottom-left-radius: 6px;
@ -106,6 +83,12 @@
-moz-border-radius-bottomleft: 6px;
border-bottom-right-radius: 6px;
border-bottom-left-radius: 6px;
-webkit-border-top-right-radius: 6px;
-webkit-border-top-left-radius: 6px;
-moz-border-radius-topright: 6px;
-moz-border-radius-topleft: 6px;
border-top-right-radius: 6px;
border-top-left-radius: 6px;
display: block;
float: left;
min-height: 100px;

View File

@ -1,22 +1,9 @@
@CHARSET "UTF-8";
#sqlite-admin-wrap h2,
#sqlite-admin-side-wrap h2 {
background: rgb(73, 90, 88);
background: -moz-linear-gradient(bottom, rgba(73, 90, 88, 1), rgba(73, 90, 88, 0.5), rgba(73, 90, 88, 0));
background: -webkit-gradient(linear, bottom, top, from(rgba(73, 90, 88, 1)), color-stop(0.5, rgba(73, 90, 88, 0.5)), to(rgba(73, 90, 88, 0)));
background: linear-gradient(to top, rgba(73, 90, 88, 1), rgba(73, 90, 88, 0.2));
color: rgb(247, 254, 236);
-webkit-border-top-right-radius: 6px;
-webkit-border-top-left-radius: 6px;
-moz-border-radius-topright: 6px;
-moz-border-radius-topleft: 6px;
border-top-right-radius: 6px;
border-top-left-radius: 6px;
text-shadow: -1px -1px 0 rgb(93, 69, 35),
1px -1px 0 rgb(93, 69, 35),
-1px 1px 0 rgb(93, 69, 35),
1px 1px 0 rgb(93, 69, 35);
padding-left: 5px;
background: rgb(34, 34, 34);
color: rgb(256, 256, 256);
padding-left: 5px;
}
h3 {
clear: both;
@ -40,13 +27,8 @@ h3 {
margin-right: 10px;
padding: 5px;
border: .5px solit #000;
-webkit-border-top-right-radius: 6px;
-webkit-border-top-left-radius: 6px;
-moz-border-radius-topright: 6px;
-moz-border-radius-topleft: 6px;
border-top-right-radius: 6px;
border-top-left-radius: 6px;
box-shadow: 5px 5px 5px #eee;
background: rgb(51, 51, 51);
color: (256, 256, 256);
}
.menu-selected {
font-size: 20px;
@ -57,30 +39,18 @@ h3 {
margin-right: 10px;
padding: 5px;
border: .5px solit #000;
-webkit-border-top-right-radius: 6px;
-webkit-border-top-left-radius: 6px;
-moz-border-radius-topright: 6px;
-moz-border-radius-topleft: 6px;
border-top-right-radius: 6px;
border-top-left-radius: 6px;
box-shadow: 5px 5px 5px #eee;
background: rgb(73, 90, 88);
background: -moz-linear-gradient(bottom, rgba(73, 90, 88, 1), rgba(73, 90, 88, 0.5), rgba(73, 90, 88, 0));
background: -webkit-gradient(linear, bottom, top, from(rgba(73, 90, 88, 1)), color-stop(0.5, rgba(73, 90, 88, 0.5)), to(rgba(73, 90, 88, 0)));
background: linear-gradient(to top, rgba(73, 90, 88, 1), rgba(73, 90, 88, 0.2));
color: rgb(247, 254, 236);
text-shadow: -1px -1px 0 rgb(93, 69, 35),
1px -1px 0 rgb(93, 69, 35),
-1px 1px 0 rgb(93, 69, 35),
1px 1px 0 rgb(93, 69, 35);
background: rgb(0, 116, 162);
color: rgb(256, 256, 256);
}
.menu-item a {
text-decoration: none;
color: rgb(256, 256, 256);
}
#sqlite-admin-wrap {
color: #1d1d1d;
font-size: 10pt;
border: 1px solid #ddd;
background: rgb(256, 256, 256);
/* border-top: 0; */
-webkit-border-bottom-right-radius: 6px;
-webkit-border-bottom-left-radius: 6px;
@ -88,11 +58,17 @@ h3 {
-moz-border-radius-bottomleft: 6px;
border-bottom-right-radius: 6px;
border-bottom-left-radius: 6px;
-webkit-border-top-right-radius: 6px;
-webkit-border-top-left-radius: 6px;
-moz-border-radius-topright: 6px;
-moz-border-radius-topleft: 6px;
border-top-right-radius: 6px;
border-top-left-radius: 6px;
display: block;
float: left;
min-height: 100%;
position: relative;
width: 60%;
width: 58%;
margin-top: 10px;
padding: 5px;
box-shadow: 5px 5px 5px #eee;
@ -102,6 +78,7 @@ h3 {
color: #1d1d1d;
font-size: 10pt;
border: 1px solid #ddd;
background: rgb(256, 256, 256);
/* border-top: 0; */
-webkit-border-bottom-right-radius: 6px;
-webkit-border-bottom-left-radius: 6px;
@ -109,6 +86,12 @@ h3 {
-moz-border-radius-bottomleft: 6px;
border-bottom-right-radius: 6px;
border-bottom-left-radius: 6px;
-webkit-border-top-right-radius: 6px;
-webkit-border-top-left-radius: 6px;
-moz-border-radius-topright: 6px;
-moz-border-radius-topleft: 6px;
border-top-right-radius: 6px;
border-top-left-radius: 6px;
display: block;
float: left;
min-height: 100%;
@ -125,14 +108,14 @@ p {
}
table#sys-info{
/* width: 600px; */
width: 450px;
width: 480px;
}
table#status {
width: 450px;
width: 480px;
}
table#sqlite-table {
/* width: 700px; */
width: 650px;
width: 100%;
}
th.tbl-name {
width: 200px;
@ -141,7 +124,7 @@ th.tbl_owner {
width: 105px;
}
th.tbl_index {
width: 350px;
width: 300px;
}
td.system {
color: rgb(153, 0, 0);
@ -150,7 +133,7 @@ td.user {
color: rgb(0, 0, 255);
}
td.menu-title {
width: 90px;
width: 95px;
}
table.statement {
width: 500px;
@ -176,7 +159,7 @@ tr.workaround {
tr.compatible {
}
th.active-plugins {
width: 100px;
width: 120px;
}
th.compatible {
width: 80px;
@ -189,7 +172,8 @@ input.button-primary {
.alt {
background: rgb(247, 254, 236);
}
table#patch-files .item {
table#patch-files .item,
table#backup-files .item {
width: 40px;
}
.alert {

View File

@ -1,8 +1,7 @@
<?php
/**
* @package SQLite Integration
* @version 1.1
* @author Toshiyasu Kojima
* @author Kojima Toshiyasu
*
*/
/**
@ -38,7 +37,7 @@ class SQLiteIntegrationDocument {
<h3><?php _e('Features', $domain);?></h3>
<p>
<?php _e('This plugin is a successor to <a href="http://wordpress.org/extend/plugins/pdo-for-wordpress/">PDO for WordPress</a>, which enabled WordPress to use SQLite for its database. But PDO for WordPress doesn\'t seem to be maintained any more only to be outdated. SQLite Integration makes use of the basic ideas and framework of PDO for WordPress, adds some new features and updates it to be able to work with the newest version of WordPress(3.5.1 and 3.6 beta).', $domain); ?>
<?php _e('This plugin is a successor to <a href="http://wordpress.org/extend/plugins/pdo-for-wordpress/">PDO for WordPress</a>, which enabled WordPress to use SQLite for its database. But PDO for WordPress doesn\'t seem to be maintained any more only to be outdated. SQLite Integration makes use of the basic ideas and framework of PDO for WordPress, adds some new features and updates it to be able to work with the newest version of WordPress(3.6).', $domain); ?>
</p>
<p>
<?php _e('<a href="http://www.sqlite.org/">SQLite Web Page</a> says &mdash; SQLite is a &quot;software library that implements selfcontained, serverless, zero-configuration, transactional SQL database engine&quot;. It is &quot;a good choice for small to medium size websites&quot;. It\'s small and portable, and you don\'t need any database server system.', $domain); ?>

View File

@ -3,7 +3,7 @@
* This file contains PatchUtils class
*
* @package SQLite Integration
* @since 1.1
* @author Kojima Toshiyasu
*
*/
class PatchUtils {
@ -34,6 +34,8 @@ class PatchUtils {
* @return boolean|array
*/
private function apply_patches() {
global $utils;
$domain = $utils->text_domain;
$installed_plugins = array();
$file_names = array();
$output = array();
@ -103,6 +105,8 @@ class PatchUtils {
* @return boolean|array
*/
private function delete_patch_files() {
global $utils;
$domain = $utils->text_domain;
$file_names = array();
$rm_results = array();
if (isset($_POST['plugin_checked'])) {
@ -110,18 +114,16 @@ class PatchUtils {
} else {
return false;
}
$command = 'rm -f';
foreach ($file_names as $file) {
if (chdir(SQLitePatchDir)) {
exec("$command $file", $output, $retval);
} else {
$rm_results[$file] = __('Error!: patches directory is not accessible.', $domain);
}
if ($retval > 0) {
$rm_results[$file] = sprintf(__('Error! Messages: %s', $domain), $output);
} else {
$rm_results[$file] = sprintf(__('File %s is deleted.', $domain), $file);
}
if (chdir(SQLitePatchDir)) {
foreach ($file_names as $file) {
if (unlink($file)) {
$rm_results[$file] = sprintf(__('File %s is deleted.', $domain), $file);
} else {
$rm_results[$file] = sprintf(__('Error! File %s is not deleted.', $domain), $file);
}
}
} else {
$rm_results[$file] = __('Error!: patches directory is not accessible.', $domain);
}
return $rm_results;
}
@ -130,6 +132,8 @@ class PatchUtils {
* No return values.
*/
private function upload_file() {
global $utils;
$domain = $utils->text_domain;
if (!file_exists(SQLitePatchDir) || !is_dir(SQLitePatchDir)) {
mkdir(SQLitePatchDir, 0705, true);
}
@ -198,7 +202,7 @@ class PatchUtils {
}
echo '</div>';
} else {
$message = __('Error! Please remove files manually');
$message = __('Error! Please remove files manually', $domain);
echo '<div id="message" class="updated fade">'.$message.'</div>';
}
}

View File

@ -22,7 +22,14 @@
"compat":"Checked",
"class":"compatible"
},
{
"name":"Better Delete Revision",
"compat":"No",
"reason":"DELETE with JOIN/etc",
"class":"incompatible"
},
{
"name":"Better Related Posts",
"compat":"No",
@ -111,6 +118,12 @@
"class":"compatible"
},
{
"name":"FeedWordPress",
"compat":"Checked",
"class":"compatible"
},
{
"name":"Google Analyticator",
"compat":"Checked",
@ -162,6 +175,14 @@
"class":"compatible"
},
{
"name":"NewStatPress",
"compat":"Needs Patch",
"patch_url":"http://dogwood.skr.jp/wordpress/plugins/",
"reason":"MySQL specific data",
"class":"workaround"
},
{
"name":"Optimize Database after Deleting Revisions",
"compat":"Probably No",
@ -175,6 +196,12 @@
"class":"compatible"
},
{
"name":"Redirection",
"compat":"Checked",
"class":"compatible"
},
{
"name":"Related Posts",
"compat":"Checked",
@ -247,6 +274,12 @@
"class":"compatible"
},
{
"name":"WP Emmet",
"compat":"Checked",
"class":"compatible"
},
{
"name":"WP Multibyte Patch",
"compat":"Checked",
@ -264,7 +297,13 @@
"compat":"Checked",
"class":"compatible"
},
{
"name":"WP-PostViews",
"compat":"Checked",
"class":"compatible"
},
{
"name":"WP-reCAPTCHA",
"compat":"Checked",

View File

@ -2,7 +2,7 @@
/**
*
* @package SQLite Integration
* @author kjm
* @author Kojima Toshiyasu
*
*/
class SQLiteIntegrationUtils {
@ -198,7 +198,7 @@ class SQLiteIntegrationUtils {
$db_file = FQDB;
if (file_exists($db_file)) {
$size = filesize($db_file);
clearstatcache(false, $db_file);
clearstatcache(true, $db_file);
return $this->convert_to_formatted_number($size);
}
}
@ -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() {
$domain = $this->text_domain;
if (isset($_GET['page']) && $_GET['page'] == 'sqlite-integration') :?>
@ -608,6 +681,35 @@ class SQLiteIntegrationUtils {
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') :?>
<div class="navigation">
<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">
</p>
</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>
<?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>
@ -641,7 +779,7 @@ class SQLiteIntegrationUtils {
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();
if ($ret_val === false || empty($ret_val)) {
$message = __('No error messages are found', $domain);
@ -665,7 +803,7 @@ class SQLiteIntegrationUtils {
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>
<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">