Fixed some bugs and added more features.

git-svn-id: https://plugins.svn.wordpress.org/sqlite-integration/trunk@852178 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
kjmtsh 2014-02-05 19:29:23 +00:00
parent 22a658ac3a
commit 71a1df03db
30 changed files with 2343 additions and 1086 deletions

8
db.php
View File

@ -18,9 +18,17 @@ if (!defined('ABSPATH')) { // Oh, you are not WordPress!
* USE_MYSQL is a directive for using MySQL for database. * USE_MYSQL is a directive for using MySQL for database.
* If you want to change the database from SQLite to MySQL or from MySQL to SQLite, * If you want to change the database from SQLite to MySQL or from MySQL to SQLite,
* the line below in the wp-config.php will enable you to use MySQL. * the line below in the wp-config.php will enable you to use MySQL.
*
* <code> * <code>
* define('USE_MYSQL', true); * define('USE_MYSQL', true);
* </code> * </code>
*
* If you want to use SQLite, the line below will do. Or simply removing the line will
* be enough.
*
* <code>
* define('USE_MYSQL', false);
* </code>
*/ */
if (defined('USE_MYSQL') && USE_MYSQL === true) return; if (defined('USE_MYSQL') && USE_MYSQL === true) return;

View File

@ -82,6 +82,9 @@ class PDOSQLiteUDFS {
'inet_aton' => 'inet_aton', 'inet_aton' => 'inet_aton',
'datediff' => 'datediff', 'datediff' => 'datediff',
'locate' => 'locate', 'locate' => 'locate',
'utc_date' => 'utc_date',
'utc_time' => 'utc_time',
'utc_timestamp' => 'utc_timestamp',
'version' => 'version' 'version' => 'version'
); );
/** /**
@ -224,7 +227,8 @@ class PDOSQLiteUDFS {
/** /**
* Method to emulate MySQL SUBSTRING() function. * Method to emulate MySQL SUBSTRING() function.
* *
* This function rewrites the function name to SQLite compatible substr(). * This function rewrites the function name to SQLite compatible substr(),
* which can manipulate UTF-8 characters.
* *
* @param string $text * @param string $text
* @param integer $pos representing the start point. * @param integer $pos representing the start point.
@ -667,17 +671,45 @@ class PDOSQLiteUDFS {
} }
} }
/** /**
* Method to return MySQL version. * Method to return GMT date in the string format.
*
* This function only returns WordPress $required_mysql_version, because it is
* meaningless for SQLite database.
* *
* @param none * @param none
* @return string representing the version number * @return string formatted GMT date 'dddd-mm-dd'
*/
public function utc_date() {
return gmdate('Y-m-d', time());
}
/**
* Method to return GMT time in the string format.
*
* @param none
* @return string formatted GMT time '00:00:00'
*/
public function utc_time() {
return gmdate('H:i:s', time());
}
/**
* Method to return GMT time stamp in the string format.
*
* @param none
* @return string formatted GMT timestamp 'yyyy-mm-dd 00:00:00'
*/
public function utc_timestamp() {
return gmdate('Y-m-d H:i:s', time());
}
/**
* Method to return MySQL version.
*
* This function only returns the current newest version number of MySQL,
* because it is meaningless for SQLite database.
*
* @param none
* @return string representing the version number: major_version.minor_version
*/ */
public function version() { public function version() {
global $required_mysql_version; // global $required_mysql_version;
return $required_mysql_version; // return $required_mysql_version;
return '5.5';
} }
} }
?> ?>

View File

@ -84,6 +84,9 @@ class PDOSQLiteUDFS {
'inet_aton' => 'inet_aton', 'inet_aton' => 'inet_aton',
'datediff' => 'datediff', 'datediff' => 'datediff',
'locate' => 'locate', 'locate' => 'locate',
'utc_date' => 'utc_date',
'utc_time' => 'utc_time',
'utc_timestamp' => 'utc_timestamp',
'version' => 'version' 'version' => 'version'
); );
/** /**
@ -225,7 +228,8 @@ class PDOSQLiteUDFS {
/** /**
* Method to emulate MySQL SUBSTRING() function. * Method to emulate MySQL SUBSTRING() function.
* *
* This function rewrites the function name to SQLite compatible substr(). * This function rewrites the function name to SQLite compatible substr(),
* which can manipulate UTF-8 characters.
* *
* @param string $text * @param string $text
* @param integer $pos representing the start point. * @param integer $pos representing the start point.
@ -640,17 +644,45 @@ class PDOSQLiteUDFS {
} }
} }
/** /**
* Method to return MySQL version. * Method to return GMT date in the string format.
*
* This function only returns WordPress $required_mysql_version, because it is
* meaningless for SQLite database.
* *
* @param none * @param none
* @return string representing the version number * @return string formatted GMT date 'dddd-mm-dd'
*/
public function utc_date() {
return gmdate('Y-m-d', time());
}
/**
* Method to return GMT time in the string format.
*
* @param none
* @return string formatted GMT time '00:00:00'
*/
public function utc_time() {
return gmdate('H:i:s', time());
}
/**
* Method to return GMT time stamp in the string format.
*
* @param none
* @return string formatted GMT timestamp 'yyyy-mm-dd 00:00:00'
*/
public function utc_timestamp() {
return gmdate('Y-m-d H:i:s', time());
}
/**
* Method to return MySQL version.
*
* This function only returns the current newest version number of MySQL,
* because it is meaningless for SQLite database.
*
* @param none
* @return string representing the version number: major_version.minor_version
*/ */
public function version() { public function version() {
global $required_mysql_version; // global $required_mysql_version;
return $required_mysql_version; // return $required_mysql_version;
return '5.5';
} }
} }
?> ?>

View File

