From 4c4d7022a9fc60db3a1cd5502c884b6319c33b0e Mon Sep 17 00:00:00 2001 From: kjmtsh Date: Mon, 21 Apr 2014 19:39:09 +0000 Subject: [PATCH] bug fixes and make compatible with WP Slimstat git-svn-id: https://plugins.svn.wordpress.org/sqlite-integration/trunk@899667 b8457f37-d9ea-0310-8a92-e5e31aec5664 --- db.php | 1 + languages/sqlite-integration-ja.mo | Bin 45120 -> 46535 bytes languages/sqlite-integration-ja.po | 28 +++++++ readme-ja.txt | 6 ++ readme.txt | 10 ++- sqlite-integration.php | 7 +- utilities/utility.php | 114 ++++++++++++++++++++++++----- 7 files changed, 144 insertions(+), 22 deletions(-) diff --git a/db.php b/db.php index 4e5d3b5..6fff34a 100644 --- a/db.php +++ b/db.php @@ -5,6 +5,7 @@ * This file must be placed in the directory wordpress/wp-content/db.php. * WordPress loads this file automatically. * + * @version 1.6.1 * @package SQLite Integration * @author Kojima Toshiyasu * diff --git a/languages/sqlite-integration-ja.mo b/languages/sqlite-integration-ja.mo index 231a9be89397d86e335e17f3ced500479d9ff335..d64b2d508edb809b39ed95433b487cefe8b51072 100644 GIT binary patch delta 6476 zcmZvf349bq7KaN20+Aa+I71^LoJqJ*PC4Wz+#p7dkPI*(%;cDWfHIj0M?%6m+?QMu z1PMq`ITUc$1w~YF5fnvOn*>ln5q4c*k^Np*XT{%Izx?~FS6yB8>eZ{B&haZHPySHS z`)$=yD;4Dds*COhDK)f&Ql~3Pt5TIil&S)&zzVRTZMT9s*gfHB`hNyjVK)v{Y6d(C zXTtV1l_~@GK^gKLcnF?^Pb%eAzFJBJ)36A}z%?)tUW0w$u-ZxuhwI>AcneO2UF&cU z?t(+$LpTD)u!@0jo6VnLE9@@yv?Fd<9(y{h#r!Ihib2Ch$l}#eD4w2xW#M^P4qk?z z!5gqOD?Sva9sjYu9{5)%5&8|v1mz8-s=-=N+9RPXv=fx^d&9EKuSQYn0>{G!a3f?4 zbqqF!m!S+4#Lecg4wM1=Ko+e=LIb8ic0nzNs8l1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5x;+QP|JvVn{u9}++E9?|wbY2_=~zyErJnS!5i!Xz!N&-mk@uzmsJ|TaLx|=hUZ^n|K2%-Sqdi4UT%syE*K9 zC2vNH>47U_x>xij#}$MK9UjD9Dhgm>nL Mi^{ERy6fHl01=+N8~^|S diff --git a/languages/sqlite-integration-ja.po b/languages/sqlite-integration-ja.po index ce3592a..6bb5dad 100644 --- a/languages/sqlite-integration-ja.po +++ b/languages/sqlite-integration-ja.po @@ -1313,3 +1313,31 @@ msgstr "ヌル" msgid "Default" msgstr "デフォルト" + +msgid "" +"Upgrading Notice: To finish upgrading, please activate SQLite Integration " +"and go Setting >> SQLite Integration >> Miscellaneous, and click the button "update" at" +" the bottom of the page. Or else replace wp-content/db.php with the one in sqlite-integration " +"directory manually." +msgstr "" +"注意: アップグレードを完了するには、SQLite Integration を有効化して、設定 >> SQLite Integration >> いろいろ " +"ページに移り、ページの最下段にある「更新」ボタンをクリックしてください。あるいは、wp-content/db.php を sqlite-integration " +"ディレクトリにある db.php で上書きしてください。" + +msgid "Update db.php" +msgstr "db.php のアップデート" + +msgid "Replace the old db.php with the new one." +msgstr "古い db.php を新しいファイルと入れ替えます。" + +msgid "Update" +msgstr "更新" + +msgid "Are you sure to update this file?\n\nClick [Cancel] to stop, [OK] to continue." +msgstr "このファイルを更新してもいいですか。\n\nやめるなら [Cancel] を、続けるなら [OK] をクリックしてください。" + +msgid "Your db.php is updated." +msgstr "db.php がアップデートされました。" + +msgid "Couldn"t update db.php file. Please replace it manually." +msgstr "db.php ファイルをアップデートできませんでした。手動で置き換えてください。" diff --git a/readme-ja.txt b/readme-ja.txt index 6609d0a..834273f 100644 --- a/readme-ja.txt +++ b/readme-ja.txt @@ -161,6 +161,12 @@ query_posts() や WP_Query() を使うときに、オプションの一部が機 == Changelog == += 1.6.1 (2014-04-22) = +* WP Slimstat を使うために、いくつかのバグを修正しました。 +* 古い db.php を使い続けている場合は、ダッシュボードに注意を表示するようにしました(必要な場合のみ)。 +* 古い db.php を新しいものを置き換えるユーティリティを追加しました。 +* 日本語カタログファイルをアップデートしました。 + = 1.6 (2014-04-17) = * 未対応のクエリに対するエラーメッセージのコントロールができていないのを修正しました。 * SQL_CALC_FOUND_ROW ステートメントのバグを修正しました。メインクエリと WP_Query、WP_Meta_Query などのページング情報に関連したものです。 diff --git a/readme.txt b/readme.txt index 9c55059..ab3f5c5 100644 --- a/readme.txt +++ b/readme.txt @@ -7,7 +7,7 @@ Author: Kojima Toshiyasu Author URI: http://dogwood.skr.jp/ Requires at least: 3.3 Tested up to: 3.9 -Stable tag: 1.6 +Stable tag: 1.6.1 License: GPLv2 License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -155,10 +155,16 @@ This plugin doesn't support 'WP_PLUGIN_URL' constant. == Upgrade Notice == -When query_posts() or WP_Query() is used, some options didn't work properly. When you post comments, the back quotes in the content was removed. These bugs and some minor ones are fixed. Documentations and doc strings are revised. WordPress 3.9 beta was tested. When auto upgrading fails, please try manual upgrade via FTP. +When query_posts() or WP_Query() is used, some options didn't work properly. When you post comments, the back quotes in the content was removed. These bugs and some minor ones are fixed. Documentations and doc strings are revised. WordPress 3.9 was tested. When auto upgrading fails, please try manual upgrade via FTP. == Changelog == += 1.6.1 (2014-04-22) = +* Fixed some bugs for using with WP Slimstat plugin. +* Display admin notice when not replacing the old db.php with the new one (when necessary). +* Add the feature for replacing the old db.php file with the button click. +* Fixed the Japanese translation catalog file. + = 1.6 (2014-04-17) = * Fixed the bug of error messaging control for the unknown query. * Fixed the bug for 'SQL_CALC_FOUND_ROW' statement. This is for the main query, WP_Query class and WP_Meta_Query concerning paging information. diff --git a/sqlite-integration.php b/sqlite-integration.php index 7cfacc7..17d7588 100644 --- a/sqlite-integration.php +++ b/sqlite-integration.php @@ -4,14 +4,14 @@ Plugin Name: SQLite Integration Plugin URI: http://dogwood.skr.jp/wordpress/sqlite-integration/ Description: SQLite Integration is the plugin that enables WordPress to use SQLite. If you don't have MySQL and want to build a WordPress website, it's for you. Author: Kojima Toshiyasu -Version: 1.6 +Version: 1.6.1 Author URI: http://dogwood.skr.jp Text Domain: sqlite-integration Domain Path: /languages License: GPL2 or later */ -/* Copyright 2013 Kojima Toshiyasu (email: kjm@dogwood.skr.jp) +/* Copyright 2013-2014 Kojima Toshiyasu (email: kjm@dogwood.skr.jp) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. @@ -44,6 +44,7 @@ $siteurl = get_option('siteurl'); /* * Defines basic constants. */ +define('SQLITE_INTEGRATION_VERSION', '1.6.1'); define('SQLiteDir', dirname(plugin_basename(__FILE__))); define('SQLiteFilePath', dirname(__FILE__)); define('SQLiteDirName', basename(SQLiteFilePath)); @@ -114,8 +115,10 @@ class SQLiteIntegration { } if (function_exists('is_multisite') && is_multisite()) { add_action('network_admin_menu', array($this, 'add_network_pages')); + add_action('network_admin_notices', array('SQLiteIntegrationUtils', 'show_admin_notice')); } else { add_action('admin_menu', array($this, 'add_pages')); + add_action('admin_notices', array('SQLiteIntegrationUtils', 'show_admin_notice')); } // See the docstring for download_backup_db() in utilities/utility.php // We need this registration process. diff --git a/utilities/utility.php b/utilities/utility.php index 6411d1d..d719b10 100644 --- a/utilities/utility.php +++ b/utilities/utility.php @@ -25,6 +25,37 @@ class SQLiteIntegrationUtils { function __construct() { } + /** + * Method to display update notice on the admin dashboard. + * + * Check if db.php file is replaced with the apropriate version, + * and if not, display notice. + * + * + */ + public static function show_admin_notice() { + $notice_string = __('Upgrading Notice: To finish upgrading, please activate SQLite Integration and go Setting >> SQLite Integration >> Miscellaneous, and click the button "update" at the bottom of the page. Or else replace wp-content/db.php with the one in sqlite-integration directory manually.', 'sqlite-integration'); + $current_version = defined('SQLITE_INTEGRATION_VERSION') ? SQLITE_INTEGRATION_VERSION : ''; + if (version_compare($current_version, '1.6.1', '=')) return; + $version = ''; + if (defined('WP_CONTENT_DIR')) { + $path = WP_CONTENT_DIR . '/db.php'; + } else { + $path = ABSPATH . 'wp-content/db.php'; + } + if (!$file_handle = @fopen($path, 'r')) return; + while (($buffer = fgets($file_handle)) !== false) { + if (stripos($buffer, '@version') !== false) { + $version = str_ireplace('*@version ', '', $buffer); + $version = trim($version); + break; + } + } + fclose($file_handle); + if (empty($version) || version_compare($version, $current_version, '<')) { + echo '
'.$notice_string.'
'; + } + } /** * Method to read a error log file and returns its contents. * @@ -176,7 +207,7 @@ class SQLiteIntegrationUtils { * * If this file is not existent, shows message and returns false. * - * @return string|boolean + * @return string * @access private */ private function show_db_php() { @@ -188,14 +219,14 @@ class SQLiteIntegrationUtils { if (file_exists($file)) { if (is_readable($file)) { $contents = file_get_contents($file); - echo $contents; + return $contents; } else { - echo 'file is not readable'; + $contents = 'file is not readable'; } } else { - echo 'file doesn\'t exist'; - return false; + $contents = 'file doesn\'t exist'; } + return $contents; } /** * Method to get the textarea content and write it to db.php file. @@ -224,6 +255,37 @@ class SQLiteIntegrationUtils { fclose($fh); return true; } + /** + * Method to replace the old db.php with the new one. + * + * @return boolean + * @access private + */ + private function update_db_file() { + $new_file = PDODIR . 'db.php'; + if (file_exists($new_file) && is_readable($new_file)) { + $contents = file_get_contents($new_file); + } else { + return false; + } + if (defined('WP_CONTENT_DIR')) { + $path = WP_CONTENT_DIR . '/db.php'; + } else { + $path = ABSPATH . 'wp-content/db.php'; + } + if (($handle = @fopen($path, 'w+')) && flock($handle, LOCK_EX)) { + if (fwrite($handle, $contents) == false) { + flock($handle, LOCK_UN); + fclose($handle); + return false; + } + flock($handle, LOCK_UN); + fclose($handle); + } else { + return false; + } + return true; + } /** * Method to optimize SQLite database. * @@ -863,6 +925,19 @@ class SQLiteIntegrationUtils { echo '
' . $message . '
'; } } + if (isset($_POST['sqliteintegration_update_db_file'])) { + check_admin_referer('sqliteintegration-db-update-stats'); + $result = $this->update_db_file(); + if ($result === false) { + $message = __('Couldn"t update db.php file. Please replace it manually.', $domain); + echo '
'.$message.'
'; + } else { + echo +''; + $message = __('Your db.php is updated.', $domain); + echo '
'.$message.'
'; + } + } if (isset($_GET['page']) && $_GET['page'] == 'setting-file') :?>