@ -3,6 +3,7 @@
* *
* This script is only included on the documentation and utility page. * This script is only included on the documentation and utility page.
* *
* @package SQLite Integration
* @author Kojima Toshiyasu * @author Kojima Toshiyasu
*/ */
jQuery(document).ready(function($) { jQuery(document).ready(function($) {

Binary file not shown.

View File

@ -129,12 +129,11 @@ msgstr "パッチ"
#: utilities/documentation.php:32 #: utilities/documentation.php:32
msgid "" msgid ""
"This is a brief documentation about this plugin. For more details, see also " "This is a brief documentation about this plugin. For more details, see also the "
"the <a href=\"http://dogwood.skr.jp/wordpress/sqlite-integration\">Plugin " "<a href=\"http://dogwood.skr.jp/wordpress/sqlite-integration/\">SQLite Integration page</a>."
"Page</a>."
msgstr "" msgstr ""
"このプラグインについての短いドキュメントです。詳しくは、<a href=\"http://dogwood.skr.jp/wordpress/" "このプラグインについての短いドキュメントです。詳しくは、<a href=\"http://dogwood.skr.jp/wordpress/"
"sqlite-integration\">プラグインのページ</a>をご覧ください。" "sqlite-integration/\">SQLite Integration</a> のページ</a>をご覧ください。"
#: utilities/documentation.php:35 #: utilities/documentation.php:35
msgid "" msgid ""
@ -266,12 +265,12 @@ msgstr ""
msgid "" msgid ""
"Some plugins do work fine if you rewrite MySQL functions. I made some patch " "Some plugins do work fine if you rewrite MySQL functions. I made some patch "
"files and <a href=\"%s?page=patch\">Patch Utility</a>. See also the <a href=" "files and <a href=\"%s?page=patch\">Patch Utility</a>. See also the <a href="
"\"http://dogwood.skr.jp/wordpress/sqlite-integration\">SQLite Integration page</a> for " "\"http://dogwood.skr.jp/wordpress/sqlite-integration/#plugin-compat\">SQLite Integration"
"more details." " Page</a> for more details."
msgstr "" msgstr ""
"MySQLの関数を書き換えると動作するプラグインがあります。いくつかはパッチファイルと、<a href=\"%s?page=patch\">" "MySQLの関数を書き換えると動作するプラグインがあります。いくつかはパッチファイルと、<a href=\"%s?page=patch\">"
"パッチをあてる</a>ページを作りました。<a href=\"http://dogwood.skr.jp/wordpress/sqlite-integration\">" "パッチをあてる</a>ページを作りました。<a href=\"http://dogwood.skr.jp/wordpress/sqlite-integration-ja/#plugin-compat\">"
"プラグインのページ</a>もご覧ください。" "SQLite Integration のページ</a>もご覧ください。"
#: utilities/documentation.php:74 #: utilities/documentation.php:74
msgid "" msgid ""
@ -429,13 +428,40 @@ msgstr "エラー! ファイル%sは削除されていません。"
msgid "Error!: patches directory is not accessible." msgid "Error!: patches directory is not accessible."
msgstr "エラー! パッチ・ディレクトリにアクセスできません。" msgstr "エラー! パッチ・ディレクトリにアクセスできません。"
msgid "Unable to create a patch directory."
msgstr "パッチ・ディレクトリを作成できませんでした。"
msgid "Unable to create a .htaccess file."
msgstr ".htaccess ファイルを作成できませんでした。"
msgid "Invalid operation."
msgstr "不正な操作です。"
msgid "File is too large to upload."
msgstr "ファイルサイズが制限を越えています。"
msgid "File upload is not complete."
msgstr "ファイルアップロードは完了しませんでした。"
msgid "File is not uploaded."
msgstr "ファイルはアップロードされませんでした。"
msgid "Temporary directory is not writable."
msgstr "テンポラリ・ディレクトリに書込みできません。"
msgid "File cannot be written on the disk."
msgstr "ファイルをディスクに書き込めません。"
msgid "Unknown error."
msgstr "不明なエラーです。"
#: utilities/patch.php:142 #: utilities/patch.php:142
msgid "File is uploaded" msgid "File is successfully uploaded."
msgstr "ファイルをアップロードしました" msgstr "ファイルをアップロードしました"
#: utilities/patch.php:146 #: utilities/patch.php:146
msgid "File is not uploaded" msgid "File upload failed. Possible file upload attack."
msgstr "ファイルはアップロードされていません" msgstr "アップロードに失敗しました。不正なファイルです。"
#: utilities/patch.php:150 #: utilities/patch.php:150
msgid "File is not selected" msgid "File is not selected"
@ -630,9 +656,11 @@ msgstr "ファイルを選択"
#: utilities/patch.php:286 #: utilities/patch.php:286
msgid "" msgid ""
"Select file from your computer. If the file name is the same as existent " "Select file from your computer. If the file name is the same as existent "
"file, this operation will override it." "file, this operation will override it. You can't upload the file whose "
"size is over 500kB."
msgstr "" msgstr ""
"あなたのコンピュータにあるファイルを選択します。ファイル名がすでに存在する場合は、それを上書きします。" "あなたのコンピュータにあるファイルを選択します。ファイル名がすでに存在する場合は、それを上書きします。"
"500kB を越えるサイズのファイルはアップロードできません。"
#: utilities/patch.php:288 #: utilities/patch.php:288
msgid "Upload" msgid "Upload"
@ -705,6 +733,16 @@ msgstr "たぶん可"
msgid "Checked" msgid "Checked"
msgstr "チェック済" msgstr "チェック済"
msgid "Checked*"
msgstr "チェック済*"
msgid ""
"\"Checked*\" with an asterisk is from the users' information. "
"I didn't check myself yet. If you found any malfunctioning, please let me know."
msgstr ""
"「チェック済*」のようにアステリスクのついたものは、ユーザからの情報にもとづいたものです。"
"私自身はチェックしていません。もし、不具合があるようでしたら、お知らせください。"
#: utilities/utility.php:257 utilities/utility.php:263 #: utilities/utility.php:257 utilities/utility.php:263
msgid "Not Checked" msgid "Not Checked"
msgstr "未確認" msgstr "未確認"
@ -968,12 +1006,18 @@ msgstr "データベースの最適化、エラーログ、初期化ファイル
#: utilities/utility.php:695 #: utilities/utility.php:695
msgid "Please select backup file(s)." msgid "Please select backup file(s)."
msgstr "データベースを最適化する" msgstr "バックアップファイルを選択してください。"
#: utilities/utility.php:704 #: utilities/utility.php:704
msgid "Error! Please remove file(s) manyally." msgid "Error! Please remove file(s) manyally."
msgstr "エラー! 手動でファイルを削除してください。" msgstr "エラー! 手動でファイルを削除してください。"
msgid "Please select backup file."
msgstr "バックアップファイルを選択してください。"
msgid "Please select one file at a time."
msgstr "複数ファイルは選択できません。"
#: utilities/utility.php:718 #: utilities/utility.php:718
msgid "Database Optimization, Error Log, Init File" msgid "Database Optimization, Error Log, Init File"
msgstr "データベース最適化、エラー・ログ、初期化ファイル" msgstr "データベース最適化、エラー・ログ、初期化ファイル"
@ -1025,9 +1069,16 @@ msgid ""
msgstr "" msgstr ""
"バックアップファイルを削除したい場合は、ファイルをチェックして削除ボタンをクリックしてください。複数ファイルを選択できます。" "バックアップファイルを削除したい場合は、ファイルをチェックして削除ボタンをクリックしてください。複数ファイルを選択できます。"
msgid ""
"If you want to download a file, check the file name and click the Download button."
" Please check one file at a time."
msgstr ""
"バックアップファイルをダウンロードしたい場合は、ファイルをチェックしてダウンロードボタンをクリックしてください。"
"1ファイルのみ選択できます。"
#: utilities/utility.php:748 #: utilities/utility.php:748
msgid "Delete" msgid "Delete/Download"
msgstr "削除" msgstr "削除/ダウンロード"
#: utilities/utility.php:749 #: utilities/utility.php:749
msgid "Backup Files" msgid "Backup Files"
@ -1051,6 +1102,11 @@ msgid ""
msgstr "" msgstr ""
"バックアップファイルを削除します。\\n\\n中止する場合は[Cancel]を、続ける場合は[OK]をクリックしてください。" "バックアップファイルを削除します。\\n\\n中止する場合は[Cancel]を、続ける場合は[OK]をクリックしてください。"
msgid ""
"Are you sure to download backup file?\\n\\nClick [Cancel] to stop, [OK] to continue."
msgstr ""
"バックアップファイルをダウンロードします。\\n\\n中止する場合は[Cancel]を、続ける場合は[OK]をクリックしてください。"
#: utilities/utility.php:768 #: utilities/utility.php:768
msgid "SQLite Integration Error Log" msgid "SQLite Integration Error Log"
msgstr "SQLite Integrationのエラーログ" msgstr "SQLite Integrationのエラーログ"

File diff suppressed because it is too large Load Diff

View File

@ -149,7 +149,22 @@ class PDODB extends wpdb {
</div>"; </div>";
} }
} }
/**
* Method to flush cached data.
*
* This overrides wpdb::flush(). This is not necessarily overridden, because
* $result will never be resource.
*
* @see wpdb::flush
*/
function flush() {
$this->last_result = array();
$this->col_info = null;
$this->last_query = null;
$this->rows_affected = $this->num_rows = 0;
$this->last_error = '';
$this->result = null;
}
/** /**
* Method to do the database connection. * Method to do the database connection.
* *
@ -234,8 +249,9 @@ class PDODB extends wpdb {
* This overrides wpdb::load_col_info(), which uses a mysql function. * This overrides wpdb::load_col_info(), which uses a mysql function.
* *
* @see wpdb::load_col_info() * @see wpdb::load_col_info()
* @access protected
*/ */
function load_col_info() { protected function load_col_info() {
if ($this->col_info) if ($this->col_info)
return; return;
$this->col_info = $this->dbh->get_columns(); $this->col_info = $this->dbh->get_columns();
@ -266,13 +282,14 @@ class PDODB extends wpdb {
* *
* This overrides wpdb::db_version() to avoid using MySQL function. * This overrides wpdb::db_version() to avoid using MySQL function.
* It returns mysql version number, but it means nothing for SQLite. * It returns mysql version number, but it means nothing for SQLite.
* So it return the required mysql version. * So it return the newest mysql version.
* *
* @see wpdb::db_version() * @see wpdb::db_version()
*/ */
function db_version() { function db_version() {
global $required_mysql_version; // global $required_mysql_version;
return $required_mysql_version; // return $required_mysql_version;
return '5.5';
} }
} }

View File

@ -110,18 +110,44 @@ class PDOEngine extends PDO {
*/ */
private $affected_rows; private $affected_rows;
/** /**
* Class variable to store the queried column names. * Class variable to store the queried column info.
* *
* @var array * @var array
*/ */
private $column_names; private $column_data;
/**
* Variable to emulate MySQL affected row.
*
* @var integer
*/
private $num_rows; private $num_rows;
/**
* Return value from query().
*
* Each query has its own return value.
*
* @var mixed
*/
private $return_value; private $return_value;
/**
* Variable to determine which insert query to use.
*
* Whether VALUES clause in the INSERT query can take multiple values or not
* depends on the version of SQLite library. We check the version and set
* this varable to true or false.
*
* @var boolean
*/
private $can_insert_multiple_rows = false; private $can_insert_multiple_rows = false;
/**
*
* @var integer
*/
private $param_num; private $param_num;
/** /**
* Varible to check if there is an active transaction. * Varible to check if there is an active transaction.
* @var boolean * @var boolean
* @access protected
*/ */
protected $has_active_transaction = false; protected $has_active_transaction = false;
@ -144,7 +170,7 @@ class PDOEngine extends PDO {
} }
/** /**
* Function to initialize database. * Function to initialize database, executed in the contructor.
* *
* It checks if there's a database directory and database file, creates the tables, * It checks if there's a database directory and database file, creates the tables,
* and binds the user defined function to the pdo object. * and binds the user defined function to the pdo object.
@ -259,7 +285,7 @@ class PDOEngine extends PDO {
public function query($query) { public function query($query) {
$this->flush(); $this->flush();
$this->queries[] = "Raw query:\t$query"; $this->queries[] = "Raw query:\n$query";
$res = $this->determine_query_type($query); $res = $this->determine_query_type($query);
if (!$res) { if (!$res) {
$bailoutString = sprintf(__("<h1>Unknown query type</h1><p>Sorry, we cannot determine the type of query that is requested.</p><p>The query is %s</p>", 'sqlite-integration'), $query); $bailoutString = sprintf(__("<h1>Unknown query type</h1><p>Sorry, we cannot determine the type of query that is requested.</p><p>The query is %s</p>", 'sqlite-integration'), $query);
@ -311,7 +337,7 @@ class PDOEngine extends PDO {
default: default:
$engine = $this->prepare_engine($this->query_type); $engine = $this->prepare_engine($this->query_type);
$this->rewritten_query = $engine->rewrite_query($query, $this->query_type); $this->rewritten_query = $engine->rewrite_query($query, $this->query_type);
$this->queries[] = "Rewritten: $this->rewritten_query"; $this->queries[] = "Rewritten:\n$this->rewritten_query";
$this->extract_variables(); $this->extract_variables();
$statement = $this->prepare_query(); $statement = $this->prepare_query();
$this->execute_query($statement); $this->execute_query($statement);
@ -346,10 +372,58 @@ class PDOEngine extends PDO {
/** /**
* Function to return the queried column names. * Function to return the queried column names.
* *
* @return string * These data are meaningless for SQLite. So they are dummy emulating
* MySQL columns data.
*
* @return array of the object
*/ */
public function get_columns() { public function get_columns() {
return $this->column_names; if (!empty($this->results)) {
$primary_key = array(
'meta_id', 'comment_ID', 'link_ID', 'option_id',
'blog_id', 'option_name', 'ID', 'term_id', 'object_id',
'term_taxonomy_id', 'umeta_id', 'id');
$unique_key = array('term_id', 'taxonomy', 'slug');
$data = array(
'name' => '', // column name
'table' => '', // table name
'max_length' => 0, // max length of the column
'not_null' => 1, // 1 if not null
'primary_key' => 0, // 1 if column has primary key
'unique_key' => 0, // 1 if column has unique key
'multiple_key' => 0, // 1 if column doesn't have unique key
'numeric' => 0, // 1 if column has numeric value
'blob' => 0, // 1 if column is blob
'type' => '', // type of the column
'unsigned' => 0, // 1 if column is unsigned integer
'zerofill' => 0 // 1 if column is zero-filled
);
if (preg_match("/\s*FROM\s*(.*)?\s*/i", $this->rewritten_query, $match)) {
$table_name = trim($match[1]);
} else {
$table_name = '';
}
foreach ($this->results[0] as $key => $value) {
$data['name'] = $key;
$data['table'] = $table_name;
if (in_array($key, $primary_key)) {
$data['primary_key'] = 1;
} elseif (in_array($key, $unique_key)) {
$data['unique_key'] = 1;
} else {
$data['multiple_key'] = 1;
}
$this->column_data[] = new ObjectArray($data);
$data['name'] = '';
$data['table'] = '';
$data['primary_key'] = 0;
$data['unique_key'] = 0;
$data['multiple_key'] = 0;
}
return $this->column_data;
} else {
return null;
}
} }
/** /**
* Function to return the queried result data. * Function to return the queried result data.
@ -429,7 +503,7 @@ class PDOEngine extends PDO {
$this->_results = null; $this->_results = null;
$this->last_insert_id = null; $this->last_insert_id = null;
$this->affected_rows = null; $this->affected_rows = null;
$this->column_names = array(); $this->column_data = array();
$this->num_rows = null; $this->num_rows = null;
$this->return_value = null; $this->return_value = null;
$this->extracted_variables = array(); $this->extracted_variables = array();
@ -466,7 +540,7 @@ class PDOEngine extends PDO {
* @return PDOStatement * @return PDOStatement
*/ */
private function prepare_query(){ private function prepare_query(){
$this->queries[] = 'Prepare: ' . $this->prepared_query; $this->queries[] = "Prepare:\n" . $this->prepared_query;
$reason = 0; $reason = 0;
$message = ''; $message = '';
$statement = null; $statement = null;
@ -501,7 +575,7 @@ class PDOEngine extends PDO {
if (!is_object($statement)) if (!is_object($statement))
return false; return false;
if (count($this->extracted_variables) > 0) { if (count($this->extracted_variables) > 0) {
$this->queries[] = 'Executing: ' . var_export($this->extracted_variables, true); $this->queries[] = "Executing:\n" . var_export($this->extracted_variables, true);
do { do {
if ($this->query_type == 'update' || $this->query_type == 'replace') { if ($this->query_type == 'update' || $this->query_type == 'replace') {
try { try {
@ -621,7 +695,7 @@ class PDOEngine extends PDO {
//reset the pcre.backtrack_limist //reset the pcre.backtrack_limist
ini_set('pcre.backtrack_limit', $_limit); ini_set('pcre.backtrack_limit', $_limit);
$this->queries[]= 'With Placeholders: ' . $query; $this->queries[] = "With Placeholders:\n" . $query;
$this->prepared_query = $query; $this->prepared_query = $query;
} }
/** /**
@ -701,7 +775,7 @@ class PDOEngine extends PDO {
private function execute_insert_query_new($query) { private function execute_insert_query_new($query) {
$engine = $this->prepare_engine($this->query_type); $engine = $this->prepare_engine($this->query_type);
$this->rewritten_query = $engine->rewrite_query($query, $this->query_type); $this->rewritten_query = $engine->rewrite_query($query, $this->query_type);
$this->queries[] = 'Rewritten: ' . $this->rewritten_query; $this->queries[] = "Rewritten:\n" . $this->rewritten_query;
$this->extract_variables(); $this->extract_variables();
$statement = $this->prepare_query(); $statement = $this->prepare_query();
$this->execute_query($statement); $this->execute_query($statement);
@ -744,7 +818,7 @@ class PDOEngine extends PDO {
} }
$query_string = $query_prefix . ' ' . $value . $suffix; $query_string = $query_prefix . ' ' . $value . $suffix;
$this->rewritten_query = $engine->rewrite_query($query_string, $this->query_type); $this->rewritten_query = $engine->rewrite_query($query_string, $this->query_type);
$this->queries[] = 'Rewritten: ' . $this->rewritten_query; $this->queries[] = "Rewritten:\n" . $this->rewritten_query;
$this->extracted_variables = array(); $this->extracted_variables = array();
$this->extract_variables(); $this->extract_variables();
if ($first) { if ($first) {
@ -757,7 +831,7 @@ class PDOEngine extends PDO {
} }
} else { } else {
$this->rewritten_query = $engine->rewrite_query($query, $this->query_type); $this->rewritten_query = $engine->rewrite_query($query, $this->query_type);
$this->queries[] = 'Rewritten: ' . $this->rewritten_query; $this->queries[] = "Rewritten:\n" . $this->rewritten_query;
$this->extract_variables(); $this->extract_variables();
$statement = $this->prepare_query(); $statement = $this->prepare_query();
$this->execute_query($statement); $this->execute_query($statement);
@ -821,7 +895,7 @@ class PDOEngine extends PDO {
try { try {
$this->beginTransaction(); $this->beginTransaction();
foreach ($rewritten_query as $single_query) { foreach ($rewritten_query as $single_query) {
$this->queries[] = "Executing:\t" . $single_query; $this->queries[] = "Executing:\n" . $single_query;
$single_query = trim($single_query); $single_query = trim($single_query);
if (empty($single_query)) continue; if (empty($single_query)) continue;
$this->pdo->exec($single_query); $this->pdo->exec($single_query);
@ -863,13 +937,13 @@ class PDOEngine extends PDO {
$this->beginTransaction(); $this->beginTransaction();
if (is_array($rewritten_query)) { if (is_array($rewritten_query)) {
foreach ($rewritten_query as $single_query) { foreach ($rewritten_query as $single_query) {
$this->queries[] = "Executing:\t" . $single_query; $this->queries[] = "Executing:\n" . $single_query;
$single_query = trim($single_query); $single_query = trim($single_query);
if (empty($single_query)) continue; if (empty($single_query)) continue;
$this->pdo->exec($single_query); $this->pdo->exec($single_query);
} }
} else { } else {
$this->queries[] = "Executing:\t" . $rewritten_query; $this->queries[] = "Executing:\n" . $rewritten_query;
$rewritten_query = trim($rewritten_query); $rewritten_query = trim($rewritten_query);
$this->pdo->exec($rewritten_query); $this->pdo->exec($rewritten_query);
} }

View File

@ -37,68 +37,68 @@ class PDOSQLiteDriver {
$this->_query = $query; $this->_query = $query;
switch ($this->query_type) { switch ($this->query_type) {
case 'truncate': case 'truncate':
$this->_handle_truncate_query(); $this->handle_truncate_query();
break; break;
case 'alter': case 'alter':
$this->_handle_alter_query(); $this->handle_alter_query();
break; break;
case 'create': case 'create':
$this->_handle_create_query(); $this->handle_create_query();
break; break;
case 'describe': case 'describe':
case 'desc': case 'desc':
$this->_handle_describe_query(); $this->handle_describe_query();
break; break;
case 'show': case 'show':
$this->_handle_show_query(); $this->handle_show_query();
break; break;
case 'showcolumns': case 'showcolumns':
$this->_handle_show_columns_query(); $this->handle_show_columns_query();
break; break;
case 'showindex': case 'showindex':
$this->_handle_show_index(); $this->handle_show_index();
break; break;
case 'select': case 'select':
$this->_strip_backticks(); $this->strip_backticks();
$this->_handle_sql_count(); $this->handle_sql_count();
$this->_rewrite_date_sub(); $this->rewrite_date_sub();
$this->_delete_index_hints(); $this->delete_index_hints();
$this->_rewrite_regexp(); $this->rewrite_regexp();
$this->_rewrite_boolean(); $this->rewrite_boolean();
$this->_fix_date_quoting(); $this->fix_date_quoting();
$this->_rewrite_between(); $this->rewrite_between();
break; break;
case 'insert': case 'insert':
$this->_safe_strip_backticks(); $this->safe_strip_backticks();
$this->_execute_duplicate_key_update(); $this->execute_duplicate_key_update();
$this->_rewrite_insert_ignore(); $this->rewrite_insert_ignore();
$this->_rewrite_regexp(); $this->rewrite_regexp();
$this->_fix_date_quoting(); $this->fix_date_quoting();
break; break;
case 'update': case 'update':
$this->_safe_strip_backticks(); $this->safe_strip_backticks();
$this->_rewrite_update_ignore(); $this->rewrite_update_ignore();
// $this->_rewrite_date_sub(); // $this->_rewrite_date_sub();
$this->_rewrite_limit_usage(); $this->rewrite_limit_usage();
$this->_rewrite_order_by_usage(); $this->rewrite_order_by_usage();
$this->_rewrite_regexp(); $this->rewrite_regexp();
$this->_rewrite_between(); $this->rewrite_between();
break; break;
case 'delete': case 'delete':
$this->_strip_backticks(); $this->strip_backticks();
$this->_rewrite_limit_usage(); $this->rewrite_limit_usage();
$this->_rewrite_order_by_usage(); $this->rewrite_order_by_usage();
$this->_rewrite_date_sub(); $this->rewrite_date_sub();
$this->_rewrite_regexp(); $this->rewrite_regexp();
$this->_delete_workaround(); $this->delete_workaround();
break; break;
case 'replace': case 'replace':
$this->_safe_strip_backticks(); $this->safe_strip_backticks();
$this->_rewrite_date_sub(); $this->rewrite_date_sub();
$this->_rewrite_regexp(); $this->rewrite_regexp();
break; break;
case 'optimize': case 'optimize':
$this->_rewrite_optimize(); $this->rewrite_optimize();
break; break;
case 'pragma': case 'pragma':
break; break;
@ -106,7 +106,7 @@ class PDOSQLiteDriver {
if (defined(WP_DEBUG) && WP_DEBUG) { if (defined(WP_DEBUG) && WP_DEBUG) {
break; break;
} else { } else {
$this->_return_true(); $this->return_true();
break; break;
} }
} }
@ -118,7 +118,7 @@ class PDOSQLiteDriver {
* *
* @access private * @access private
*/ */
private function _handle_show_query(){ private function handle_show_query(){
$table_name = ''; $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)) { if (preg_match($pattern, $this->_query, $matches)) {
@ -139,7 +139,7 @@ class PDOSQLiteDriver {
* *
* @access private * @access private
*/ */
private function _strip_backticks(){ private function strip_backticks(){
$this->_query = str_replace('`', '', $this->_query); $this->_query = str_replace('`', '', $this->_query);
} }
/** /**
@ -150,7 +150,7 @@ class PDOSQLiteDriver {
* *
* @access private * @access private
*/ */
private function _safe_strip_backticks() { private function safe_strip_backticks() {
$query_string = ''; $query_string = '';
$tokens = preg_split("/(''|')/s", $this->_query, -1, PREG_SPLIT_DELIM_CAPTURE); $tokens = preg_split("/(''|')/s", $this->_query, -1, PREG_SPLIT_DELIM_CAPTURE);
$literal = false; $literal = false;
@ -188,16 +188,15 @@ class PDOSQLiteDriver {
* *
* @access private * @access private
*/ */
private function _handle_sql_count(){ private function handle_sql_count(){
if (stripos($this->_query, 'SELECT SQL_CALC_FOUND_ROWS') !== false){ if (stripos($this->_query, 'SELECT SQL_CALC_FOUND_ROWS') !== false){
global $wpdb; global $wpdb;
// first strip the code. this is the end of rewriting process // first strip the code. this is the end of rewriting process
$this->_query = str_ireplace('SQL_CALC_FOUND_ROWS', '', $this->_query); $this->_query = str_ireplace('SQL_CALC_FOUND_ROWS', '', $this->_query);
// we make the data for next SELECE FOUND_ROWS() statement // we make the data for next SELECE FOUND_ROWS() statement
$unlimited_query = preg_replace('/\\bLIMIT\\s*.*/imsx', '', $this->_query); $unlimited_query = preg_replace('/\\bLIMIT\\s*.*/imsx', '', $this->_query);
// $unlimited_query = preg_replace('/\\bFALSE\\s*.*/imsx', '0', $unlimited_query);
$unlimited_query = preg_replace('/\\bGROUP\\s*BY\\s*.*/imsx', '', $unlimited_query); $unlimited_query = preg_replace('/\\bGROUP\\s*BY\\s*.*/imsx', '', $unlimited_query);
$unlimited_query = $this->__transform_to_count($unlimited_query); $unlimited_query = $this->_transform_to_count($unlimited_query);
$_wpdb = new PDODB(); $_wpdb = new PDODB();
$result = $_wpdb->query($unlimited_query); $result = $_wpdb->query($unlimited_query);
$wpdb->dbh->found_rows_result = $_wpdb->last_result; $wpdb->dbh->found_rows_result = $_wpdb->last_result;
@ -213,7 +212,7 @@ class PDOSQLiteDriver {
* @return string the transformed query * @return string the transformed query
* @access private * @access private
*/ */
private function __transform_to_count($query){ private function _transform_to_count($query){
$pattern = '/^\\s*SELECT\\s*(DISTINCT|)?.*?FROM\b/isx'; $pattern = '/^\\s*SELECT\\s*(DISTINCT|)?.*?FROM\b/isx';
$_query = preg_replace($pattern, 'SELECT \\1 COUNT(*) FROM ', $query); $_query = preg_replace($pattern, 'SELECT \\1 COUNT(*) FROM ', $query);
return $_query; return $_query;
@ -223,7 +222,7 @@ class PDOSQLiteDriver {
* *
* @access private * @access private
*/ */
private function _rewrite_insert_ignore(){ private function rewrite_insert_ignore(){
$this->_query = str_ireplace('INSERT IGNORE', 'INSERT OR IGNORE ', $this->_query); $this->_query = str_ireplace('INSERT IGNORE', 'INSERT OR IGNORE ', $this->_query);
} }
/** /**
@ -231,7 +230,7 @@ class PDOSQLiteDriver {
* *
* @access private * @access private
*/ */
private function _rewrite_update_ignore(){ private function rewrite_update_ignore(){
$this->_query = str_ireplace('UPDATE IGNORE', 'UPDATE OR IGNORE ', $this->_query); $this->_query = str_ireplace('UPDATE IGNORE', 'UPDATE OR IGNORE ', $this->_query);
} }
/** /**
@ -242,7 +241,7 @@ class PDOSQLiteDriver {
* *
* @access private * @access private
*/ */
private function _rewrite_date_add(){ private function rewrite_date_add(){
//(date,interval expression unit) //(date,interval expression unit)
$pattern = '/\\s*date_add\\s*\(([^,]*),([^\)]*)\)/imsx'; $pattern = '/\\s*date_add\\s*\(([^,]*),([^\)]*)\)/imsx';
if (preg_match($pattern, $this->_query, $matches)) { if (preg_match($pattern, $this->_query, $matches)) {
@ -258,7 +257,7 @@ class PDOSQLiteDriver {
* *
* @access private * @access private
*/ */
private function _rewrite_date_sub(){ private function rewrite_date_sub(){
//(date,interval expression unit) //(date,interval expression unit)
$pattern = '/\\s*date_sub\\s*\(([^,]*),([^\)]*)\)/imsx'; $pattern = '/\\s*date_sub\\s*\(([^,]*),([^\)]*)\)/imsx';
if (preg_match($pattern, $this->_query, $matches)) { if (preg_match($pattern, $this->_query, $matches)) {
@ -274,7 +273,7 @@ class PDOSQLiteDriver {
* *
* @access private * @access private
*/ */
private function _handle_create_query(){ private function handle_create_query(){
require_once PDODIR . 'query_create.class.php'; require_once PDODIR . 'query_create.class.php';
$engine = new CreateQuery(); $engine = new CreateQuery();
$this->_query = $engine->rewrite_query($this->_query); $this->_query = $engine->rewrite_query($this->_query);
@ -289,7 +288,7 @@ class PDOSQLiteDriver {
* *
* @access private * @access private
*/ */
private function _handle_alter_query(){ private function handle_alter_query(){
require_once PDODIR . 'query_alter.class.php'; require_once PDODIR . 'query_alter.class.php';
$engine = new AlterQuery(); $engine = new AlterQuery();
$this->_query = $engine->rewrite_query($this->_query, 'alter'); $this->_query = $engine->rewrite_query($this->_query, 'alter');
@ -304,7 +303,7 @@ class PDOSQLiteDriver {
* *
* @access private * @access private
*/ */
private function _handle_describe_query(){ private function handle_describe_query(){
// $this->_query = "select 1=1"; // $this->_query = "select 1=1";
$pattern = '/^\\s*(DESCRIBE|DESC)\\s*(.*)/i'; $pattern = '/^\\s*(DESCRIBE|DESC)\\s*(.*)/i';
if (preg_match($pattern, $this->_query, $match)) { if (preg_match($pattern, $this->_query, $match)) {
@ -323,7 +322,7 @@ class PDOSQLiteDriver {
* *
* @access private * @access private
*/ */
private function _rewrite_limit_usage(){ private function rewrite_limit_usage(){
$_wpdb = new PDODB(); $_wpdb = new PDODB();
$options = $_wpdb->get_results('PRAGMA compile_options'); $options = $_wpdb->get_results('PRAGMA compile_options');
foreach ($options as $opt) { foreach ($options as $opt) {
@ -342,7 +341,7 @@ class PDOSQLiteDriver {
* *
* @access private * @access private
*/ */
private function _rewrite_order_by_usage() { private function rewrite_order_by_usage() {
$_wpdb = new PDODB(); $_wpdb = new PDODB();
$options = $_wpdb->get_results('PRAGMA compile_options'); $options = $_wpdb->get_results('PRAGMA compile_options');
foreach ($options as $opt) { foreach ($options as $opt) {
@ -357,7 +356,7 @@ class PDOSQLiteDriver {
* *
* @access private * @access private
*/ */
private function _handle_truncate_query(){ private function handle_truncate_query(){
$pattern = '/TRUNCATE TABLE (.*)/im'; $pattern = '/TRUNCATE TABLE (.*)/im';
$this->_query = preg_replace($pattern, 'DELETE FROM $1', $this->_query); $this->_query = preg_replace($pattern, 'DELETE FROM $1', $this->_query);
} }
@ -369,7 +368,7 @@ class PDOSQLiteDriver {
* *
* @access private * @access private
*/ */
private function _rewrite_optimize(){ private function rewrite_optimize(){
$this->_query ="VACUUM"; $this->_query ="VACUUM";
} }
/** /**
@ -384,7 +383,7 @@ class PDOSQLiteDriver {
* @return void * @return void
* @access private * @access private
*/ */
private function _rewrite_badly_formed_dates(){ private function rewrite_badly_formed_dates(){
$pattern = '/([12]\d{3,}-\d{2}-)(\d )/ims'; $pattern = '/([12]\d{3,}-\d{2}-)(\d )/ims';
$this->_query = preg_replace($pattern, '${1}0$2', $this->_query); $this->_query = preg_replace($pattern, '${1}0$2', $this->_query);
} }
@ -394,7 +393,7 @@ class PDOSQLiteDriver {
* @return void * @return void
* @access private * @access private
*/ */
private function _delete_index_hints(){ private function delete_index_hints(){
$pattern = '/\\s*(use|ignore|force)\\s+index\\s*\(.*?\)/i'; $pattern = '/\\s*(use|ignore|force)\\s+index\\s*\(.*?\)/i';
$this->_query = preg_replace($pattern, '', $this->_query); $this->_query = preg_replace($pattern, '', $this->_query);
} }
@ -412,9 +411,9 @@ class PDOSQLiteDriver {
* @return void * @return void
* @access private * @access private
*/ */
private function _fix_date_quoting() { private function fix_date_quoting() {
$pattern = '/(month|year|second|day|minute|hour|dayofmonth)\\s*\((.*?)\)\\s*=\\s*["\']?(\d{1,4})[\'"]?\\s*/im'; $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); $this->_query = preg_replace_callback($pattern, array($this, '_fix_date_quoting'), $this->_query);
} }
/** /**
* Call back method to rewrite date string. * Call back method to rewrite date string.
@ -423,7 +422,7 @@ class PDOSQLiteDriver {
* @return string * @return string
* @access private * @access private
*/ */
private function __fix_date_quoting($match) { private function _fix_date_quoting($match) {
$fixed_val = "{$match[1]}({$match[2]})='" . intval($match[3]) . "' "; $fixed_val = "{$match[1]}({$match[2]})='" . intval($match[3]) . "' ";
return $fixed_val; return $fixed_val;
} }
@ -435,7 +434,7 @@ class PDOSQLiteDriver {
* *
* @access private * @access private
*/ */
private function _rewrite_regexp(){ private function rewrite_regexp(){
$pattern = '/\s([^\s]*)\s*regexp\s*(\'.*?\')/im'; $pattern = '/\s([^\s]*)\s*regexp\s*(\'.*?\')/im';
$this->_query = preg_replace($pattern, ' regexpp(\1, \2)', $this->_query); $this->_query = preg_replace($pattern, ' regexpp(\1, \2)', $this->_query);
} }
@ -446,7 +445,7 @@ class PDOSQLiteDriver {
* *
* @access private * @access private
*/ */
private function _rewrite_boolean() { private function rewrite_boolean() {
$query = str_ireplace('TRUE', "1", $this->_query); $query = str_ireplace('TRUE', "1", $this->_query);
$query = str_ireplace('FALSE', "0", $query); $query = str_ireplace('FALSE', "0", $query);
$this->_query = $query; $this->_query = $query;
@ -456,7 +455,7 @@ class PDOSQLiteDriver {
* *
* @access private * @access private
*/ */
private function _handle_show_columns_query() { private function handle_show_columns_query() {
$pattern_like = '/^\\s*SHOW\\s*(COLUMNS|FIELDS)\\s*FROM\\s*(.*)?\\s*LIKE\\s*(.*)?/i'; $pattern_like = '/^\\s*SHOW\\s*(COLUMNS|FIELDS)\\s*FROM\\s*(.*)?\\s*LIKE\\s*(.*)?/i';
$pattern = '/^\\s*SHOW\\s*(COLUMNS|FIELDS)\\s*FROM\\s*(.*)?/i'; $pattern = '/^\\s*SHOW\\s*(COLUMNS|FIELDS)\\s*FROM\\s*(.*)?/i';
if (preg_match($pattern_like, $this->_query, $matches)) { if (preg_match($pattern_like, $this->_query, $matches)) {
@ -477,7 +476,7 @@ class PDOSQLiteDriver {
* *
* @access private * @access private
*/ */
private function _handle_show_index() { private function handle_show_index() {
$pattern = '/^\\s*SHOW\\s*(?:INDEX|INDEXES|KEYS)\\s*FROM\\s*(\\w+)?/im'; $pattern = '/^\\s*SHOW\\s*(?:INDEX|INDEXES|KEYS)\\s*FROM\\s*(\\w+)?/im';
if (preg_match($pattern, $this->_query, $match)) { if (preg_match($pattern, $this->_query, $match)) {
$table_name = preg_replace("/[\';]/", '', $match[1]); $table_name = preg_replace("/[\';]/", '', $match[1]);
@ -494,7 +493,7 @@ class PDOSQLiteDriver {
* @return void * @return void
* @access private * @access private
*/ */
private function _execute_duplicate_key_update() { private function execute_duplicate_key_update() {
$update = false; $update = false;
$unique_keys_for_cond = array(); $unique_keys_for_cond = array();
$unique_keys_for_check = array(); $unique_keys_for_check = array();
@ -633,7 +632,7 @@ class PDOSQLiteDriver {
* *
* @access private * @access private
*/ */
private function _rewrite_between() { private function rewrite_between() {
$pattern = '/\\s*(\\w+)?\\s*BETWEEN\\s*([^\\s]*)?\\s*AND\\s*([^\\s]*)?\\s*/ims'; $pattern = '/\\s*(\\w+)?\\s*BETWEEN\\s*([^\\s]*)?\\s*AND\\s*([^\\s]*)?\\s*/ims';
if (preg_match($pattern, $this->_query, $match)) { if (preg_match($pattern, $this->_query, $match)) {
$column_name = trim($match[1]); $column_name = trim($match[1]);
@ -674,7 +673,7 @@ class PDOSQLiteDriver {
* *
* @access private * @access private
*/ */
private function _delete_workaround() { private function delete_workaround() {
global $wpdb; global $wpdb;
// $pattern = "DELETE o1 FROM $wpdb->options AS o1 JOIN $wpdb->options AS o2 USING (option_name) WHERE o2.option_id > o1.option_id"; // $pattern = "DELETE o1 FROM $wpdb->options AS o1 JOIN $wpdb->options AS o2 USING (option_name) WHERE o2.option_id > o1.option_id";
$pattern = "DELETE o1 FROM $wpdb->options AS o1 JOIN $wpdb->options AS o2"; $pattern = "DELETE o1 FROM $wpdb->options AS o1 JOIN $wpdb->options AS o2";
@ -692,7 +691,7 @@ class PDOSQLiteDriver {
* *
* @access private * @access private
*/ */
private function _return_true() { private function return_true() {
$this->_query = 'SELECT 1=1'; $this->_query = 'SELECT 1=1';
} }
} }

View File

@ -12,10 +12,40 @@
*/ */
class CreateQuery{ class CreateQuery{
/**
* The query string to be rewritten in this class.
*
* @var string
* @access private
*/
private $_query = ''; private $_query = '';
/**
* The array to contain CREATE INDEX queries.
*
* @var array of strings
* @access private
*/
private $index_queries = array(); private $index_queries = array();
/**
* The array to contain error messages.
*
* @var array of string
* @access private
*/
private $_errors = array(); private $_errors = array();
/**
* Variable to have the table name to be executed.
*
* @var string
* @access private
*/
private $table_name = ''; private $table_name = '';
/**
* Variable to check if the query has the primary key.
*
* @var boolean
* @access private
*/
private $has_primary_key = false; private $has_primary_key = false;
/** /**
@ -60,8 +90,9 @@ class CreateQuery{
/** /**
* Method to get table name from the query string. * Method to get table name from the query string.
* *
* IF NOT EXISTS is removed for the easy regular expression usage. * 'IF NOT EXISTS' clause is removed for the easy regular expression usage.
* It will be added at the end of the process. * It will be added at the end of the process.
*
* @access private * @access private
*/ */
private function get_table_name(){ private function get_table_name(){
@ -74,6 +105,8 @@ class CreateQuery{
/** /**
* Method to change the MySQL field types to SQLite compatible types. * Method to change the MySQL field types to SQLite compatible types.
* *
* Order of the key value is important. Don't change it.
*
* @access private * @access private
*/ */
private function rewrite_field_types(){ private function rewrite_field_types(){
@ -126,7 +159,8 @@ class CreateQuery{
/** /**
* Method for stripping unsigned. * Method for stripping unsigned.
* *
* UNSIGNED INT(EGER) is converted to INTEGER here. * SQLite doesn't have unsigned int data type. So UNSIGNED INT(EGER) is converted
* to INTEGER here.
* *
* @access private * @access private
*/ */
@ -282,6 +316,7 @@ class CreateQuery{
* Method to assemble the main query and index queries into an array. * Method to assemble the main query and index queries into an array.
* *
* It return the array of the queries to be executed separately. * It return the array of the queries to be executed separately.
*
* @return array * @return array
* @access private * @access private
*/ */
@ -316,7 +351,7 @@ class CreateQuery{
} }
} }
/** /**
* Method to strip back ticks. * Method to strip back quotes.
* *
* @access private * @access private
*/ */
@ -342,3 +377,4 @@ class CreateQuery{
$this->_query = preg_replace($patterns, '', $this->_query); $this->_query = preg_replace($patterns, '', $this->_query);
} }
} }
?>

View File

@ -159,13 +159,17 @@ query_posts() や WP_Query() を使うときに、オプションの一部が機
== Changelog == == Changelog ==
= 1.5.1 (2014-01-00) = = 1.5.1 (2014-02-06) =
* SQL_CALC_FOUND_ROW ステートメントのバグを修正しました。メインクエリと WP_Query のページング情報に関連したものです。 * SQL_CALC_FOUND_ROW ステートメントのバグを修正しました。メインクエリと WP_Query のページング情報に関連したものです。
* コメント本文からバッククォートが削除されるバグを修正しました。 * コメント本文からバッククォートが削除されるバグを修正しました。
* バックアップファイルをローカルにダウンロードできるようにしました。
* PHP documentor で使えるように、ソースコードのドキュメントを書き直しました。 * PHP documentor で使えるように、ソースコードのドキュメントを書き直しました。
* このドキュメントを変えました。 * このドキュメントを変えました。
* マイナーな変更、修正がいくつかありました。 * マイナーな変更、修正がいくつかありました。
* WordPress 3.8.1 と 3.9 alpha でインストールテストをしました。 * WordPress 3.8.1 と 3.9 alpha でインストールテストをしました。
* プラグイン互換リストを増補しました。
* これまで使えなかった WordPress の関数が使えるようになりました。
* いくつかのユーザ定義関数を追加しました。
= 1.5 (2013-12-17) = = 1.5 (2013-12-17) =
* WordPress 3.8 でのインストールと動作テストをしました。 * WordPress 3.8 でのインストールと動作テストをしました。

View File

@ -157,13 +157,17 @@ When query_posts() or WP_Query() is used, some options didn't work properly. Whe
== Changelog == == Changelog ==
= 1.5.1 (2014-01-00) = = 1.5.1 (2014-02-06) =
* Fixed the bug for 'SQL_CALC_FOUND_ROW' statement. This is for the main query and WP_Query concerning paging information. * Fixed the bug for 'SQL_CALC_FOUND_ROW' statement. This is for the main query and WP_Query concerning paging information.
* Fixed the bug that the back quote in the comments was removed. * Fixed the bug that the back quote in the comments was removed.
* Added the feature to download a backup file to a local machine.
* Revised all the doc strings in the sourcse code for PHP documentor. * Revised all the doc strings in the sourcse code for PHP documentor.
* Changed the documentation. * Changed the documentation.
* Fixed minor bugs and typos. * Fixed minor bugs and typos.
* Tested to install WordPress 3.8.1 and 3.9 beta. * Tested to install WordPress 3.8.1 and 3.9 beta.
* Augumented the plugin compatibility list.
* Some functions in WordPress that can't be used are made to work.
* Some more user defined functions are added.
= 1.5 (2013-12-17) = = 1.5 (2013-12-17) =
* Tested WordPress 3.8 installation and compatibility. * Tested WordPress 3.8 installation and compatibility.

View File

@ -14,6 +14,7 @@ if (!defined('ABSPATH')) {
* Function to create tables according to the schemas of WordPress. * Function to create tables according to the schemas of WordPress.
* *
* This is executed only once while installation. * This is executed only once while installation.
*
* @return boolean * @return boolean
*/ */
function make_db_sqlite() { function make_db_sqlite() {

View File

@ -36,12 +36,21 @@ if (!defined('ABSPATH')) {
echo 'Thank you, but you are not allowed to access this file.'; echo 'Thank you, but you are not allowed to access this file.';
die(); die();
} }
/*
* This will be activated after the installation is finished.
* So you can use all the functionality of WordPress.
*/
$siteurl = get_option('siteurl'); $siteurl = get_option('siteurl');
/*
* Defines basic constants.
*/
define('SQLiteDir', dirname(plugin_basename(__FILE__))); define('SQLiteDir', dirname(plugin_basename(__FILE__)));
define('SQLiteFilePath', dirname(__FILE__)); define('SQLiteFilePath', dirname(__FILE__));
define('SQLiteDirName', basename(SQLiteFilePath)); define('SQLiteDirName', basename(SQLiteFilePath));
define('SQLiteUrl', $siteurl . '/wp-content/plugins/' . SQLiteDir); define('SQLiteUrl', $siteurl . '/wp-content/plugins/' . SQLiteDir);
/*
* Defines patch file upload directory.
*/
if (defined('UPLOADS')) { if (defined('UPLOADS')) {
define('SQLitePatchDir', UPLOADS . '/patches'); define('SQLitePatchDir', UPLOADS . '/patches');
} else { } else {
@ -51,9 +60,13 @@ if (defined('UPLOADS')) {
define('SQLitePatchDir', ABSPATH . 'wp-content/uploads/patches'); define('SQLitePatchDir', ABSPATH . 'wp-content/uploads/patches');
} }
} }
/*
* Plugin compatibility file in json format.
*/
define('SQLiteListFile', SQLiteFilePath . '/utilities/plugin_lists.json'); define('SQLiteListFile', SQLiteFilePath . '/utilities/plugin_lists.json');
/*
* Instantiates utility classes.
*/
if (!class_exists('SQLiteIntegrationUtils')) { if (!class_exists('SQLiteIntegrationUtils')) {
require_once SQLiteFilePath . '/utilities/utility.php'; require_once SQLiteFilePath . '/utilities/utility.php';
$utils = new SQLiteIntegrationUtils(); $utils = new SQLiteIntegrationUtils();
@ -83,6 +96,8 @@ class SQLiteIntegration {
* Constructor. * Constructor.
* *
* This constructor does everything needed for the administration panel. * This constructor does everything needed for the administration panel.
*
* @param no parameter is provided.
*/ */
function __construct() { function __construct() {
if (function_exists('register_activation_hook')) { if (function_exists('register_activation_hook')) {
@ -98,14 +113,19 @@ class SQLiteIntegration {
} else { } else {
add_action('admin_menu', array($this, 'add_pages')); add_action('admin_menu', array($this, 'add_pages'));
} }
// See the docstring for download_backup_db() in utilities/utility.php
// We need this registration process.
add_action('admin_init', array('SQLiteIntegrationUtils', 'download_backup_db'));
add_action('plugins_loaded', array($this, 'textdomain_init')); add_action('plugins_loaded', array($this, 'textdomain_init'));
} }
/** /**
* Function to install on multisite or single site. * Method to install on multisite or single site.
* *
* There really is nothing to install for now. It is for future use... * There really is nothing to install for now. It is for future use...
* *
* @param no parameter is provided.
* @return returns null.
*/ */
function install() { function install() {
global $wpdb; global $wpdb;
@ -125,20 +145,26 @@ class SQLiteIntegration {
} }
/** /**
* Function to install something. * Method to install something.
* *
* We have nothing to do for now. * We have nothing to do for now.
* We show menu and documents only to the network administrator * We show menu and documents only to the network administrator.
*
* @param no parameter is provided.
* @return no return values.
*/ */
function _install() { function _install() {
} }
/** /**
* Function to uninstall plugin. * Method to uninstall plugin.
* *
* This will remove wp-content/db.php and wp-content/patches direcotry. * This will remove wp-content/db.php and wp-content/patches direcotry.
* If you migrate the site to the sever with MySQL, you have only to * If you migrate the site to the sever with MySQL, you have only to
* migrate the data in the database. * migrate the data in the database.
*
* @param no parameter is provided.
* @return no return values.
*/ */
function uninstall() { function uninstall() {
// remove patch files and patch directory // remove patch files and patch directory
@ -163,12 +189,15 @@ class SQLiteIntegration {
} }
/** /**
* Function to manipulate the admin panel, stylesheet and JavaScript. * Method to manipulate the admin panel, stylesheet and JavaScript.
* *
* We use class method to show pages and want to load style files and script * We use class method to show pages and want to load style files and script
* files only in our plugin documents, so we need add_submenu_page with parent * files only in our plugin documents, so we need add_submenu_page with parent
* slug set to null. This means that menu items are added but hidden from the * slug set to null. This means that menu items are added but hidden from the
* users. * users.
*
* @param no parameter is provided.
* @return no return values.
*/ */
function add_pages() { function add_pages() {
global $utils, $doc, $patch_utils, $maintenance; global $utils, $doc, $patch_utils, $maintenance;
@ -193,9 +222,12 @@ class SQLiteIntegration {
} }
/** /**
* Function to manipulate network admin panel. * Method to manipulate network admin panel.
* *
* Capability is set to manage_network_options. * Capability is set to manage_network_options.
*
* @param no parameter is provided.
* @return no return values.
*/ */
function add_network_pages() { function add_network_pages() {
global $utils, $doc, $patch_utils, $maintenance; global $utils, $doc, $patch_utils, $maintenance;
@ -220,9 +252,12 @@ class SQLiteIntegration {
} }
/** /**
* Function to initialize textdomain. * Method to initialize textdomain.
* *
* Japanese catalog is only available. * Japanese catalog is only available.
*
* @param no parameter is provided.
* @return no return values.
*/ */
function textdomain_init() { function textdomain_init() {
global $utils; global $utils;
@ -235,10 +270,14 @@ class SQLiteIntegration {
} }
/** /**
* Function to initialize stylesheet on the admin panel. * Method to initialize stylesheet on the admin panel.
* *
* This determines which stylesheet to use depending on the users' choice * This determines which stylesheet to use depending on the users' choice
* of admin_color. * of admin_color. Each stylesheet imports style.css and change the color
* of the admin dashboard.
*
* @param no parameter is provided.
* @return no return values.
*/ */
function add_style_sheet() { function add_style_sheet() {
global $current_user; global $current_user;
@ -256,8 +295,13 @@ class SQLiteIntegration {
} }
} }
/** /**
* Function to register the JavaScript file. * Method to register the JavaScript file.
* *
* To register the JavaScript file. It's only for the admin dashboard.
* It won't included in web pages.
*
* @param no parameter is provided.
* @return no return value.
*/ */
function add_sqlite_script() { function add_sqlite_script() {
$script_url = SQLiteUrl . '/js/sqlite.min.js'; $script_url = SQLiteUrl . '/js/sqlite.min.js';

View File

@ -1,6 +1,8 @@
/** /**
* This file is a part of SQLite Integration. * This file is a part of SQLite Integration.
* *
* @package SQLite Integration
* @author Kojima Toshiyasu
*/ */
@import url('./style.min.css'); @import url('./style.min.css');
@CHARSET "UTF-8"; @CHARSET "UTF-8";

View File

@ -1,6 +1,8 @@
/** /**
* This file is a part of SQLite Integration. * This file is a part of SQLite Integration.
* *
* @package SQLite Integration
* @author Kojima Toshiyasu
*/ */
@import url('./style.min.css'); @import url('./style.min.css');
@CHARSET "UTF-8"; @CHARSET "UTF-8";

View File

@ -1,6 +1,8 @@
/** /**
* This file is a part of SQLite Integration. * This file is a part of SQLite Integration.
* *
* @package SQLite Integration
* @author Kojima Toshiyasu
*/ */
@import url('./style.min.css'); @import url('./style.min.css');
@CHARSET "UTF-8"; @CHARSET "UTF-8";

View File

@ -1,6 +1,8 @@
/** /**
* This file is a part of SQLite Integration. * This file is a part of SQLite Integration.
* *
* @package SQLite Integration
* @author Kojima Toshiyasu
*/ */
@import url('./style.min.css'); @import url('./style.min.css');
@CHARSET "UTF-8"; @CHARSET "UTF-8";

View File

@ -1,6 +1,8 @@
/** /**
* This file is a part of SQLite Integration. * This file is a part of SQLite Integration.
* *
* @package SQLite Integration
* @author Kojima Toshiyasu
*/ */
@import url('./style.min.css'); @import url('./style.min.css');
@CHARSET "UTF-8"; @CHARSET "UTF-8";

View File

@ -1,6 +1,8 @@
/** /**
* This file is a part of SQLite Integration. * This file is a part of SQLite Integration.
* *
* @package SQLite Integration
* @author Kojima Toshiyasu
*/ */
@import url('./style.min.css'); @import url('./style.min.css');
@CHARSET "UTF-8"; @CHARSET "UTF-8";

View File

@ -1,6 +1,8 @@
/** /**
* This file is a part of SQLite Integration. * This file is a part of SQLite Integration.
* *
* @package SQLite Integration
* @author Kojima Toshiyasu
*/ */
@CHARSET "UTF-8"; @CHARSET "UTF-8";
#sqlite-admin-wrap h2, #sqlite-admin-wrap h2,
@ -110,11 +112,14 @@ h3 {
} }
p { p {
text-indent: 15px; text-indent: 15px;
line-height: 150%; line-height: 160%;
font-size: 11pt; font-size: 11pt;
margin-left: 10px; margin-left: 10px;
margin-right: 10px; margin-right: 10px;
} }
li {
line-height: 130%;
}
table#sys-info{ table#sys-info{
/* width: 600px; */ /* width: 600px; */
width: 80%; width: 80%;
@ -190,7 +195,7 @@ input.button-primary {
} }
table#patch-files .item, table#patch-files .item,
table#backup-files .item { table#backup-files .item {
width: 40px; width: 150px;
} }
.alert { .alert {
color: rgb(255, 0, 0); color: rgb(255, 0, 0);

View File

@ -1 +1 @@
@CHARSET "UTF-8";#sqlite-admin-wrap h2,#sqlite-admin-side-wrap h2{background:#222;color:#fff;padding-left:5px}h3{clear:both}.navigation{display:block;margin-top:0;margin-bottom:0;min-height:20px}.navi-menu{margin-left:0}.menu-item{font-size:20px;display:inline;min-width:150px;height:50px;margin-left:0;margin-right:10px;padding:5px;border:.5px solit #000;background:#333;color:(255,255,255);line-height:40px}.menu-selected{font-size:20px;display:inline;min-width:150px;height:50px;margin-left:0;margin-right:10px;padding:5px;border:.5px solit #000;background:#2ea2cc;color:#fff}.menu-item a{text-decoration:none;color:#fff}#sqlite-admin-wrap{color:#1d1d1d;font-size:11pt;border:1px solid #ddd;background:#fff;-webkit-border-bottom-right-radius:6px;-webkit-border-bottom-left-radius:6px;-moz-border-radius-bottomright:6px;-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:58%;margin-top:10px;padding:5px;box-shadow:5px 5px 5px #eee;z-index:1}#wpbody-content>.single{width:95%}#sqlite-admin-side-wrap{color:#1d1d1d;font-size:11pt;border:1px solid #ddd;background:#fff;-webkit-border-bottom-right-radius:6px;-webkit-border-bottom-left-radius:6px;-moz-border-radius-bottomright:6px;-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:35%;margin-top:10px;padding:5px 5px 5px 5px;box-shadow:5px 5px 5px #eee;z-index:1}p{text-indent:15px;line-height:150%;font-size:11pt;margin-left:10px;margin-right:10px}table#sys-info{width:80%}table#status{width:100%}table#sqlite-table{width:100%}th.tbl-name{width:25%}th.tbl_owner{width:25%}th.tbl_index{width:50%}td.system{color:#900}td.user{color:#00f}td.menu-title{width:95px}table.statement{width:500px}ul.in-body-list{margin-left:20px}ol{margin-left:40px}pre.code{padding:5px 5px 5px 5px;margin-left:15px;margin-right:10px;background:#eee;white-space:pre-wrap;word-wrap:break-word;overflow:auto}tr.incompatible{background:#fbe5dd}tr.workaround{background:#d9e8ed}th.active-plugins{width:20%}th.compatible{width:30%}input.button-primary{display:block;clear:both;width:100px}.alt{background:#f7feec}.em{font-weight:bold;text-transform:capitalize}table#patch-files .item,table#backup-files .item{width:40px}.alert{color:#f00}div.alert{display:block;width:95%;text-align:center;margin:0 auto;color:#f00;text-transform:capitalize}blockquote.caution{display:block;width:95%;border:3px double #000;margin:0 auto;padding:5px}blockquote.caution>p{margin:5px;padding:0}#errorlog,#dbfile{width:100%}@media screen and (max-width:600px){#sqlite-admin-wrap{width:95%}#sqlite-admin-side-wrap{width:95%}#sqlite-admin-wrap>table#sys-info{width:100%}table#sys-info th.item{width:50%}#sqlite-admin-wrap>table#status{width:100%}table#status th{width:50%}table#sqlite-table{width:100%}th.tbl-name{width:25%}th.tbl_owner{width:25%}th.tbl_index{width:50%}#sqlite-admin-side-wrap table#plugins-info{width:100%}th.installed-plugins{width:50%}th.active-plugins{width:20%}th.compatible{width:30%}#sqlite-admin-side-wrap>table#plugins-table{width:100%}#sqlite-admin-side-wrap>table#plugins-table th.item{width:30%}#sqlite-admin-side-wrap>table#plugins-table th.compat{width:20%}#sqlite-admin-side-wrap>table#plugins-table th.reason{width:50%}}@media screen and (max-width:782px){#sqlite-admin-wrap{width:95%}#sqlite-admin-side-wrap{width:95%}table#plugins-info{width:480px}table#sqlite-table{width:100%}th.tbl-name{width:25%}th.tbl_owner{width:25%}th.tbl_index{width:50%}#plugins-table{width:500px}}@media screen and (max-width:900px){#sqlite-admin-wrap{width:95%}#sqlite-admin-side-wrap{width:95%}table#plugins-info{width:480px}table#sqlite-table{width:100%}th.tbl-name{width:25%}th.tbl_owner{width:25%}th.tbl_index{width:50%}#plugins-table{width:500px}}@media screen and (max-width:1169px){#sqlite-admin-wrap{width:95%}#sqlite-admin-side-wrap{width:95%}table#plugins-info{width:480px}table#sys-info{width:460px}table#status{width:460px}table#sqlite-table{width:100%}th.tbl-name{width:25%}th.tbl_owner{width:25%}th.tbl_index{width:50%}#plugins-table{width:500px}} @CHARSET "UTF-8";#sqlite-admin-wrap h2,#sqlite-admin-side-wrap h2{background:#222;color:#fff;padding-left:5px}h3{clear:both}.navigation{display:block;margin-top:0;margin-bottom:0;min-height:20px}.navi-menu{margin-left:0}.menu-item{font-size:20px;display:inline;min-width:150px;height:50px;margin-left:0;margin-right:10px;padding:5px;border:.5px solit #000;background:#333;color:(255,255,255);line-height:40px}.menu-selected{font-size:20px;display:inline;min-width:150px;height:50px;margin-left:0;margin-right:10px;padding:5px;border:.5px solit #000;background:#2ea2cc;color:#fff}.menu-item a{text-decoration:none;color:#fff}#sqlite-admin-wrap{color:#1d1d1d;font-size:11pt;border:1px solid #ddd;background:#fff;-webkit-border-bottom-right-radius:6px;-webkit-border-bottom-left-radius:6px;-moz-border-radius-bottomright:6px;-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:58%;margin-top:10px;padding:5px;box-shadow:5px 5px 5px #eee;z-index:1}#wpbody-content>.single{width:95%}#sqlite-admin-side-wrap{color:#1d1d1d;font-size:11pt;border:1px solid #ddd;background:#fff;-webkit-border-bottom-right-radius:6px;-webkit-border-bottom-left-radius:6px;-moz-border-radius-bottomright:6px;-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:35%;margin-top:10px;padding:5px 5px 5px 5px;box-shadow:5px 5px 5px #eee;z-index:1}p{text-indent:15px;line-height:160%;font-size:11pt;margin-left:10px;margin-right:10px}li{line-height:130%}table#sys-info{width:80%}table#status{width:100%}table#sqlite-table{width:100%}th.tbl-name{width:25%}th.tbl_owner{width:25%}th.tbl_index{width:50%}td.system{color:#900}td.user{color:#00f}td.menu-title{width:95px}table.statement{width:500px}ul.in-body-list{margin-left:20px}ol{margin-left:40px}pre.code{padding:5px 5px 5px 5px;margin-left:15px;margin-right:10px;background:#eee;white-space:pre-wrap;word-wrap:break-word;overflow:auto}tr.incompatible{background:#fbe5dd}tr.workaround{background:#d9e8ed}th.active-plugins{width:20%}th.compatible{width:30%}input.button-primary{display:block;clear:both;width:100px}.alt{background:#f7feec}.em{font-weight:bold;text-transform:capitalize}table#patch-files .item,table#backup-files .item{width:150px}.alert{color:#f00}div.alert{display:block;width:95%;text-align:center;margin:0 auto;color:#f00;text-transform:capitalize}blockquote.caution{display:block;width:95%;border:3px double #000;margin:0 auto;padding:5px}blockquote.caution>p{margin:5px;padding:0}#errorlog,#dbfile{width:100%}@media screen and (max-width:600px){#sqlite-admin-wrap{width:95%}#sqlite-admin-side-wrap{width:95%}#sqlite-admin-wrap>table#sys-info{width:100%}table#sys-info th.item{width:50%}#sqlite-admin-wrap>table#status{width:100%}table#status th{width:50%}table#sqlite-table{width:100%}th.tbl-name{width:25%}th.tbl_owner{width:25%}th.tbl_index{width:50%}#sqlite-admin-side-wrap table#plugins-info{width:100%}th.installed-plugins{width:50%}th.active-plugins{width:20%}th.compatible{width:30%}#sqlite-admin-side-wrap>table#plugins-table{width:100%}#sqlite-admin-side-wrap>table#plugins-table th.item{width:30%}#sqlite-admin-side-wrap>table#plugins-table th.compat{width:20%}#sqlite-admin-side-wrap>table#plugins-table th.reason{width:50%}}@media screen and (max-width:782px){#sqlite-admin-wrap{width:95%}#sqlite-admin-side-wrap{width:95%}table#plugins-info{width:480px}table#sqlite-table{width:100%}th.tbl-name{width:25%}th.tbl_owner{width:25%}th.tbl_index{width:50%}#plugins-table{width:500px}}@media screen and (max-width:900px){#sqlite-admin-wrap{width:95%}#sqlite-admin-side-wrap{width:95%}table#plugins-info{width:480px}table#sqlite-table{width:100%}th.tbl-name{width:25%}th.tbl_owner{width:25%}th.tbl_index{width:50%}#plugins-table{width:500px}}@media screen and (max-width:1169px){#sqlite-admin-wrap{width:95%}#sqlite-admin-side-wrap{width:95%}table#plugins-info{width:480px}table#sys-info{width:460px}table#status{width:460px}table#sqlite-table{width:100%}th.tbl-name{width:25%}th.tbl_owner{width:25%}th.tbl_index{width:50%}#plugins-table{width:500px}}

View File

@ -1,6 +1,8 @@
/** /**
* This file is a part of SQLite Integration. * This file is a part of SQLite Integration.
* *
* @package SQLite Integration
* @author Kojima Toshiyasu
*/ */
@import url('./style.min.css'); @import url('./style.min.css');
@CHARSET "UTF-8"; @CHARSET "UTF-8";

View File

@ -3,15 +3,20 @@
* This file defines DatabaseMaintenance class. * This file defines DatabaseMaintenance class.
* *
* When WordPress was upgraded from 3.5.x to 3.6, SQLite Integration couldn't manipulate * When WordPress was upgraded from 3.5.x to 3.6, SQLite Integration couldn't manipulate
* dbDelta() function of WordPress. As a result, there are some tables whose default * dbDelta() function of WordPress as expected. As a result, there are some tables whose
* values are missing. * default values are missing.
* *
* This class checks the table schemas and restore the default value if necessary.
* This file is for temporary use and will be removed or changed in the future release. * This file is for temporary use and will be removed or changed in the future release.
* *
* @package SQLite Integration * @package SQLite Integration
* @author Kojima Toshiyasu * @author Kojima Toshiyasu
*/ */
/**
* This class provide the methods to check the table schemas and restore if necessary.
*
* Each method is a private function except the one to show admin page.
*
*/
class DatabaseMaintenance { class DatabaseMaintenance {
/** /**
* Method to check the table schemas. * Method to check the table schemas.

View File

@ -37,7 +37,7 @@ class SQLiteIntegrationDocument {
<div class="wrap" id="sqlite-admin-wrap"> <div class="wrap" id="sqlite-admin-wrap">
<h2><?php _e('Documentation', $domain); ?></h2> <h2><?php _e('Documentation', $domain); ?></h2>
<p> <p>
<?php _e('This is a brief documentation about this plugin. For more details, see also the <a href="http://dogwood.skr.jp/wordpress/sqlite-integration">SQLite Integration page</a>.', $domain);?> <?php _e('This is a brief documentation about this plugin. For more details, see also the <a href="http://dogwood.skr.jp/wordpress/sqlite-integration/">SQLite Integration page</a>.', $domain);?>
</p> </p>
<p> <p>
<?php _e('Please don\'t forget: WordPress DOES NOT OFFICIALLY SUPPORT any database other than MySQL. So if you ask about this plugin in the Forum, it\'s not unlikely that you won\'t get no answers at all.', $domain);?> <?php _e('Please don\'t forget: WordPress DOES NOT OFFICIALLY SUPPORT any database other than MySQL. So if you ask about this plugin in the Forum, it\'s not unlikely that you won\'t get no answers at all.', $domain);?>
@ -76,7 +76,7 @@ class SQLiteIntegrationDocument {
<li><strong><?php _e('There are some plugins that you can\'t use. No way around.<br />', $domain);?></strong> <li><strong><?php _e('There are some plugins that you can\'t use. No way around.<br />', $domain);?></strong>
<?php _e('Some plugins can\'t be activated or work properly. See the &quot;Plugin Compatibility/Incompatibility&quot; section.', $domain);?></li> <?php _e('Some plugins can\'t be activated or work properly. See the &quot;Plugin Compatibility/Incompatibility&quot; section.', $domain);?></li>
<li><strong><?php _e('There are some plugins that you can\'t use without rewriting some codes in them.<br />', $domain);?></strong> <li><strong><?php _e('There are some plugins that you can\'t use without rewriting some codes in them.<br />', $domain);?></strong>
<?php echo sprintf(__('Some plugins do work fine if you rewrite MySQL functions. I made some patch files and <a href="%s?page=patch">Patch Utility</a>. See also the <a href="http://dogwood.skr.jp/wordpress/sqlite-integration">Plugin Page</a> for more details.', $domain), $utils->show_parent());?></li> <?php echo sprintf(__('Some plugins do work fine if you rewrite MySQL functions. I made some patch files and <a href="%s?page=patch">Patch Utility</a>. See also the <a href="http://dogwood.skr.jp/wordpress/sqlite-integration/#plugin-compat">SQLite Integration Page</a> for more details.', $domain), $utils->show_parent());?></li>
</ol> </ol>
<p> <p>
<?php _e('And there may be other problems I overlooked. If you find malfunctionality, please let me know at the <a href="http://wordpress.org/support/plugin/sqlite-integration">Support Forum</a>.', $domain);?> <?php _e('And there may be other problems I overlooked. If you find malfunctionality, please let me know at the <a href="http://wordpress.org/support/plugin/sqlite-integration">Support Forum</a>.', $domain);?>

View File

@ -26,7 +26,7 @@ class PatchUtils {
} else { } else {
if ($dir_handle = opendir(SQLitePatchDir)) { if ($dir_handle = opendir(SQLitePatchDir)) {
while (($file_name = readdir($dir_handle)) !== false) { while (($file_name = readdir($dir_handle)) !== false) {
if ($file_name == '.' || $file_name == '..') if ($file_name == '.' || $file_name == '..' || $file_name == '.htaccess')
continue; continue;
$patch_files[] = $file_name; $patch_files[] = $file_name;
} }
@ -148,31 +148,82 @@ class PatchUtils {
* *
* It uploads a patch file to the server. You must have the permission to write to the * It uploads a patch file to the server. You must have the permission to write to the
* temporary directory. If there isn't SQLitePatchDir, this method will create it and * temporary directory. If there isn't SQLitePatchDir, this method will create it and
* set the permission to 0705. * set the permission to 0707.
* *
* No return values. * No return values.
* *
* @return boolean
* @access private * @access private
*/ */
private function upload_file() { private function upload_file() {
global $utils; global $utils;
$domain = $utils->text_domain; $domain = $utils->text_domain;
if (!file_exists(SQLitePatchDir) || !is_dir(SQLitePatchDir)) { if (!file_exists(SQLitePatchDir) || !is_dir(SQLitePatchDir)) {
mkdir(SQLitePatchDir, 0705, true); if (!mkdir(SQLitePatchDir, 0707, true)) {
$message = __('Unable to create a patch directory.', $domain);
echo '<div id="message" class="updated fade">'.$message.'</div>';
return false;
}
}
if (!is_file(SQLitePatchDir . '/.htaccess')) {
$fp = fopen(SQLitePatchDir . '/.htaccess', 'w');
if (!$fp) {
$message = __('Unable to create a .htaccess file.', $domain);
echo '<div id="message" class="updated fade">'.$message.'</div>';
return false;
}
fwrite($fp, 'DENY FROM ALL');
fclose($fp);
}
if (!isset($_FILES['upfile']['error']) || !is_int($_FILES['upfile']['error'])) {
$message = __('Invalid operation.', $domain);
echo '<div id="message" class="updated fade">'.$message.'</div>';
return false;
} elseif ($_FILES['upfile']['error'] != UPLOAD_ERR_OK) {
switch ($_FILES['upfile']['error']) {
case UPLOAD_ERR_FORM_SIZE:
$message = __('File is too large to upload.', $domain);
echo '<div id="message" class="updated fade">'.$message.'</div>';
break;
case UPLOAD_ERR_PARTIAL:
$message = __('File upload is not complete.', $domain);
echo '<div id="message" class="updated fade">'.$message.'</div>';
break;
case UPLOAD_ERR_NO_FILE:
$message = __('File is not uploaded.', $domain);
echo '<div id="message" class="updated fade">'.$message.'</div>';
break;
case UPLOAD_ERR_NO_TMP_DIR:
$message = __('Temporary directory is not writable.', $domain);
echo '<div id="message" class="updated fade">'.$message.'</div>';
break;
case UPLOAD_ERR_CANT_WRITE:
$message = __('File cannot be written on the disk.', $domain);
echo '<div id="message" class="updated fade">'.$message.'</div>';
break;
default:
$message = __('Unknown error.', $domain);
break;
}
return false;
} }
if (is_uploaded_file($_FILES['upfile']['tmp_name'])) { if (is_uploaded_file($_FILES['upfile']['tmp_name'])) {
if (move_uploaded_file($_FILES['upfile']['tmp_name'], SQLitePatchDir.'/'.$_FILES['upfile']['name'])) { $file_full_path = SQLitePatchDir . '/' . $_FILES['upfile']['name'];
$message = __('File is uploaded', $domain); if (move_uploaded_file($_FILES['upfile']['tmp_name'], $file_full_path)) {
$message = __('File is successfully uploaded.', $domain);
echo '<div id="message" class="updated fade">'.$message.'</div>'; echo '<div id="message" class="updated fade">'.$message.'</div>';
chmod(SQLitePatchDir.'/'.$_FILES['upfile']['name'], 0644); chmod(SQLitePatchDir.'/'.$_FILES['upfile']['name'], 0606);
} else { } else {
$message = __('File is not uploaded', $domain); $message = __('File upload failed. Possible file upload attack.', $domain);
echo '<div id="message" class="updated fade">'.$message.'</div>'; echo '<div id="message" class="updated fade">'.$message.'</div>';
return false;
} }
} else { } else {
$message = __('File is not selected', $domain); $message = __('File is not selected', $domain);
echo '<div id="message" class="updated fade">'.$message.'</div>'; echo '<div id="message" class="updated fade">'.$message.'</div>';
return false;
} }
return true;
} }
/** /**
* Method to display the patch utility page on the admin panel. * Method to display the patch utility page on the admin panel.
@ -308,7 +359,8 @@ class PatchUtils {
wp_nonce_field('sqlitewordpress-plugin-patch-file-stats'); wp_nonce_field('sqlitewordpress-plugin-patch-file-stats');
} }
?> ?>
<label for="upload"><?php _e('Select file from your computer. If the file name is the same as existent file, this operation will override it.', $domain);?></label><br /> <input type="hidden" name="MAX_FILE_SIZE" value="500000" />
<label for="upload"><?php _e('Select file from your computer. If the file name is the same as existent file, this operation will override it. You can\'t upload the file whose size is over 500kB.', $domain);?></label><br />
<input type="file" id="upload" name="upfile" size="60"/> <input type="file" id="upload" name="upfile" size="60"/>
<input type="submit" name="upload" id="submit-upload" class="button" value="<?php _e('Upload', $domain)?>" /> <input type="submit" name="upload" id="submit-upload" class="button" value="<?php _e('Upload', $domain)?>" />
</form> </form>

View File

@ -1,4 +1,18 @@
[ [
{
"name":"Add Meta Tags",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"Advanced Sitemap Generator",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"Akismet", "name":"Akismet",
"compat":"Checked", "compat":"Checked",
@ -11,18 +25,46 @@
"class":"compatible" "class":"compatible"
}, },
{
"name":"All In One WP Security & Firewall",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"Anti-spam",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"Any Mobile Theme Switcher", "name":"Any Mobile Theme Switcher",
"compat":"Checked", "compat":"Checked",
"class":"compatible" "class":"compatible"
}, },
{
"name":"Batcache",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"BAW Manual Related Posts", "name":"BAW Manual Related Posts",
"compat":"Checked", "compat":"Checked",
"class":"compatible" "class":"compatible"
}, },
{
"name":"bbPress",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"Better Delete Revision", "name":"Better Delete Revision",
"compat":"No", "compat":"No",
@ -37,6 +79,20 @@
"class":"incompatible" "class":"incompatible"
}, },
{
"name":"Better WP Security",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WP Bit.ly",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"Breadcrumb NavXT", "name":"Breadcrumb NavXT",
"compat":"Checked", "compat":"Checked",
@ -55,6 +111,20 @@
"class":"compatible" "class":"compatible"
}, },
{
"name":"BuddyPress",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"BuddyPress Courseware",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"Camera slideshow", "name":"Camera slideshow",
"compat":"Needs Patch", "compat":"Needs Patch",
@ -63,12 +133,40 @@
"class":"workaround" "class":"workaround"
}, },
{
"name":"Cart66 Cloud :: Ecommerce with security",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"Cart66 Lite :: WordPress Ecommerce",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"Category Order and Taxonomy Terms Order", "name":"Category Order and Taxonomy Terms Order",
"compat":"Checked", "compat":"Checked",
"class":"compatible" "class":"compatible"
}, },
{
"name":"CKEditor For WordPress",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"configure-login-timeout",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"Contact Form 7", "name":"Contact Form 7",
"compat":"Checked", "compat":"Checked",
@ -81,12 +179,61 @@
"class":"compatible" "class":"compatible"
}, },
{
"name":"Control XML-RPC publishing",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"Count per Day",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"Crayon Syntax Highlighter", "name":"Crayon Syntax Highlighter",
"compat":"Checked", "compat":"Checked",
"class":"compatible" "class":"compatible"
}, },
{
"name":"Custom Post type and short code",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"Custom Content Shortcode",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"Custom Field List Widget",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"Custom Meta Widget",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"Custom sidebars",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"DB Cache Reloaded Fix", "name":"DB Cache Reloaded Fix",
"compat":"Probably No", "compat":"Probably No",
@ -112,12 +259,68 @@
"class":"compatible" "class":"compatible"
}, },
{
"name":"Disable XML-RPC",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"Download Button Shortcode",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WordPress Download Manager",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"Dynamic To Top", "name":"Dynamic To Top",
"compat":"Checked", "compat":"Checked",
"class":"compatible" "class":"compatible"
}, },
{
"name":"Easy Digital Downloads",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"Easy WP SMTP",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"EDD Hide Download",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"eShop",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"Facebook",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"FeedWordPress", "name":"FeedWordPress",
"compat":"Needs patch", "compat":"Needs patch",
@ -126,12 +329,26 @@
"class":"workaround" "class":"workaround"
}, },
{
"name":"FlexiCache",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"Google Analyticator", "name":"Google Analyticator",
"compat":"Checked", "compat":"Checked",
"class":"compatible" "class":"compatible"
}, },
{
"name":"Google Analytics for WordPress",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"Google Analytics Popular Posts", "name":"Google Analytics Popular Posts",
"compat":"Checked", "compat":"Checked",
@ -152,6 +369,13 @@
"class":"compatible" "class":"compatible"
}, },
{
"name":"HTTP Digest Authentication",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"HyperDB", "name":"HyperDB",
"compat":"Probably No", "compat":"Probably No",
@ -165,6 +389,13 @@
"class":"compatible" "class":"compatible"
}, },
{
"name":"Jigoshop",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"Ktai Style", "name":"Ktai Style",
"compat":"Checked", "compat":"Checked",
@ -177,18 +408,81 @@
"class":"compatible" "class":"compatible"
}, },
{
"name":"Login Only 1 Session",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"Mass Email To users",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"Mathjax Latex", "name":"Mathjax Latex",
"compat":"Checked", "compat":"Checked",
"class":"compatible" "class":"compatible"
}, },
{
"name":"Members",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"Members Category",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"MP6", "name":"MP6",
"compat":"Checked", "compat":"Checked",
"class":"compatible" "class":"compatible"
}, },
{
"name":"Multisite Global Search",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"Multisite User Management",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"MW WP Form",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"My Content Management",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"Networks for WordPress",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"NewStatPress", "name":"NewStatPress",
"compat":"Needs Patch", "compat":"Needs Patch",
@ -199,12 +493,19 @@
{ {
"name":"NextGEN Gallery", "name":"NextGEN Gallery",
"compat":"Needs patch", "compat":"Needs Patch",
"patch_url":"http://dogwood.skr.jp/wordpress/plugins/", "patch_url":"http://dogwood.skr.jp/wordpress/plugins/",
"reason":"MySQL specific function", "reason":"MySQL specific function",
"class":"workaround" "class":"workaround"
}, },
{
"name":"StatCounter - Free Real Time Visitor Stats",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"Optimize Database after Deleting Revisions", "name":"Optimize Database after Deleting Revisions",
"compat":"Probably No", "compat":"Probably No",
@ -212,12 +513,61 @@
"class":"workaround" "class":"workaround"
}, },
{
"name":"Options Framework",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"OSE Firewall™ Security",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"Page Builder by SiteOrigin",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"PDF.js Viewer Shortcode",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"PHP Code Widget",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"Polylang", "name":"Polylang",
"compat":"Checked", "compat":"Checked",
"class":"compatible" "class":"compatible"
}, },
{
"name":"Prevent XMLRPC",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"Qikmo Mobile Website Redirection",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"Redirection", "name":"Redirection",
"compat":"Checked", "compat":"Checked",
@ -236,6 +586,13 @@
"class":"compatible" "class":"compatible"
}, },
{
"name":"Safer Cookies",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"Search Everything", "name":"Search Everything",
"compat":"Checked", "compat":"Checked",
@ -248,42 +605,203 @@
"class":"compatible" "class":"compatible"
}, },
{
"name":"Sell Downloads",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"Session Manager",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"Simple Session Support",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"Simple Tags",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"Smart Donations",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"Socializer!",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"SQLite Integration", "name":"SQLite Integration",
"compat":"Checked", "compat":"Checked",
"class":"compatible" "class":"compatible"
}, },
{
"name":"StatPress",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"Synchi", "name":"Synchi",
"compat":"Checked", "compat":"Checked",
"class":"compatible" "class":"compatible"
}, },
{
"name":"SysInfo",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"System information",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"Theme-Check", "name":"Theme-Check",
"compat":"Checked", "compat":"Checked",
"class":"compatible" "class":"compatible"
}, },
{
"name":"Theme My Login",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"Welcart e-Commerce",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"Wikiful Mediawiki Bridge",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WooCommerce - excelling eCommerce",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"Wordfence Security", "name":"Wordfence Security",
"compat":"Checked", "compat":"Checked",
"class":"compatible" "class":"compatible"
}, },
{
"name":"WordPress Advanced Ticket System",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WP Attachments",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"WordPress Beta Tester", "name":"WordPress Beta Tester",
"compat":"Checked", "compat":"Checked",
"class":"compatible" "class":"compatible"
}, },
{
"name":"WP Campaign Manager",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WordPress.com Custom CSS",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WordPress.com Stats",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WordPress Hit Counter",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"WordPress Importer", "name":"WordPress Importer",
"compat":"Checked", "compat":"Checked",
"class":"compatible" "class":"compatible"
}, },
{
"name":"WordPress Login Redirect",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WordPress Mobile Pack",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WordPress MU Domain Mapping",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WordPress MU Sitewide Tags Pages",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"Wordpress Popular Posts", "name":"Wordpress Popular Posts",
"compat":"Needs Patch", "compat":"Needs Patch",
@ -298,18 +816,123 @@
"class":"compatible" "class":"compatible"
}, },
{
"name":"WordPress SEO by Yoast",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WP Document Revisions",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WP e-Commerce",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WP Email Login",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"WP Emmet", "name":"WP Emmet",
"compat":"Checked", "compat":"Checked",
"class":"compatible" "class":"compatible"
}, },
{
"name":"WP Custom Login",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WP Frontpage News",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WP iSell Photo",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WP Mail SMTP",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WP-Members",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WP-Piwik",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WPtap Mobile Detector",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WP Mobile Edition",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WP Mobile Theme Switcher",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WP-Mobilizer",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"WP Multibyte Patch", "name":"WP Multibyte Patch",
"compat":"Checked", "compat":"Checked",
"class":"compatible" "class":"compatible"
}, },
{
"name":"WP Online Store",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"WP-PageNavi", "name":"WP-PageNavi",
"compat":"Checked", "compat":"Checked",
@ -334,24 +957,94 @@
"class":"compatible" "class":"compatible"
}, },
{
"name":"WP Session Manager",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"WP Social Bookmarking Light", "name":"WP Social Bookmarking Light",
"compat":"Checked", "compat":"Checked",
"class":"compatible" "class":"compatible"
}, },
{
"name":"WP-Statistics",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"WP Super Cache", "name":"WP Super Cache",
"compat":"Checked", "compat":"Checked",
"class":"compatible" "class":"compatible"
}, },
{
"name":"WP System Health",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"WP Video Lightbox", "name":"WP Video Lightbox",
"compat":"Checked", "compat":"Checked",
"class":"compatible" "class":"compatible"
}, },
{
"name":"wp-webservices",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WP Document Revisions Simple Downloads",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WP Marketplace - Complete Shopping Cart / eCommerce Solution",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WordPress Multi Site Mobile Edition",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WPQuery Shortcode",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WP Social Stats",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{
"name":"WPtouch Mobile Plugin",
"compat":"Checked",
"class":"compatible",
"informed":"Users' Information"
},
{ {
"name":"Wysija Newsletters", "name":"Wysija Newsletters",
"compat":"Needs Patch", "compat":"Needs Patch",

View File

@ -306,7 +306,11 @@ class SQLiteIntegrationUtils {
$compat = __('No', $domain); $compat = __('No', $domain);
break; break;
case 'Checked': case 'Checked':
if (!empty($plugin_info->informed) && stripos($plugin_info->informed, 'Users\' Information') !== false) {
$compat = __('Checked*', $domain);
} else {
$compat = __('Checked', $domain); $compat = __('Checked', $domain);
}
break; break;
default: default:
$compat = __('Not Checked', $domain); $compat = __('Not Checked', $domain);
@ -416,6 +420,7 @@ class SQLiteIntegrationUtils {
* @access private * @access private
*/ */
private function backup_db() { private function backup_db() {
$domain = $this->text_domain;
$result = array(); $result = array();
$database_file = FQDB; $database_file = FQDB;
$db_name = basename(FQDB); $db_name = basename(FQDB);
@ -447,12 +452,13 @@ class SQLiteIntegrationUtils {
/** /**
* Method to delete backup database file(s). * Method to delete backup database file(s).
* *
* @return boolean|string * Users can delete multiple files at a time.
*
* @return false if file names aren't checked, empty array if failed, array of messages if succeeded.
* @access private * @access private
*/ */
private function delete_backup_db() { private function delete_backup_db() {
global $utils; $domain = $this->text_domain;
$domain = $utils->text_domain;
$file_names = array(); $file_names = array();
$results = array(); $results = array();
if (isset($_POST['backup_checked'])) { if (isset($_POST['backup_checked'])) {
@ -471,6 +477,53 @@ class SQLiteIntegrationUtils {
} }
return $results; return $results;
} }
/**
* Method to download a backup file.
*
* This method uses header() function, so we have to register this function using
* admin_init action hook. It must also be declared as public. We check HTTP_REFERER
* and input button name, and ,after that, wp_nonce. When the admin_init is executed
* it only returns true.
*
* The database file might be several hundred mega bytes, so we don't use readfile()
* but use fread() instead.
*
* Users can download one file at a time.
*
* @return 1 if the file name isn't checked, 2 if multiple files are checked, true if succeeded.
*/
static function download_backup_db() {
if (is_multisite()) {
$script_url = network_admin_url('settings.php?page=setting-file');
} else {
$script_url = admin_url('options-general.php?page=setting-file');
}
if (isset($_POST['download_backup_file']) && stripos($_SERVER['HTTP_REFERER'], $script_url) !== false) {
check_admin_referer('sqliteintegration-backup-manip-stats');
if (!isset($_POST['backup_checked'])) return 1;
$file_names = array();
$file_names = $_POST['backup_checked'];
if (count($file_names) != 1) return 2;
$file_name = $file_names[0];
$file_path = FQDBDIR . $file_name;
$download_file_name = get_bloginfo('name') . '_' . $file_name;
header('Pragma: public');
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='.$download_file_name.';');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.filesize($file_path));
$fp = fopen($file_path, 'r');
while (!feof($fp)) {
echo fread($fp, 65536);
flush();
}
fclose($fp);
}
return true;
}
/** /**
* Method to show Welcome page. * Method to show Welcome page.
* *
@ -705,6 +758,9 @@ class SQLiteIntegrationUtils {
<?php $this->show_plugins_info();?> <?php $this->show_plugins_info();?>
</tbody> </tbody>
</table> </table>
<p>
<?php _e('"Checked*" with an asterisk is from the users\' information. I didn\'t check myself yet. If you found any malfunctioning, please let me know.', $domain);?>
</p>
</div> </div>
<?php endif; <?php endif;
} }
@ -788,6 +844,24 @@ class SQLiteIntegrationUtils {
echo '<div id="message" class="updated fade">'.$message.'</div>'; echo '<div id="message" class="updated fade">'.$message.'</div>';
} }
} }
if (isset($_POST['download_backup_file'])) {
check_admin_referer('sqliteintegration-backup-manip-stats');
$message = '';
$result = self::download_backup_db();
if ($result !== true) {
switch($result) {
case 1:
$message = __('Please select backup file.', $domain);
break;
case 2:
$message = __('Please select one file at a time.', $domain);
break;
default:
break;
}
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">
@ -820,6 +894,9 @@ class SQLiteIntegrationUtils {
<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);?> <?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> </p>
<p>
<?php _e('If you want to download a file, check the file name and click the Download button. Please check one file at a time.', $domain);?>
</p>
<?php $backup_files = $this->get_backup_files();?> <?php $backup_files = $this->get_backup_files();?>
<form action="" method="post" id="delete-backup-form"> <form action="" method="post" id="delete-backup-form">
<?php if (function_exists('wp_nonce_field')) { <?php if (function_exists('wp_nonce_field')) {
@ -829,7 +906,7 @@ class SQLiteIntegrationUtils {
<table class="widefat page fixed" id="backup-files"> <table class="widefat page fixed" id="backup-files">
<thead> <thead>
<tr> <tr>
<th class="item"><?php _e('Delete', $domain);?></th> <th class="item"><?php _e('Delete/Download', $domain);?></th>
<th data-sort='{"key":"name"}'><?php _e('Backup Files', $domain);?></th> <th data-sort='{"key":"name"}'><?php _e('Backup Files', $domain);?></th>
</tr> </tr>
</thead> </thead>
@ -847,6 +924,7 @@ class SQLiteIntegrationUtils {
<p> <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="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);?>')" /> <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);?>')" />
<input type="submit" name="download_backup_file" class="button-primary" value="<?php _e('Download', $domain);?>" onclick="return confirm('<?php _e('Are you sure to download backup file?\n\nClick [Cancel] to stop, [OK] to continue.', $domain);?>')"/>
</p> </p>
</form> </form>
<h3><?php _e('SQLite Integration Error Log', $domain);?></h3> <h3><?php _e('SQLite Integration Error Log', $domain);?></h3>