tagging version 1.5

git-svn-id: https://plugins.svn.wordpress.org/sqlite-integration/tags/1.5@823588 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
kjmtsh 2013-12-17 02:50:20 +00:00
parent e17d3a382a
commit 91ad2da9d6
45 changed files with 2760 additions and 1138 deletions

21
db.php
View File

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

View File

@ -1,7 +1,6 @@
<?php
/**
* @package SQLite Integration
* @version 1.1
* @author Kojima Toshiyasu, Justin Adie
*
*/
@ -57,7 +56,8 @@ class PDOSQLiteUDFS {
'inet_ntoa' => 'inet_ntoa',
'inet_aton' => 'inet_aton',
'datediff' => 'datediff',
'locate' => 'locate'
'locate' => 'locate',
'version' => 'version'
);
public function month($field){
@ -385,5 +385,12 @@ class PDOSQLiteUDFS {
}
}
}
/**
*
*/
public function version() {
global $required_mysql_version;
return $required_mysql_version;
}
}
?>

View File

@ -1,7 +1,6 @@
<?php
/**
* @package SQLite Integration
* @version 1.1
* @author Kojima Toshiyasu, Justin Adie
*
*/
@ -58,7 +57,8 @@ class PDOSQLiteUDFS {
'inet_ntoa' => 'inet_ntoa',
'inet_aton' => 'inet_aton',
'datediff' => 'datediff',
'locate' => 'locate'
'locate' => 'locate',
'version' => 'version'
);
public function month($field){
@ -359,5 +359,12 @@ class PDOSQLiteUDFS {
}
}
}
/**
*
*/
public function version() {
global $required_mysql_version;
return $required_mysql_version;
}
}
?>

2
index.php Normal file
View File

@ -0,0 +1,2 @@
<?php
/* Silence is golden */

View File

@ -1,14 +1,17 @@
<?php
/**
* @package SQLite Integration
* @version 1.1
* @author Kojima Toshiyasu, Justin Adie
*
*/
/**
* This function overrides wp_install() in wp-admin/upgrade.php
* This function overrides wp_install() in wp-admin/includes/upgrade.php
*/
if (!defined('ABSPATH')) {
echo 'Thank you, but you are not allowed to access this file.';
die();
}
function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '') {
if (!empty($deprecated))
_deprecated_argument(__FUNCTION__, '2.6');
@ -57,7 +60,16 @@ function wp_install($blog_title, $user_name, $user_email, $public, $deprecated =
wp_new_blog_notification($blog_title, $guessurl, $user_id, ($email_password ? $user_password : __('The password you chose during the install.')));
wp_cache_flush();
if (isset($_SERVER['SERVER_SOFTWARE']) && stripos($_SERVER['SERVER_SOFTWARE'], 'apache') !== false || isset($_SERVER['SERVER_SIGNATURE']) && stripos($_SERVER['SERVER_SIGNATURE'], 'apache') !== false) {
;// Your server is Apache. Nothing to do more.
} else {
$server_message = sprintf('Your webserver doesn\'t seem to be Apache. So the database directory access restriction by the .htaccess file may not function. We strongly recommend that you should restrict the access to the directory %s in some other way.', FQDBDIR);
echo '<div style="position: absolute; margin-top: 250px; width: 700px; border: .5px dashed rgb(0, 0, 0);"><p style="margin: 10px;">';
echo $server_message;
echo '</p></div>';
}
return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
}
?>

2
js/index.php Normal file
View File

@ -0,0 +1,2 @@
<?php
/* Silence is golden */

View File

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

1
js/sqlite.min.js vendored Normal file
View File

@ -0,0 +1 @@
jQuery(document).ready(function($){function stripe(arg){$(arg).find("tr.alt").removeClass("alt");var $args=arg+" tbody";$($args).each(function(){$(this).children(":visible").has("td").filter(function(index){return 1==index%2}).addClass("alt")})}var $table=null,$headers=null;null!=document.getElementById("sqlite-table")?($table=$("#sqlite-table"),$headers=$table.find("thead th").slice(0,2)):null!=document.getElementById("plugins-table")?($table=$("#plugins-table"),$headers=$table.find("thead th").slice(0)):null!=document.getElementById("patch-files")?($table=$("#patch-files"),$headers=$table.find("thead th").slice(1)):null!=document.getElementById("backup-files")&&($table=$("#backup-files"),$headers=$table.find("thead th").slice(1)),$headers.wrapInner('<a href="#"></a>').addClass("sort");var rows=$table.find("tbody > tr").get();$headers.bind("click",function(event){event.preventDefault();var $header=$(this),sortKey=$header.data("sort").key,sortDirection=1;$header.hasClass("sorted-asc")&&(sortDirection=-1),rows.sort(function(a,b){var keyA=$(a).data("table")[sortKey],keyB=$(b).data("table")[sortKey];return keyB>keyA?-sortDirection:keyA>keyB?sortDirection:0}),$headers.removeClass("sorted-asc sortd-desc"),$headers.addClass(1==sortDirection?"sorted-asc":"sorted-desc"),$.each(rows,function(index,row){$table.children("tbody").append(row)}),stripe("#plugins-table"),stripe("#sqlite-table"),stripe("#patch-files")}),stripe("#plugins-table"),stripe("#sys-info"),stripe("#sqlite-table"),stripe("#status"),stripe("#patch-files")}),jQuery(document).ready(function($){function stripe(arg){$(arg).find("tr.alt").removeClass("alt");var $args=arg+" tbody";$($args).each(function(){$(this).children(":visible").has("td").filter(function(index){return 1==index%2}).addClass("alt")})}var $table=$("#plugins-info"),$headers=$table.find("thead th").slice(0);$headers.wrapInner('<a href="#"></a>').addClass("sort");var rows=$table.find("tbody > tr").get();$headers.bind("click",function(event){event.preventDefault();var $header=$(this),sortKey=$header.data("sort").key,sortDirection=1;$header.hasClass("sorted-asc")&&(sortDirection=-1),rows.sort(function(a,b){var keyA=$(a).data("table")[sortKey],keyB=$(b).data("table")[sortKey];return keyB>keyA?-sortDirection:keyA>keyB?sortDirection:0}),$headers.removeClass("sorted-asc sortd-desc"),$headers.addClass(1==sortDirection?"sorted-asc":"sorted-desc"),$.each(rows,function(index,row){$table.children("tbody").append(row)}),stripe("#plugins-info")}),stripe("#plugins-info")});

2
languages/index.php Normal file
View File

@ -0,0 +1,2 @@
<?php
/* Silence is golden */

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,13 @@
<?php
/**
* @package SQLite Integration
* @version 1.1
* @author Kojima Toshiyasu, Justin Adie
*
*/
if (!defined('ABSPATH')) {
echo 'Thank you, but you are not allowed to accesss this file.';
die();
}
require_once PDODIR . 'pdoengine.class.php';
require_once PDODIR . 'install.php';
@ -46,6 +48,16 @@ class PDODB extends wpdb {
return true;
}
/**
* dummy out the MySQL function
* @see wpdb::set_charset()
*/
function set_charset($dbh, $charset = null, $collate = null) {
if ( ! isset( $charset ) )
$charset = $this->charset;
if ( ! isset( $collate ) )
$collate = $this->collate;
}
/**
* dummy out the MySQL function
* @see wpdb::select()
@ -62,10 +74,7 @@ class PDODB extends wpdb {
* @see wpdb::_real_escape()
*/
function _real_escape($string) {
if ($this->dbh && $this->real_escape)
return $this->dbh->quote($string);
else
return addslashes($string);
return addslashes($string);
}
/**
@ -77,7 +86,7 @@ class PDODB extends wpdb {
if (!$str) {
$err = $this->dbh->get_error_message() ? $this->dbh->get_error_message() : '';
$str = $err[2];
if (!empty($err)) $str = $err[2]; else $str = '';
}
$EZSQL_ERROR[] = array('query' => $this->last_query, 'error_str' => $str);

View File

@ -1,7 +1,6 @@
<?php
/**
* @package SQLite Integration
* @version 1.1
* @author Kojima Toshiyasu, Justin Adie
*
*/
@ -35,7 +34,7 @@ class PDOEngine extends PDO {
/**
* Constructor
* @param array $DatabaseParams
* @param
*/
function __construct() {
$this->init();
@ -80,8 +79,8 @@ class PDOEngine extends PDO {
if ($status == 5 || $status == 6) {
$locked = true;
} else {
$message = __("Database connection error!<br />", 'sqlite-integration');
$message .= sprintf(__("Error message is: %s", 'sqlite-integration'), $err->getMessage());
$message = 'Database connection error!<br />';
$message .= sprintf("Error message is: %s", $err->getMessage());
$this->set_error(__LINE__, __FUNCTION__, $message);
return false;
}
@ -96,8 +95,8 @@ class PDOEngine extends PDO {
try {
$this->pdo = new PDO($dsn, null, null, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
} catch (PDOException $err) {
$message = __("Database connection error!<br />", 'sqlite-integration');
$message .= sprintf(__("Error message is: %s", 'sqlite-integration'), $err->getMessage());
$message = 'Database initialization error!<br />';
$message .= sprintf("Error message is: %s", $err->getMessage());
$this->set_error(__LINE__, __FUNCTION__, $message);
return false;
}
@ -113,16 +112,16 @@ class PDOEngine extends PDO {
global $wpdb;
$u = umask(0000);
if (!is_dir(FQDBDIR)) {
if (!@mkdir(FQDBDIR, 0777, true)) {
if (!@mkdir(FQDBDIR, 0707, true)) {
umask($u);
$message = __('Unable to create the required directory! Please check your server settings.', 'sqlite-integration');
$message = 'Unable to create the required directory! Please check your server settings.';
echo $message;
return false;
}
}
if (!is_writable(FQDBDIR)) {
umask($u);
$message = __('Unable to create a file in the directory! Please check your server settings.', 'sqlite-integration');
$message = 'Unable to create a file in the directory! Please check your server settings.';
echo $message;
return false;
}
@ -130,11 +129,11 @@ class PDOEngine extends PDO {
$fh = fopen(FQDBDIR . '.htaccess', "w");
if (!$fh) {
umask($u);
$message = __('Unable to create a file in the directory! Please check your server settings.', 'sqlite-integration');
$message = 'Unable to create a file in the directory! Please check your server settings.';
echo $message;
return false;
}
fwrite($fh, "DENY FROM ALL");
fwrite($fh, 'DENY FROM ALL');
fclose($fh);
}
umask($u);
@ -145,7 +144,7 @@ class PDOEngine extends PDO {
* executed once while installation process
*/
private function make_sqlite_tables() {
require_once PDODIR . "install.php";
require_once PDODIR . 'install.php';
}
public function query($query) {
@ -253,7 +252,7 @@ class PDOEngine extends PDO {
ob_start();
debug_print_backtrace();
$output .= "<pre>" . ob_get_contents() . "</pre>";
$output .= '<pre>' . ob_get_contents() . '</pre>';
ob_end_clean();
return $output;
@ -299,7 +298,7 @@ class PDOEngine extends PDO {
}
private function prepare_query(){
$this->queries[] = "Prepare:\t". $this->prepared_query;
$this->queries[] = 'Prepare: ' . $this->prepared_query;
$reason = 0;
$message = '';
$statement = null;
@ -313,7 +312,7 @@ class PDOEngine extends PDO {
} while (5 == $reason || 6 == $reason);
if ($reason > 0){
$err_message = sprintf(__("Problem preparing the PDO SQL Statement. Error was: %s", 'sqlite-integration'), $message);
$err_message = sprintf("Problem preparing the PDO SQL Statement. Error was: %s", $message);
$this->set_error(__LINE__, __FUNCTION__, $err_message);
}
return $statement;
@ -325,7 +324,7 @@ class PDOEngine extends PDO {
if (!is_object($statement))
return;
if (count($this->extracted_variables) > 0) {
$this->queries[] = "Executing: ". var_export($this->extracted_variables, true);
$this->queries[] = 'Executing: ' . var_export($this->extracted_variables, true);
do {
if ($this->query_type == 'update' || $this->query_type == 'replace') {
try {
@ -347,7 +346,7 @@ class PDOEngine extends PDO {
}
} while (5 == $reason || 6 == $reason);
} else {
$this->queries[] = "Executing: (no parameters)\t ";
$this->queries[] = 'Executing: (no parameters)';
do{
if ($this->query_type == 'update' || $this->query_type == 'replace') {
try {
@ -370,7 +369,7 @@ class PDOEngine extends PDO {
} while (5 == $reason || 6 == $reason);
}
if ($reason > 0) {
$err_message = sprintf(__("Error while executing query! Error message was: %s", 'sqlite-integration'), $message);
$err_message = sprintf("Error while executing query! Error message was: %s", $message);
$this->set_error(__LINE__, __FUNCTION__, $err_message);
return false;
} else {
@ -378,32 +377,34 @@ class PDOEngine extends PDO {
}
//generate the results that $wpdb will want to see
switch ($this->query_type) {
case "insert":
case "update":
case "replace":
case 'insert':
case 'update':
case 'replace':
$this->last_insert_id = $this->pdo->lastInsertId();
$this->affected_rows = $statement->rowCount();
$this->return_value = $this->affected_rows;
break;
case "select":
case "show":
case "showcolumns":
case "showindex":
case "describe":
case "desc":
case 'select':
case 'show':
case 'showcolumns':
case 'showindex':
case 'describe':
case 'desc':
case 'check':
case 'analyze':
// case "foundrows":
$this->num_rows = count($this->_results);
$this->return_value = $this->num_rows;
break;
case "delete":
case 'delete':
$this->affected_rows = $statement->rowCount();
$this->return_value = $this->affected_rows;
break;
case "alter":
case "drop":
case "create":
case "optimize":
case "truncate":
case 'alter':
case 'drop':
case 'create':
case 'optimize':
case 'truncate':
if ($this->is_error) {
$this->return_value = false;
} else {
@ -424,7 +425,7 @@ class PDOEngine extends PDO {
$_limit = $limit = ini_get('pcre.backtrack_limit');
do {
if ($limit > 10000000) {
$message = __("The query is too big to parse properly", 'sqlite-integration');
$message = 'The query is too big to parse properly';
$this->set_error(__LINE__, __FUNCTION__, $message);
break; //no point in continuing execution, would get into a loop
} else {
@ -436,7 +437,7 @@ class PDOEngine extends PDO {
//reset the pcre.backtrack_limist
ini_set('pcre.backtrack_limit', $_limit);
$this->queries[]= "With Placeholders: $query ";
$this->queries[]= 'With Placeholders: ' . $query;
$this->prepared_query = $query;
}
@ -469,7 +470,7 @@ class PDOEngine extends PDO {
* @return boolean|string
*/
private function determine_query_type($query) {
$result = preg_match('/^\\s*(EXPLAIN|PRAGMA|SELECT\\s*FOUND_ROWS|SELECT|INSERT|UPDATE|REPLACE|DELETE|ALTER|CREATE|DROP\\s*INDEX|DROP|SHOW\\s*\\w+\\s*\\w+\\s*|DESCRIBE|DESC|TRUNCATE|OPTIMIZE)/i', $query, $match);
$result = preg_match('/^\\s*(EXPLAIN|PRAGMA|SELECT\\s*FOUND_ROWS|SELECT|INSERT|UPDATE|REPLACE|DELETE|ALTER|CREATE|DROP\\s*INDEX|DROP|SHOW\\s*\\w+\\s*\\w+\\s*|DESCRIBE|DESC|TRUNCATE|OPTIMIZE|CHECK|ANALYZE)/i', $query, $match);
if (!$result) {
return false;
@ -505,7 +506,7 @@ class PDOEngine extends PDO {
private function execute_insert_query_new($query) {
$engine = $this->prepare_engine($this->query_type);
$this->rewritten_query = $engine->rewrite_query($query, $this->query_type);
$this->queries[] = "Rewritten: $this->rewritten_query";
$this->queries[] = 'Rewritten: ' . $this->rewritten_query;
$this->extract_variables();
$statement = $this->prepare_query();
$this->execute_query($statement);
@ -544,7 +545,7 @@ class PDOEngine extends PDO {
}
$query_string = $query_prefix . ' ' . $value . $suffix;
$this->rewritten_query = $engine->rewrite_query($query_string, $this->query_type);
$this->queries[] = "Rewritten: $this->rewritten_query";
$this->queries[] = 'Rewritten: ' . $this->rewritten_query;
$this->extracted_variables = array();
$this->extract_variables();
if ($first) {
@ -557,7 +558,7 @@ class PDOEngine extends PDO {
}
} else {
$this->rewritten_query = $engine->rewrite_query($query, $this->query_type);
$this->queries[] = "Rewritten: $this->rewritten_query";
$this->queries[] = 'Rewritten: ' . $this->rewritten_query;
$this->extract_variables();
$statement = $this->prepare_query();
$this->execute_query($statement);
@ -633,7 +634,7 @@ class PDOEngine extends PDO {
}
}
if ($reason > 0) {
$err_message = sprintf(__("Problem in creating table or index. Error was: %s", 'sqlite-integration'), $message);
$err_message = sprintf("Problem in creating table or index. Error was: %s", $message);
$this->set_error(__LINE__, __FUNCTION__, $err_message);
return false;
}
@ -649,7 +650,12 @@ class PDOEngine extends PDO {
$engine = $this->prepare_engine($this->query_type);
$reason = 0;
$message = '';
$re_query = '';
$rewritten_query = $engine->rewrite_query($query, $this->query_type);
if (is_array($rewritten_query) && array_key_exists('recursion', $rewritten_query)) {
$re_query = $rewritten_query['recursion'];
unset($rewritten_query['recursion']);
}
try {
$this->beginTransaction();
if (is_array($rewritten_query)) {
@ -675,8 +681,11 @@ class PDOEngine extends PDO {
$this->rollBack();
}
}
if ($re_query != '') {
$this->query($re_query);
}
if ($reason > 0) {
$err_message = sprintf(__("Problem in executing alter query. Error was: %s", 'sqlite-integration'), $message);
$err_message = sprintf("Problem in executing alter query. Error was: %s", $message);
$this->set_error(__LINE__, __FUNCTION__, $err_message);
return false;
}
@ -699,7 +708,11 @@ class PDOEngine extends PDO {
$value = str_replace("'", '', $match[1]);
$dummy_data['Variable_name'] = trim($value);
// this is set for Wordfence Security Plugin
if ($value == 'max_allowed_packet') $dummy_data['Value'] = 1047552;
if ($value == 'max_allowed_packet') {
$dummy_data['Value'] = 1047552;
} else {
$dummy_data['Value'] = '';
}
}
$_results[] = new ObjectArray($dummy_data);
$this->results = $_results;
@ -713,6 +726,8 @@ class PDOEngine extends PDO {
$this->convert_to_columns_object();
} elseif ('showindex' === $this->query_type){
$this->convert_to_index_object();
} elseif (in_array($this->query_type, array('check', 'analyze'))) {
$this->convert_result_check_or_analyze();
} else {
$this->results = $this->_results;
}
@ -774,6 +789,7 @@ class PDOEngine extends PDO {
}
/**
* rewrites the result of SHOW INDEX to the Object compatible with MySQL
* added the WHERE clause manipulation (ver 1.3.1)
*/
private function convert_to_index_object() {
$_results = array();
@ -840,10 +856,44 @@ class PDOEngine extends PDO {
$_columns['Comment'] = '';
$_results[] = new ObjectArray($_columns);
}
if (stripos($this->queries[0], 'WHERE') !== false) {
preg_match('/WHERE\\s*(.*)$/im', $this->queries[0], $match);
list($key, $value) = explode('=', $match[1]);
$key = trim($key);
$value = preg_replace("/[\';]/", '', $value);
$value = trim($value);
foreach ($_results as $result) {
if (stripos($value, $result->$key) !== false) {
unset($_results);
$_results[] = $result;
break;
}
}
}
}
$this->results = $_results;
}
private function convert_result_check_or_analyze() {
$results = array();
if ($this->query_type == 'check') {
$_columns = array(
'Table' => '',
'Op' => 'check',
'Msg_type' => 'status',
'Msg_text' => 'OK'
);
} else {
$_columns = array(
'Table' => '',
'Op' => 'analyze',
'Msg_type' => 'status',
'Msg_text' => 'Table is already up to date'
);
}
$_results[] = new ObjectArray($_columns);
$this->results = $_results;
}
/**
* function to get SQLite library version
* this is used for checking if SQLite can execute multiple rows insert

View File

@ -1,7 +1,6 @@
<?php
/**
* @package SQLite Integration
* @version 1.1
* @author Kojima Toshiyasu, Justin Adie
*/
@ -54,12 +53,15 @@ class PDOSQLiteDriver {
$this->_delete_index_hints();
$this->_rewrite_regexp();
$this->_rewrite_boolean();
$this->_fix_date_quoting();
$this->_rewrite_between();
break;
case 'insert':
$this->_strip_backticks();
$this->_execute_duplicate_key_update();
$this->_rewrite_insert_ignore();
$this->_rewrite_regexp();
$this->_fix_date_quoting();
break;
case 'update':
$this->_strip_backticks();
@ -68,6 +70,7 @@ class PDOSQLiteDriver {
$this->_rewrite_limit_usage();
$this->_rewrite_order_by_usage();
$this->_rewrite_regexp();
$this->_rewrite_between();
break;
case 'delete':
$this->_strip_backticks();
@ -85,7 +88,15 @@ class PDOSQLiteDriver {
case 'optimize':
$this->_rewrite_optimize();
break;
case 'pragma':
break;
default:
if (defined(WP_DEBUG) && WP_DEBUG) {
break;
} else {
$this->_return_true();
break;
}
}
return $this->_query;
}
@ -95,7 +106,7 @@ class PDOSQLiteDriver {
*/
private function _handle_show_query(){
$table_name = '';
$pattern = '/^\\s*SHOW\\s*TABLES\\s*(LIKE\\s*(.*))$/im';
$pattern = '/^\\s*SHOW\\s*TABLES\\s*.*?(LIKE\\s*(.*))$/im';
if (preg_match($pattern, $this->_query, $matches)) {
$table_name = str_replace(array("'", ';'), '', $matches[2]);
}
@ -238,6 +249,11 @@ class PDOSQLiteDriver {
* We need to exclude sub query's LIMIT.
*/
private function _rewrite_limit_usage(){
$_wpdb = new PDODB();
$options = $_wpdb->get_results('PRAGMA compile_options');
foreach ($options as $opt) {
if (stripos($opt->compile_option, 'ENABLE_UPDATE_DELETE_LIMIT') !== false) return;
}
if (stripos($this->_query, '(select') === false) {
$this->_query = preg_replace('/\\s*LIMIT\\s*[0-9]$/i', '', $this->_query);
}
@ -285,25 +301,28 @@ class PDOSQLiteDriver {
* @return void
*/
private function _delete_index_hints(){
$pattern = '/use\s+index\s*\(.*?\)/i';
$pattern = '/\\s*(use|ignore|force)\\s+index\\s*\(.*?\)/i';
$this->_query = preg_replace($pattern, '', $this->_query);
}
/**
* Justin Adie says:
* method to fix inconsistent use of quoted, unquoted etc date values in query function
* this is ironic, given the above rewrite badlyformed dates method
* examples
* Fix the date string and quote. This is required for the calendar widget.
*
* where month(fieldname)=08 becomes month(fieldname)='8'
* where month(fieldname)='08' becomes month(fieldname)='8'
*
* I don't understand...
* I use preg_replace_callback instead of 'e' option because of security reason.
* cf. PHP manual (regular expression)
*
* @return void
*/
private function _fix_date_quoting(){
$pattern = '/(month|year|second|day|minute|hour|dayofmonth)\s*\((.*?)\)\s*=\s*["\']?(\d{1,4})[\'"]?\s*/ei';
$this->_query = preg_replace($pattern, "'\\1(\\2)=\'' . intval('\\3') . '\' ' ", $this->_query);
private function _fix_date_quoting() {
$pattern = '/(month|year|second|day|minute|hour|dayofmonth)\\s*\((.*?)\)\\s*=\\s*["\']?(\d{1,4})[\'"]?\\s*/im';
$this->_query = preg_replace_callback($pattern, array($this, '__fix_date_quoting'), $this->_query);
}
private function __fix_date_quoting($match) {
$fixed_val = "{$match[1]}({$match[2]})='" . intval($match[3]) . "' ";
return $fixed_val;
}
private function _rewrite_regexp(){
@ -341,28 +360,12 @@ class PDOSQLiteDriver {
/**
* method to execute SHOW INDEX query
* Moved the WHERE clause manipulation to pdoengin.class.php (ver 1.3.1)
*/
private function _handle_show_index() {
$_columns = array(// No, you'll get no meaningful information..
'Key_name' => 'name',
);
$pattern_0 = '/^\\s*SHOW\\s*(?:INDEX|INDEXES|KEYS)\\s*FROM\\s*(\\w+)?\\s*WHERE\\s*(.*)$/im';
$pattern_1 = '/^\\s*SHOW\\s*(?:INDEX|INDEXES|KEYS)\\s*FROM\\s*(\\w+)?/im';
if (preg_match($pattern_0, $this->_query, $match_0)) {
$table_name = str_replace("'", '', $match_0[1]);
list($key, $value) = explode('=', $match_0[2]);
$key = trim($key);
$value = preg_replace("/[\';]/", '', $value);
$value = trim($value);
if (array_key_exists($key, $_columns)) {
$key = $_columns[$key];
$where_clause = 'AND ' . $key . ' LIKE ' . "'" . $value . "%'";
} else {
$where_clause = '';
}
$this->_query = "SELECT * FROM sqlite_master WHERE tbl_name='$table_name' $where_clause";
} elseif (preg_match($pattern_1, $this->_query, $match_1)) {
$table_name = preg_replace("/[\';]/", '', $match_1[1]);
$pattern = '/^\\s*SHOW\\s*(?:INDEX|INDEXES|KEYS)\\s*FROM\\s*(\\w+)?/im';
if (preg_match($pattern, $this->_query, $match)) {
$table_name = preg_replace("/[\';]/", '', $match[1]);
$table_name = trim($table_name);
$this->_query = "SELECT * FROM sqlite_master WHERE tbl_name='$table_name'";
}
@ -408,7 +411,7 @@ class PDOSQLiteDriver {
return;
}
// data check
if (preg_match('/^\((.*)\)\\s*VALUES\\s*\((.*)\)$/im', $insert_data, $match_1)) {
if (preg_match('/^\((.*)\)\\s*VALUES\\s*\((.*)\)$/ims', $insert_data, $match_1)) {
$col_array = explode(',', $match_1[1]);
$ins_data_array = explode(',', $match_1[2]);
foreach ($col_array as $col) {
@ -498,15 +501,45 @@ class PDOSQLiteDriver {
$this->_query = $update_query;
}
}
} else {
// wordaround...
$pattern = '/ ON DUPLICATE KEY UPDATE.*$/im';
$replace_query = preg_replace($pattern, '', $this->_query);
$replace_query = str_ireplace('INSERT ', 'INSERT OR REPLACE ', $replace_query);
$this->_query = $replace_query;
}
// else {
// $pattern = '/ ON DUPLICATE KEY UPDATE.*$/im';
// $replace_query = preg_replace($pattern, '', $this->_query);
// $replace_query = str_ireplace('INSERT ', 'INSERT OR REPLACE ', $replace_query);
// $this->_query = $replace_query;
// }
}
private function _rewrite_between() {
$pattern = '/\\s*(\\w+)?\\s*BETWEEN\\s*([^\\s]*)?\\s*AND\\s*([^\\s]*)?\\s*/ims';
if (preg_match($pattern, $this->_query, $match)) {
$column_name = trim($match[1]);
$min_value = trim($match[2]);
$max_value = trim($match[3]);
$max_value = rtrim($max_value);
$tokens = preg_split("/(''|'|,|)/s", $this->_query, -1, PREG_SPLIT_DELIM_CAPTURE);
$literal = false;
$rewriting = false;
foreach ($tokens as $token) {
if (strpos($token, "'") !== false) {
if ($literal) {
$literal = false;
} else {
$literal = true;
}
} else {
if ($literal === false && stripos($token, 'between') !== false) {
$rewriting = true;
break;
}
}
}
if ($rewriting) {
$replacement = " $column_name >= '$min_value' AND $column_name <= '$max_value'";
$this->_query = str_ireplace($match[0], $replacement, $this->_query);
}
}
}
/**
* workaround function to avoid DELETE with JOIN
* wp-admin/includes/upgrade.php contains 'DELETE ... JOIN' statement.
@ -522,5 +555,11 @@ class PDOSQLiteDriver {
$this->_query = $rewritten;
}
}
/**
*
*/
private function _return_true() {
$this->_query = 'SELECT 1=1';
}
}
?>

View File

@ -3,56 +3,71 @@
* The class for manipulating ALTER query
* newly supports multiple variants
* @package SQLite Integration
* @version 1.1
* @author Kojima Toshiyasu
*/
class AlterQuery {
public $_query = null;
public function rewrite_query($query, $query_type) {
$tokens = array();
if (stripos($query, $query_type) === false) {
return false;
}
$query = str_replace('`', '', $query);
if (preg_match('/^\\s*(ALTER\\s*TABLE)\\s*(\\w+)?\\s*/ims', $query, $match)) {
$tmp_query = array();
$tokens = array();
$re_command = '';
$command = str_ireplace($match[0], '', $query);
$tmp_tokens['query_type'] = trim($match[1]);
$tmp_tokens['table_name'] = trim($match[2]);
$command_array = $this->split_multiple($command);
foreach ($command_array as $single_command) {
$command_tokens = $this->command_tokenizer($single_command);
if (!empty($command_tokens)) {
$tokens[] = array_merge($tmp_tokens, $command_tokens);
} else {
$this->_query = 'SELECT 1=1';
}
// $command_array = $this->split_multiple($command);
$command_array = explode(',', $command);
$single_command = array_shift($command_array);
if (!empty($command_array)) {
$re_command = 'ALTER TABLE ' . $tmp_tokens['table_name'] . ' ';
$re_command .= implode(',', $command_array);
}
$command_tokens = $this->command_tokenizer($single_command);
if (!empty($command_tokens)) {
$tokens = array_merge($tmp_tokens, $command_tokens);
} else {
$this->_query = 'SELECT 1=1';
return $this->_query;
}
foreach ($tokens as $token) {
$command_name = $token['command'];
switch ($command_name) {
case 'add column': case 'rename to': case 'add index': case 'drop index':
$this->_query = $this->handle_single_command($token);
break;
case 'add primary key':
$this->_query = $this->handle_add_primary_key($token);
break;
case 'drop primary key':
$this->_query = $this->handle_drop_primary_key($token);
break;
case 'modify column':
$this->_query = $this->handle_modify_command($token);
break;
case 'change column':
$this->_query = $this->handle_change_command($token);
break;
case 'alter column':
$this->_query = $this->handle_alter_command($token);
break;
default:
break;
// foreach ($tokens as $token) {
$command_name = strtolower($tokens['command']);
switch ($command_name) {
case 'add column': case 'rename to': case 'add index': case 'drop index':
$tmp_query = $this->handle_single_command($tokens);
break;
case 'add primary key':
$tmp_query = $this->handle_add_primary_key($tokens);
break;
case 'drop primary key':
$tmp_query = $this->handle_drop_primary_key($tokens);
break;
case 'modify column':
$tmp_query = $this->handle_modify_command($tokens);
break;
case 'change column':
$tmp_query = $this->handle_change_command($tokens);
break;
case 'alter column':
$tmp_query = $this->handle_alter_command($tokens);
break;
default:
break;
}
}
// }
if (!is_array($tmp_query)) {
$this->_query[] = $tmp_query;
} else {
$this->_query = $tmp_query;
}
if ($re_command != '') {
$this->_query = array_merge($this->_query, array('recursion' => $re_command));
}
} else {
$this->_query = 'SELECT 1=1';
}
@ -61,110 +76,125 @@ class AlterQuery {
private function command_tokenizer($command) {
$tokens = array();
if (preg_match('/^(ADD|DROP|RENAME|MODIFY|CHANGE|ALTER)\\s*(\\w+)?\\s*(\\w+)?\\s*/ims', $command, $match)) {
if (preg_match('/^(ADD|DROP|RENAME|MODIFY|CHANGE|ALTER)\\s*(\\w+)?\\s*(\\w+(\(.+\)|))?\\s*/ims', $command, $match)) {
$the_rest = str_ireplace($match[0], '', $command);
$match_1 = strtolower(trim($match[1]));
$match_2 = strtolower(trim($match[2]));
$match_3 = isset($match[3]) ? strtolower(trim($match[3])) : '';
switch ($match_1) {
$match_1 = trim($match[1]);
$match_2 = trim($match[2]);
$match_3 = isset($match[3]) ? trim($match[3]) : '';
switch (strtolower($match_1)) {
case 'add':
if (in_array($match_2, array('fulltext', 'constraint', 'foreign'))) {
if (in_array(strtolower($match_2), array('fulltext', 'constraint', 'foreign'))) {
break;
} elseif ($match_2 == 'column') {
} elseif (stripos('column', $match_2) !== false) {
$tokens['command'] = $match_1.' '.$match_2;
$tokens['column_name'] = $match_3;
$tokens['column_def'] = trim($the_rest);
} elseif ($match_2 == 'primary') {
} elseif (stripos('primary', $match_2) !== false) {
$tokens['command'] = $match_1.' '.$match_2.' '.$match_3;
$tokens['column_name'] = $the_rest;
} elseif ($match_2 == 'unique') {
} elseif (stripos('unique', $match_2) !== false) {
list($index_name, $col_name) = preg_split('/[\(\)]/s', trim($the_rest), -1, PREG_SPLIT_DELIM_CAPTURE);
$tokens['unique'] = true;
$tokens['command'] = $match_1.' '.$match_3;
$tokens['index_name'] = trim($index_name);
$tokens['column_name'] = '('.trim($col_name).')';
} elseif (in_array($match_2, array('index', 'key'))) {
} elseif (in_array(strtolower($match_2), array('index', 'key'))) {
$tokens['command'] = $match_1.' '.$match_2;
$tokens['index_name'] = $match_3;
if ($match_3 == '') {
$tokens['index_name'] = str_replace(array('(', ')'), '', $the_rest);
} else {
$tokens['index_name'] = $match_3;
}
$tokens['column_name'] = trim($the_rest);
} else {
$tokens['command'] = $match_1.' column';
$tokens['command'] = $match_1.' COLUMN';
$tokens['column_name'] = $match_2;
$tokens['column_def'] = $match_3.' '.$the_rest;
}
break;
case 'drop':
if ($match_2 == 'column') {
if (stripos('column', $match_2) !== false) {
$tokens['command'] = $match_1.' '.$match_2;
$tokens['column_name'] = trim($match_3);
} elseif ($match_2 == 'primary') {
} elseif (stripos('primary', $match_2) !== false) {
$tokens['command'] = $match_1.' '.$match_2.' '.$match_3;
} elseif (in_array($match_2, array('index', 'key'))) {
} elseif (in_array(strtolower($match_2), array('index', 'key'))) {
$tokens['command'] = $match_1.' '.$match_2;
$tokens['index_name'] = $match_3;
} elseif ($match_2 == 'primary') {
} elseif (stripos('primary', $match_2) !== false) {
$tokens['command'] = $match_1.' '.$match_2.' '.$match_3;
} else {
$tokens['command'] = $match_1.' column';
$tokens['command'] = $match_1.' COLUMN';
$tokens['column_name'] = $match_2;
}
break;
case 'rename':
if ($match_2 == 'to') {
if (stripos('to', $match_2) !== false) {
$tokens['command'] = $match_1.' '.$match_2;
$tokens['column_name'] = $match_3;
} else {
$tokens['command'] = $match_1.' to';
$tokens['command'] = $match_1.' TO';
$tokens['column_name'] = $match_2;
}
break;
case 'modify':
if ($match_2 == 'column') {
if (stripos('column', $match_2) !== false) {
$tokens['command'] = $match_1.' '.$match_2;
$tokens['column_name'] = $match_3;
$tokens['column_def'] = trim($the_rest);
} else {
$tokens['command'] = $match_1.' column';
$tokens['command'] = $match_1.' COLUMN';
$tokens['column_name'] = $match_2;
$tokens['column_def'] = $match_3.' '.trim($the_rest);
}
break;
case 'change':
if ($match_2 == 'column') {
$the_rest = trim($the_rest);
if (stripos('column', $match_2) !== false) {
$tokens['command'] = $match_1.' '.$match_2;
$tokens['old_column'] = $match_3;
list($new_col) = preg_split('/\s/s', trim($the_rest), -1, PREG_SPLIT_DELIM_CAPTURE);
$tokens['new_column'] = $new_col;
$col_def = str_ireplace($new_col, '', $the_rest);
$tokens['column_def'] = trim($col_def);
} else {
$tokens['command'] = $match_1.' column';
$tokens['old_column'] = $match_2;
$tokens['new_column'] = $match_3;
$tokens['column_def'] = trim($the_rest);
}
break;
case 'alter':
if ($match_2 == 'column') {
$tokens['command'] = $match_1.' '.$match_2;
$tokens['column_name'] = $match_3;
list($set_or_drop) = explode(' ', $the_rest);
if ($set_or_drop == 'set') {
$tokens['default_command'] = 'set default';
$default_value = str_ireplace('set default', '', $the_rest);
$tokens['default_value'] = trim($default_value);
list($new_col) = explode(' ', $the_rest);
$tmp_col = preg_replace('/\(.+?\)/im', '', $new_col);
if (array_key_exists(strtolower($tmp_col), $this->array_types)) {
$tokens['column_def'] = $the_rest;
} else {
$tokens['default_command'] = 'drop default';
$tokens['new_column'] = $new_col;
$col_def = str_replace($new_col, '', $the_rest);
$tokens['column_def'] = trim($col_def);
}
} else {
$tokens['command'] = $match_1.' column';
$tokens['old_column'] = $match_2;
$tmp_col = preg_replace('/\(.+?\)/im', '', $match_3);
if (array_key_exists(strtolower($tmp_col), $this->array_types)) {
$tokens['column_def'] = $match_3 . ' ' . $the_rest;
} else {
$tokens['new_column'] = $match_3;
$tokens['column_def'] = $the_rest;
}
}
break;
case 'alter':
if (stripos('column', $match_2) !== false) {
$tokens['command'] = $match_1.' '.$match_2;
$tokens['column_name'] = $match_3;
list($set_or_drop) = explode(' ', $the_rest);
if (stripos('set', $set_or_drop) !== false) {
$tokens['default_command'] = 'SET DEFAULT';
$default_value = str_ireplace('set default', '', $the_rest);
$tokens['default_value'] = trim($default_value);
} else {
$tokens['default_command'] = 'DROP DEFAULT';
}
} else {
$tokens['command'] = $match_1.' COLUMN';
$tokens['column_name'] = $match_2;
if ($match_3 == 'set') {
$tokens['default_command'] = 'set default';
if (stripos('set', $match_3) !== false) {
$tokens['default_command'] = 'SET DEFAULT';
$default_value = str_ireplace('default', '', $the_rest);
$tokens['default_value'] = trim($default_value);
} else {
$tokens['default_command'] = 'drop default';
$tokens['default_command'] = 'DROP DEFAULT';
}
}
break;
@ -299,14 +329,14 @@ class AlterQuery {
$create_query = array_shift($index_queries);
if (stripos($create_query, $tokenized_query['column_name']) === false) {
return 'SELECT 1=1';
} elseif (preg_match("/{$tokenized_query['column_name']}\\s*{$tokenized_query['column_def']}\\s*[,)]/i", $create_query)) {
} elseif (preg_match("/{$tokenized_query['column_name']}\\s*{$column_def}\\s*[,)]/i", $create_query)) {
return 'SELECT 1=1';
}
$create_query = preg_replace("/{$tokenized_query['table_name']}/i", $temp_table, $create_query);
if (preg_match("/\\b{$tokenized_query['column_name']}\\s*.*(?=,)/ims", $create_query)) {
$create_query = preg_replace("/\\b{$tokenized_query['column_name']}\\s*.*(?=,)/ims", "{$tokenized_query['column_name']} {$tokenized_query['column_def']}", $create_query);
$create_query = preg_replace("/\\b{$tokenized_query['column_name']}\\s*.*(?=,)/ims", "{$tokenized_query['column_name']} {$column_def}", $create_query);
} elseif (preg_match("/\\b{$tokenized_query['column_name']}\\s*.*(?=\))/ims", $create_query)) {
$create_query = preg_replace("/\\b{$tokenized_query['column_name']}\\s*.*(?=\))/ims", "{$tokenized_query['column_name']} {$tokenized_query['column_def']}", $create_query);
$create_query = preg_replace("/\\b{$tokenized_query['column_name']}\\s*.*(?=\))/ims", "{$tokenized_query['column_name']} {$column_def}", $create_query);
}
$query[] = $create_query;
$query[] = "INSERT INTO $temp_table SELECT * FROM {$tokenized_query['table_name']}";
@ -324,11 +354,16 @@ class AlterQuery {
$new_fields = '';
$tokenized_query = $queries;
$temp_table = 'temp_'.$tokenized_query['table_name'];
$column_def = $this->convert_field_types($tokenized_query['new_column'], $tokenized_query['column_def']);
if (isset($tokenized_query['new_column'])) {
$column_name = $tokenized_query['new_column'];
} else {
$column_name = $tokenized_query['old_column'];
}
$column_def = $this->convert_field_types($column_name, $tokenized_query['column_def']);
$_wpdb = new PDODB();
$col_obj = $_wpdb->get_results("SHOW COLUMNS FROM {$tokenized_query['table_name']}");
foreach ($col_obj as $col) {
if ($col->Field == $tokenized_query['old_column']) $col_check = true;
if (stripos($col->Field, $tokenized_query['old_column']) !== false) $col_check = true;
$old_fields .= $col->Field . ',';
}
if ($col_check == false) {
@ -336,7 +371,7 @@ class AlterQuery {
return 'SELECT 1=1';
}
$old_fields = rtrim($old_fields, ',');
$new_fields = str_replace($tokenized_query['old_column'], $tokenized_query['new_column'], $old_fields);
$new_fields = str_ireplace($tokenized_query['old_column'], $column_name, $old_fields);
$query_obj = $_wpdb->get_results("SELECT sql FROM sqlite_master WHERE tbl_name='{$tokenized_query['table_name']}'");
$_wpdb = null;
for ($i = 0; $i < count($query_obj); $i++) {
@ -345,16 +380,16 @@ class AlterQuery {
$create_query = array_shift($index_queries);
$create_query = preg_replace("/{$tokenized_query['table_name']}/i", $temp_table, $create_query);
if (preg_match("/\\b{$tokenized_query['old_column']}\\s*(.+?)(?=,)/ims", $create_query, $match)) {
if ($tokenized_query['column_def'] == trim($match[1])) {
if (stripos(trim($match[1]), $column_def) !== false) {
return 'SELECT 1=1';
} else {
$create_query = preg_replace("/\\b{$tokenized_query['old_column']}\\s*.*?(?=,)/ims", "{$tokenized_query['new_column']} {$tokenized_query['column_def']}", $create_query);
$create_query = preg_replace("/\\b{$tokenized_query['old_column']}\\s*.+?(?=,)/ims", "{$column_name} {$column_def}", $create_query, 1);
}
} elseif (preg_match("/\\b{$tokenized_query['old_column']}\\s*(.+?)(?=\))/ims", $create_query, $match)) {
if ($tokenized_query['column_def'] == trim($match[1])) {
if (stripos(trim($match[1]), $column_def) !== false) {
return 'SELECT 1=1';
} else {
$create_query = preg_replace("/\\b{$tokenized_query['old_column']}\\s*.*?(?=\))/ims", "{$tokenized_query['new_column']} {$tokenized_query['column_def']}", $create_query);
$create_query = preg_replace("/\\b{$tokenized_query['old_column']}\\s*.*(?=\))/ims", "{$column_name} {$column_def}", $create_query, 1);
}
}
$query[] = $create_query;
@ -370,11 +405,11 @@ class AlterQuery {
private function handle_alter_command($queries) {
$tokenized_query = $queries;
$temp_table = 'temp_'.$tokenized_query['table_name'];
if (stripos($tokenized_query['default_command'], 'set') !== false) {
if (isset($tokenized_query['default_value'])) {
$def_value = $this->convert_field_types($tokenized_query['column_name'], $tokenized_query['default_value']);
$def_value = 'DEFAULT '.$def_value;
} else {
$def_value = '';
$def_value = null;
}
$_wpdb = new PDODB();
$query_obj = $_wpdb->get_results("SELECT sql FROM sqlite_master WHERE tbl_name='{$tokenized_query['table_name']}'");
@ -386,12 +421,34 @@ class AlterQuery {
if (stripos($create_query, $tokenized_query['column_name']) === false) {
return 'SELECT 1=1';
}
if (preg_match("/\\s*({$tokenized_query['column_name']}\\s*.*?)\\s*(DEFAULT\\s*.*)[,)]/im", $create_query, $match)) {
$col_def = trim($match[1]);
$old_default = trim($match[2]);
$create_query = preg_replace("/($col_def)\\s*$old_default/im", "\\1 $def_value", $create_query);
if (preg_match("/\\s*({$tokenized_query['column_name']})\\s*(.*)?(DEFAULT\\s*.*)[,)]/im", $create_query, $match)) {
$col_name = trim($match[1]);
$col_def = trim($match[2]);
$col_def_esc = str_replace(array('(', ')'), array('\(', '\)'), $col_def);
$checked_col_def = $this->convert_field_types($col_name, $col_def);
$old_default = trim($match[3]);
$pattern = "/$col_name\\s*$col_def_esc\\s*$old_default/im";
if (is_null($def_value)) {
$replacement = $col_name . ' ' . $checked_col_def;
} else {
$replacement = $col_name . ' ' . $checked_col_def . ' ' . $def_value;
}
$create_query = preg_replace($pattern, $replacement, $create_query);
$create_query = str_ireplace($tokenized_query['table_name'], $temp_table, $create_query);
} else {
} elseif (preg_match("/\\s*({$tokenized_query['column_name']})\\s*(.*)?[,)]/im", $create_query, $match)) {
$col_name = trim($match[1]);
$col_def = trim($match[2]);
$col_def_esc = str_replace(array('(', ')'), array('\(', '\)'), $col_def);
$checked_col_def = $this->convert_field_types($col_name, $col_def);
$pattern = "/$col_name\\s*$col_def_esc/im";
if (is_null($def_value)) {
$replacement = $col_name . ' ' . $checked_col_def;
} else {
$replacement = $col_name . ' ' . $checked_col_def . ' ' . $def_value;
}
$create_query = preg_replace($pattern, $replacement, $create_query);
$create_query = str_ireplace($tokenized_query['table_name'], $temp_table, $create_query);
} else {
return 'SELECT 1=1';
}
$query[] = $create_query;
@ -410,29 +467,11 @@ class AlterQuery {
* @return string
*/
private function convert_field_types($col_name, $col_def){
$array_types = array(
'bit' => 'INTEGER', 'bool' => 'INTEGER',
'boolean' => 'INTEGER', 'tinyint' => 'INTEGER',
'smallint' => 'INTEGER', 'mediumint' => 'INTEGER',
'int' => 'INTEGER', 'integer' => 'INTEGER',
'bigint' => 'INTEGER', 'float' => 'REAL',
'double' => 'REAL', 'decimal' => 'REAL',
'dec' => 'REAL', 'numeric' => 'REAL',
'fixed' => 'REAL', 'date' => 'TEXT',
'datetime' => 'TEXT', 'timestamp' => 'TEXT',
'time' => 'TEXT', 'year' => 'TEXT',
'char' => 'TEXT', 'varchar' => 'TEXT',
'binary' => 'INTEGER', 'varbinary' => 'BLOB',
'tinyblob' => 'BLOB', 'tinytext' => 'TEXT',
'blob' => 'BLOB', 'text' => 'TEXT',
'mediumblob' => 'BLOB', 'mediumtext' => 'TEXT',
'longblob' => 'BLOB', 'longtext' => 'TEXT'
);
$array_curtime = array('current_timestamp', 'current_time', 'current_date');
$array_reptime = array("'0000-00-00 00:00:00'", "'0000-00-00 00:00:00'", "'0000-00-00'");
$def_string = str_replace('`', '', $col_def);
foreach ($array_types as $o=>$r){
$pattern = "/\\b" . $o . "\\s*(\([^\)]*\))?\\s*/imsx";
foreach ($this->array_types as $o=>$r){
$pattern = "/\\b$o\\s*(\([^\)]*\)*)?\\s*/ims";
if (preg_match($pattern, $def_string)) {
$def_string = preg_replace($pattern, "$r ", $def_string);
break;
@ -449,5 +488,24 @@ class AlterQuery {
}
return $def_string;
}
private $array_types = array(
'bit' => 'INTEGER', 'bool' => 'INTEGER',
'boolean' => 'INTEGER', 'tinyint' => 'INTEGER',
'smallint' => 'INTEGER', 'mediumint' => 'INTEGER',
'bigint' => 'INTEGER', 'integer' => 'INTEGER',
'int' => 'INTEGER', 'float' => 'REAL',
'double' => 'REAL', 'decimal' => 'REAL',
'dec' => 'REAL', 'numeric' => 'REAL',
'fixed' => 'REAL', 'datetime' => 'TEXT',
'date' => 'TEXT', 'timestamp' => 'TEXT',
'time' => 'TEXT', 'year' => 'TEXT',
'varchar' => 'TEXT', 'char' => 'TEXT',
'varbinary' => 'BLOB', 'binary' => 'BLOB',
'tinyblob' => 'BLOB', 'mediumblob' => 'BLOB',
'longblob' => 'BLOB', 'blob' => 'BLOB',
'tinytext' => 'TEXT', 'mediumtext' => 'TEXT',
'longtext' => 'TEXT', 'text' => 'TEXT'
);
}
?>

View File

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

View File

@ -6,8 +6,8 @@ Tags: database, SQLite, PDO
Author: Kojima Toshiyasu
Author URI: http://dogwood.skr.jp/
Requires at least: 3.3
Tested up to: 3.5.2
Stable tag: 1.1
Tested up to: 3.8
Stable tag: 1.5
License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@ -30,47 +30,69 @@ WordPressはMySQLと話していると思っていて、背後で何が起こっ
SQLite Integrationは[PDO for WordPress](http://wordpress.org/extend/plugins/pdo-for-wordpress)プラグインの後継です。後者は残念なことに、もうメンテナンスされていないようです。SQLite IntegrationはPDO for WordPressの基本的なアイディアと構造を借りて、より多くの機能とユーティリティを追加しました。
= Features =
= 特徴 =
SQLite Integrationは普通の「プラグイン」ではありません。WordPressをインストールするときに使います。そのため、少し準備が必要です。インストールのセクションを参照してください。[SQLite Integration Page](http://dogwood.skr.jp/wordpress/sqlite-integration/)をご覧になると、もっと詳しい説明を読むことができます。
SQLite Integrationは普通の「プラグイン」ではありません。WordPressをインストールするときに使わなければなりません。そのため、少し準備が必要です。インストールのセクションを参照してください。[SQLite Integration Page](http://dogwood.skr.jp/wordpress/sqlite-integration/)をご覧になると、もっと詳しい説明を読むことができます。
インストールに成功したら、MySQLを使う他のWordPressと同じように使うことができます。オプションとして、管理パネルでこのプラグインを有効化することができます。有効化すると有益な情報と説明を見ることができます。これは必須ではありませんが、お勧めします。
= Backward Compatibility =
ローカルマシンにこのプラグインを使ってWordPressをインストールし、本番の環境ではMySQLを使いたいという場合を考えて、wp-config.phpでどちらのデータベースを使うかを制御できるようにしました。
= 後方互換性 =
現在[PDO for WordPress](http://wordpress.org/extend/plugins/pdo-for-wordpress)をお使いの場合は、データベースを移行することができます。インストールのセクションをご覧ください。
= Support =
= サポート =
下の方法でコンタクトを取ってください。
[Support Forum](http://wordpress.org/support/plugin/sqlite-integration)にポストする。
1. [Support Forum](http://wordpress.org/support/plugin/sqlite-integration)にポストする。
2. [SQLite Integration(ja)のページ](http://dogwood.skr.jp/wordpress/sqlite-integration-ja/)でメッセージを残す。
注意: WordPress.orgはMySQL以外のデータベースを正式にサポートしていません。だから、WordPress.orgからのサポートは得られません。フォーラムに投稿しても、回答を得ることはまずないでしょう。また、パッチをあてたプラグインを使う場合は、そのプラグインの作者からのサポートはないものと思ってください。自分でリスクを負う必要があります。
= Translation =
= 翻訳 =
ドキュメントは英語で書かれています。日本語のカタログファイルと、.potファイルがアーカイブに含まれています。もしあなたの言語に翻訳をしたら、知らせてください。
== Installation ==
== インストール ==
このプラグインは他のプラグインとはちがいます。管理パネルのプラグイン・ページでインストールすることはできません。
まず、WordPressのインストールを準備しなければなりません。Codexの[Installing Wordpress ](http://codex.wordpress.org/Installing_WordPress)をご覧ください。
必要要件をチェックし、WordPressのアーカイブを展開したら、wp-config-sample.phpをwp-config.phpにリネームして、[Codex page](http://codex.wordpress.org/Editing_wp-config.php)に書いてあるように、少し編集する必要があります。データベースの設定*以外*の部分を設定してください。
必要要件をチェックし、WordPressのアーカイブを展開したら、wp-config-sample.phpをwp-config.phpにリネームして、[Codex page](http://codex.wordpress.org/Editing_wp-config.php)に書いてあるように、少し編集する必要があります。
終わったら、オプションの設定を書き加えることができます。次の説明に従ってください。
= 基本設定 =
SQLiteだけを使いたい場合は、wp-conifg.phpの下の部分だけを編集してください。
* 認証用ユニークキー
* WordPressデータベーステーブルの接頭辞
* ローカル言語(日本語版では、jaがすでに設定されています)
これでお終いです。他の部分は変更する必要はありません。
SQLiteとMySQLを交互に使いたい場合は、「MySQLの設定」セクションを編集する必要があります。また、wp-config.phpに下の1行を追加してください。
`define('USE_MYSQL', false);
// 編集が必要なのはここまでです !`
この定義は、WordPressがSQLiteを使うようにさせるものです。MySQLを使いたい場合は、'false'を'true'に変えるか、この行自体を削除してください。
= オプションの設定 =
基本設定が終わったら、オプションの設定を書き加えることができます。これは必須ではありませんので、必要がなければ、編集作業は終了です。
* デフォルト(wp-content/database)とは違うディレクトリにSQLiteデータベース・ファイルを置きたい場合は、次の行を追加してください(最後のスラッシュを忘れずに)。
`define('DB_DIR', '/home/youraccount/database_directory/');`
`define('DB_DIR', '/home/youraccount/database_directory/');`
注意: PHPスクリプトがこのディレクトリを作ったり、中にファイルを書き込んだりする権限を持っていることが必要です。
* デフォルト(.ht.sqlite)とは違うデータベース・ファイル名を使いたい場合は、次の行を追加してください。
`define('DB_FILE', 'database_file_name');`
`define('DB_FILE', 'database_file_name');`
注意: PDO for WordPressをお使いの方は、「データベースを移行する」のセクションをご覧ください。
@ -78,11 +100,13 @@ SQLite Integrationは普通の「プラグイン」ではありません。WordP
wp-config.phpの準備が終わったら、次のステップに進みます。
1. プラグインのアーカイブを展開します。
1. SQLite Integrationのアーカイブをダウンロードします。
2. アーカイブに含まれるdb.phpファイルをwp-contentディレクトリに移動(またはコピー)してください
2. プラグインのアーカイブを展開します
3. sqlite-wordpressディレクトリをwp-content/plugin/ディレクトリの下に移動してください。
3. アーカイブに含まれるdb.phpファイルをwp-contentディレクトリにコピーしてください。
4. sqlite-wordpressディレクトリをwp-content/plugin/ディレクトリの下に移動してください。
`wordpress/wp-contents/db.php`
@ -118,7 +142,7 @@ wp-config.phpの準備が終わったら、次のステップに進みます。
これでおしまいです。忘れずに必要要件とWordPressのバージョンをチェックしてください。*SQLite IntegrationはWordPress 3.2.x以前のものでは動作しません。*
== Frequently Asked Questions ==
== よくある質問 ==
= データベース・ファイルが作られません =
@ -158,18 +182,64 @@ wp-config.phpの準備が終わったら、次のステップに進みます。
* [Yet Another Related Posts](http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/)
* [Better Related Posts](http://wordpress.org/extend/plugins/better-related/)
たぶん、もっとあるでしょう。
たぶん、もっとあるでしょう。動作しないプラグインを見つけたら、お知らせいただけると助かります。
== Changelog ==
= 1.1 (2013-07-24) =
* DROP INDEX 単独のクエリが動作していなかったのを修正しました。
* shutdown_hook で descructor を実行していたのをやめました。
* LOCATE() 関数を使えるようにしました。
= 1.0 (2013-07-07) =
最初のリリース。
== Upgrade Notice ==
SQLite Integrationのアップグレードに失敗するようなら、FTPを使っての手動アップグレードを試してみてください。
WordPress 3.8 に対応しました。バグフィクスが少し、機能拡張も少しあります。自動アップグレードで失敗するようなら、FTPを使っての手動アップグレードを試してみてください。
== Changelog ==
= 1.5 (2013-12-17) =
* WordPress 3.8 でのインストールと動作テストをしました。
* SQLite と MySQL を交互に使えるようにしました。
* readme-ja.txt のインストールの説明をかえました。
* SQLite のコンパイルオプション'ENABLE_UPDATE_DELETE_LIMIT'をチェックするようにしました。
* WordPress 3.8 の管理画面に合わせて sytle を変更しました。
* グローバルで動くファイルへのダイレクトアクセスを制限するようにしました。
= 1.4.2 (2013-11-06) =
* ダッシュボードに表示される情報についてのバグを修正しました。
* スクリーンショットを変更しました。
* WordPress 3.7.1 でのインストールテストを行いました。
= 1.4.1 (2013-09-27) =
* BETWEEN関数の書き換え方を修正しました。致命的なバグです。新規投稿に'between A and B'というフレーズが含まれていると、公開されず、投稿自体も消えます。
* MP6を使っているときに、管理画面のレイアウトが崩れるのを修正しました。
* 日本語が一部表示されないのを直しました。
* SELECT version()がダミーデータを返すようにしました。
* WP_DEBUGが有効の時に、WordPressのテーブルからカラム情報を読んで表示できるようにしました。
= 1.4 (2013-09-12) =
* アップグレードしたWordPressで期待通り動作しないのを修正するために、データベース管理ユーティリティを追加しました。
* SHOW INDEXクエリにWHERE句がある場合の処理を変更しました。
* ALTER TABLEクエリのバグを修正しました。
= 1.3 (2013-09-04) =
* データベースファイルのスナップショットをzipアーカイブとしてバックアップするユーティリティを追加しました。
* ダッシュボードのスタイルをMP6プラグインに合わせたものに変えました。
* 言語カタログが読み込まれていないときのエラーメッセージの出力方法を一部変更しました。
* query_create.class.phpの_rewrite_field_types()を変更しました。dbDelta()関数が意図したとおりに実行されます。
* BETWEENステートメントが使えるようになりました。
* クエリからインデックスヒントを全て削除して実行するようにしました。
* New StatPressプラグインが使えるように、ALTER TABLE CHANGE COLUMNの扱いを修正しました。
* いくつかの小さなバグを修正しました。
= 1.2.1 (2013-08-04) =
* wp-db.phpの変更にともなって、wpdb::real_escapeプロパティを削除しました。WordPress 3.6 との互換性を保つための変更です。
= 1.2 (2013-08-03) =
* カレンダー・ウィジェットでの不具合に対応するため、日付フォーマットとそのクオートを修正しました。
* Windows マシンでパッチファイルが削除できなかったのを修正しました。
* パッチファイルをアップロードするときに textdomain のエラーが出るのを修正しました。
* ON DUPLICATE KEY UPDATEをともなったクエリの処理を変更しました。
* readme.txt と readme-ja.txt の間違いを直しました。
= 1.1 (2013-07-24) =
* DROP INDEX 単独のクエリが動作していなかったのを修正しました。
* shutdown_hook で destruct() を実行していたのをやめました。
* LOCATE() 関数を使えるようにしました。
= 1.0 (2013-07-07) =
* 最初のリリース。

View File

@ -6,8 +6,8 @@ Tags: database, SQLite, PDO
Author: Kojima Toshiyasu
Author URI: http://dogwood.skr.jp/
Requires at least: 3.3
Tested up to: 3.5.2
Stable tag: 1.1
Tested up to: 3.8
Stable tag: 1.5
License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@ -15,7 +15,7 @@ SQLite Integration is the plugin that enables WordPress to use SQLite. If you wa
== Description ==
This plugin enables WordPress to work with [SQLite](http://www.sqlite.org/). You don't have to prepare MySQL database server and its configuration. SQLite is a self-contained, serverless, transactional SQL database engine. It is not a full-featured database system like MySQL or PostgreSQL, but it best fits for low to medium traffic websites.
This plugin enables WordPress to work with [SQLite](http://www.sqlite.org/). You don't have to prepare MySQL database server or its configuration. SQLite is a self-contained, serverless, transactional SQL database engine. It is not a full-featured database system like MySQL or PostgreSQL, but it best fits for low to medium traffic websites.
SQLite Integration is a kind of wrapper program, which is placed between WordPress and SQLite database and works as a mediator. It works as follows:
@ -32,21 +32,24 @@ SQLite Integration is a successor to [PDO for WordPress](http://wordpress.org/ex
= Features =
SQLite Integration is not an ordinary 'plugin'. It is used to install WordPress itself. You need to do some preparations. Please read the install section. And see more detailed instruction in the [SQLite Integration Page](http://dogwood.skr.jp/wordpress/sqlite-integration).
SQLite Integration is not an ordinary 'plugin'. It must be be used when you install WordPress itself, which requires you to do some preparations. Please read the install section. And see more detailed instruction in the [SQLite Integration Page](http://dogwood.skr.jp/wordpress/sqlite-integration/).
Once you succeeded in installing WordPress, you can use it just like the others using MySQL. Optionally, you can activate this plugin in the installed plugins panel of the adimn dashboard, and you can see the useful information and instructions. It is not required but I recommend it.
Once you succeed in installing WordPress, you can use it just like the others using MySQL. Optionally, you can activate this plugin in the installed plugins panel of the adimn dashboard, and you can see the useful information and instructions. It is not required but I recommend it.
If you want to test WordPress with this plugin on the local machine but want to use MySQL on the server machine, you can control which database to use with the simple directive in the wp-config.php file. See the install instruction section.
= Backward Compatibility =
If you are using [PDO for WordPress](http://wordpress.org/extend/plugins/pdo-for-wordpress), you can migrate your database. See install section.
If you are using [PDO for WordPress](http://wordpress.org/extend/plugins/pdo-for-wordpress), you can migrate your database. See install instruction section.
= Support =
Please contact us with the methods below:
Post to [Support Forum](http://wordpress.org/support/plugin/sqlite-integration/).
1. Post to [Support Forum](http://wordpress.org/support/plugin/sqlite-integration/).
2. Visti the [SQLite Integration Page](http://dogwood.skr.jp/wordpress/sqlite-integration/) or [SQLite Integration(ja) Page](http://dogwood.skr.jp/wordpress/sqlite-integration-ja/) and leave a message.
Notes: WordPress.org doesn't officially support using any other database than MySQL. So there will be no supports from WordPress.org. Even if you post to the general Forum, you have few chances to get the answer. And if you use patched plugins, you will have be no support from the plugin authors, eithter.
Notes: WordPress.org doesn't officially support using any other database than MySQL. So there will be no supports from WordPress.org. Even if you post to the general Forum, you have few chances to get the answer. And if you use patched plugins, you will have no support from the plugin authors, eithter.
= Translation =
@ -56,31 +59,54 @@ Documentation is written in English. Japanese catalog file and .pot file are inc
This plugin is *not* like the other plugins. You can't install and activate it on the plugin administration panel.
First of all, you've got to prepare WordPress installation. See [Installing Wordpress ](http://codex.wordpress.org/Installing_WordPress) section in the Codex.
First of all, you've got to prepare WordPress installation. See also [Installing Wordpress ](http://codex.wordpress.org/Installing_WordPress) section in the Codex.
After checking the prerequisites and unzipping the WordPress archive file, you must rename wp-contig-sample.php file to wp-config.php and do some editting as the [Codex page](http://codex.wordpress.org/Editing_wp-config.php) says. Please follow the instructions *except* the database settings.
After checking the prerequisites and downloading and unzipping the WordPress archive file, you must rename wp-contig-sample.php file to wp-config.php and do some editting as the [Codex page](http://codex.wordpress.org/Editing_wp-config.php) says.
When you finish, you can add optional settings. Follow the steps below:
= Basic settings =
If you only use SQLite for your database, you don't have to edit the MySQL settings section. Edit the three sections below:
* Authentication Unique keys and Salts
* WordPress Database Table prefix
* WordPress Localized Language
That's all. You don't have to change any other sections.
If you want to use SQLite and MySQL interchangeably, you must edit the database server settings at the top of the file as well as the sections above mentioned. And add the line below.
`define('USE_MYSQL', false);
/* That's all, stop editing! Happy blogging. */`
This definition makes WordPress use SQLite. If you want to change the database to MySQL, change 'false' to 'true' or just delete this line.
= Optional settings =
When you finish basic settings, you can add optional ones. This is not required. If you don't need them, you don't have to edit wp-config.php any more.
* If you want to put the SQLite database file to the directory different from the default setting (wp-content/database), you can add the line below (don't forget to add a trailing slash):
`define('DB_DIR', '/home/youraccount/database_directory/');`
`define('DB_DIR', '/home/youraccount/database_directory/');`
Note: Your PHP scripts must be able to create that directory and files in it.
Note: Your PHP scripts must have the permission to create that directory and files in it.
* If you want to change the database file name to the one different from the default (.ht.sqlite), you can add the line below:
* If you want to change the database file name to another one different from the default (.ht.sqlite), you can add the line below:
`define('DB_FILE', 'database_file_name');`
`define('DB_FILE', 'database_file_name');`
Note: If you are using 'PDO for WordPress' plugin, see also 'Migrating your database' section.
If you don't understand well, you don't have to add any of the lines above.
= Preparing SQLite Integration =
After you finish preparing wp-config.php, follow the next steps:
1. Unzip the plugin archive file.
1. Download SQLite Integration archive file.
2. Move db.php file contained in the archive to wp-content directory.
2. Unzip the plugin archive file.
3. Copy db.php file contained in the archive to wp-content directory.
3. Move the sqlite-integration directory to wp-content/plugin/ directory.
@ -135,7 +161,7 @@ Just deactivate the plugin, and you can remove them. Activation and deactivation
== Known Limitations ==
Many of the other plugins will work fine with this plugin. But there are some you can't use. Generally speaking, the plugins that manipulate database not with WordPress functions but with Mysql or Mysqli native drivers from PHP might cause the problem.
Many of the other plugins will work fine with this plugin. But there are some you can't use. Generally speaking, the plugins that manipulate database not with WordPress functions but with mysql or mysqli native drivers from PHP might cause the problem.
These are other examples:
@ -150,18 +176,63 @@ These are other examples:
* [Yet Another Related Posts](http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/)
* [Better Related Posts](http://wordpress.org/extend/plugins/better-related/)
Probably there are more, I'm afraid.
== Changelog ==
= 1.1 (2013-07-24) =
* Fixed the manipulation of DROP INDEX query.
* Removed desctructor() from shutdown_hook.
* Enabled LOCATE() function in the query string.
= 1.0 (2013-07-07) =
First release version of the plugin.
Probably there are more, I'm afraid. If you find one, please let me know.
== Upgrade Notice ==
When auto upgrading of SQLite Integration fails, Please try manual upgrade via FTP.
WordPress 3.8 compatible. Some minor bug fixes and optional features. When auto upgrading fails, please try manual upgrade via FTP.
== Changelog ==
= 1.5 (2013-12-17) =
* Tested WordPress 3.8 installation and compatibility.
* Add the optional feature to change the database from SQLite to MySQL.
* Changed the install instruction in the readme.txt.
* Add the code to check if the SQLite library was compiled with the option 'ENABLE_UPDATE_DELETE_LIMIT'.
* Changed the admin panel style to fit for WordPress 3.8.
* Restricted the direct access to the files that works in the global namespace.
= 1.4.2 (2013-11-06) =
* Fixed some minor bugs about the information in the dashboard.
* Changed the screenshot.
* Tested WordPress 3.7.1 installation.
= 1.4.1 (2013-09-27) =
* Fixed the rewriting process of BETWEEN function. This is a critical bug. When your newly created post contains 'between A and B' phrase, it is not published and disappears.
* Fixed the admin dashboard display when using MP6.
* Fixed the Japanese catalog.
* Added the procedure for returning the dummy data when using SELECT version().
* Added the procedure for displaying column informatin of WordPress tables when WP_DEBUG enabled.
= 1.4 (2013-09-12) =
* Added the database maintenance utility for fixing the database malfunction of the upgraded WordPress installation.
* Changed the manipulation of SHOW INDEX query with WHERE clause.
* Fixed the bug of the manipulation of ALTER TABLE query.
= 1.3 (2013-09-04) =
* Added the backup utility that creates the zipped archive of the current snapshot of the database file.
* Changed the dashboard style to match MP6 plugin.
* Changed the way of putting out the error messages when language catalogs are not loaded.
* Modified the _rewrite_field_types() in query_create.class.php for the dbDelta() function to work properly.
* Added the support for BETWEEN statement.
* Changed the regular expression to remove all the index hints from the query string.
* Fixed the manipulation of ALTER TABLE CHANGE COLUMN query for NewStatPress plugin to work.
* Fixed minor bugs.
= 1.2.1 (2013-08-04) =
* Removed wpdb::real_escape property following the change of the wpdb.php file which makes the plugin compatible with Wordpress 3.6.
= 1.2 (2013-08-03) =
* Fixed the date string format and its quotation for calendar widget.
* Fixed the patch utility program for using on the Windows machine.
* Fixed the textdomain error in utilities/patch.php file when uploading the patch file.
* Changed the manipulation of the query with ON DUPLICATE KEY UPDATE.
* Fixed the typos in readme.txt and readme-ja.txt.
= 1.1 (2013-07-24) =
* Fixed the manipulation of DROP INDEX query.
* Removed destruct() from shutdown_hook.
* Enabled LOCATE() function in the query string.
= 1.0 (2013-07-07) =
* First release version of the plugin.

View File

@ -1,7 +1,6 @@
<?php
/**
* @package SQLite Integration
* @version 1.1
* @author Kojima Toshiyasu, Justin Adie
*/
@ -10,12 +9,16 @@
* This is run only once while installation.
* @return boolean
*/
if (!defined('ABSPATH')) {
echo 'Thank you, but you are not allowed to access this file.';
die();
}
function make_db_sqlite() {
include_once PDODIR . 'query_create.class.php';
include_once ABSPATH . 'wp-admin/includes/schema.php';
$index_array = array();
ob_end_clean();
// ob_end_clean();
$table_schemas = wp_get_db_schema();
$queries = explode (";", $table_schemas);
$query_parser = new CreateQuery();
@ -23,8 +26,8 @@ function make_db_sqlite() {
$pdo = new PDO('sqlite:'.FQDB, null, null, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
} catch (PDOException $err) {
$err_data = $err->errorInfo;
$message = __("Database connection error!<br />", 'sqlite-integration');
$message .= sprintf(__("Error message is: %s", 'sqlite-integration'), $err_data[2]);
$message = 'Database connection error!<br />';
$message .= sprintf("Error message is: %s", $err_data[2]);
echo $message;
return false;
}
@ -77,8 +80,8 @@ function make_db_sqlite() {
$pdo->commit();
} else {
$pdo->rollBack();
$message = sprintf(__("Error occured while creating tables or indexes...<br />Query was: %s<br />", 'sqlite-integration'), var_export($rewritten_query, true));
$message .= sprintf(__("Error message is: %s", 'sqlite-integration'), $err_data[2]);
$message = sprintf("Error occured while creating tables or indexes...<br />Query was: %s<br />", var_export($rewritten_query, true));
$message .= sprintf("Error message is: %s", $err_data[2]);
echo $message;
return false;
}

View File

@ -1,10 +1,10 @@
<?php
/*
Plugin Name: SQLite Integration
Plugin URI: http://wordpress.org/extend/plugins/sqlite-integration
Plugin URI: http://dogwood.skr.jp/wordpress/sqlite-integration/
Description: SQLite Integration is the plugin that enables WordPress to use SQLite. If you don't have MySQL and want to build a WordPress website, it's for you.
Author: Kojima Toshiyasu
Version: 1.1
Version: 1.5
Author URI: http://dogwood.skr.jp
Text Domain: sqlite-integration
Domain Path: /languages
@ -29,6 +29,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
/**
* Globals
*/
if (!defined('ABSPATH')) {
echo 'Thank you, but you are not allowed to access this file.';
die();
}
$siteurl = get_option('siteurl');
define('SQLiteDir', dirname(plugin_basename(__FILE__)));
define('SQLiteFilePath', dirname(__FILE__));
@ -59,6 +63,10 @@ if (!class_exists('PatchUtils')) {
require_once SQLiteFilePath . '/utilities/patch.php';
$patch_utils = new PatchUtils();
}
if (!class_exists('DatabaseMaintenance')) {
require_once SQLiteFilePath . '/utilities/database_maintenance.php';
$maintenance = new DatabaseMaintenance();
}
/**
* This class is for WordPress Administration Panel
@ -153,21 +161,24 @@ class SQLiteIntegration {
* users.
*/
function add_pages() {
global $utils, $doc, $patch_utils;
global $utils, $doc, $patch_utils, $maintenance;
if (function_exists('add_options_page')) {
$welcome_page = add_options_page(__('SQLite Integration'), __('SQLite Integration'), 'manage_options', 'sqlite-integration', array($utils, 'welcome'));
$util_page = add_submenu_page(null, 'System Info', 'System Info', 'manage_options', 'sys-info', array($utils, 'show_utils'));
$edit_db = add_submenu_page(null, 'Setting File', 'Setting File', 'manage_options', 'setting-file', array($utils, 'edit_db_file'));
$doc_page = add_submenu_page(null, 'Documentation', 'Documentation', 'manage_options', 'doc', array($doc, 'show_doc'));
$patch_page = add_submenu_page(null, 'Patch Utility', 'Patch Utility', 'manage_options', 'patch', array($patch_utils, 'show_patch_page'));
$maintenance_page = add_submenu_page(null, 'DB Maintenance', 'DB Maintenance', 'manage_options', 'maintenance', array($maintenance, 'show_maintenance_page'));
add_action('admin_print_styles-'.$welcome_page, array($this, 'add_style_sheet'));
add_action('admin_print_styles-'.$util_page, array($this, 'add_style_sheet'));
add_action('admin_print_styles-'.$edit_db, array($this, 'add_style_sheet'));
add_action('admin_print_styles-'.$doc_page, array($this, 'add_doc_style_sheet'));
add_action('admin_print_styles-'.$doc_page, array($this, 'add_style_sheet'));
add_action('admin_print_styles-'.$patch_page, array($this, 'add_style_sheet'));
add_action('admin_print_scripts-'.$util_page, array($this, 'add_sqlite_script'));
add_action('admin_print_scripts-'.$doc_page, array($this, 'add_sqlite_script'));
add_action('admin_print_scripts-'.$patch_page, array($this, 'add_sqlite_script'));
add_action('admin_print_scripts-'.$edit_db, array($this, 'add_sqlite_script'));
add_action('admin_print_styles-'.$maintenance_page, array($this, 'add_style_sheet'));
}
}
@ -176,21 +187,24 @@ class SQLiteIntegration {
* So, capability is set to manage_network_options.
*/
function add_network_pages() {
global $utils, $doc, $patch_utils;
global $utils, $doc, $patch_utils, $maintenance;
if (function_exists('add_options_page')) {
$welcome_page = add_submenu_page('settings.php', __('SQLite Integration'), __('SQLite Integration'), 'manage_network_options', 'sqlite-integration', array($utils, 'welcome'));
$util_page = add_submenu_page(null, 'System Info', 'System Info', 'manage_network_options', 'sys-info', array($utils, 'show_utils'));
$edit_db = add_submenu_page(null, 'Setting File', 'Setting File', 'manage_network_options', 'setting-file', array($utils, 'edit_db_file'));
$doc_page = add_submenu_page(null, 'Documentation', 'Documentation', 'manage_network_options', 'doc', array($doc, 'show_doc'));
$patch_page = add_submenu_page(null, 'Patch Utility', 'Patch Utility', 'manage_network_options', 'patch', array($patch_utils, 'show_patch_page'));
$maintenance_page = add_submenu_page(null, 'DB Maintenance', 'DB Maintenance', 'manage_network_options', 'maintenance', array($maintenance, 'show_maintenance_page'));
add_action('admin_print_styles-'.$welcome_page, array($this, 'add_style_sheet'));
add_action('admin_print_styles-'.$util_page, array($this, 'add_style_sheet'));
add_action('admin_print_styles-'.$edit_db, array($this, 'add_style_sheet'));
add_action('admin_print_styles-'.$doc_page, array($this, 'add_doc_style_sheet'));
add_action('admin_print_styles-'.$doc_page, array($this, 'add_style_sheet'));
add_action('admin_print_styles-'.$patch_page, array($this, 'add_style_sheet'));
add_action('admin_print_scripts-'.$util_page, array($this, 'add_sqlite_script'));
add_action('admin_print_scripts-'.$doc_page, array($this, 'add_sqlite_script'));
add_action('admin_print_scripts-'.$patch_page, array($this, 'add_sqlite_script'));
add_action('admin_print_scripts-'.$edit_db, array($this, 'add_sqlite_script'));
add_action('admin_print_styles-'.$maintenance_page, array($this, 'add_style_sheet'));
}
}
@ -211,22 +225,23 @@ class SQLiteIntegration {
* Styles and JavaScripts
*/
function add_style_sheet() {
$style_url = SQLiteUrl . '/styles/style.css';
$style_file = SQLiteFilePath . '/styles/style.css';
global $current_user;
get_currentuserinfo();
$admin_color = get_user_meta($current_user->ID, 'admin_color', true);
if ($admin_color == 'fresh') {
$stylesheet_file = 'style.min.css';
} else {
$stylesheet_file = $admin_color . '.min.css';
}
$style_url = SQLiteUrl . '/styles/' . $stylesheet_file;
$style_file = SQLiteFilePath . '/styles/' . $stylesheet_file;
if (file_exists($style_file)) {
wp_enqueue_style('sqlite_integration_stylesheet', $style_url);
}
}
function add_doc_style_sheet() {
$style_url = SQLiteUrl . '/styles/doc.css';
$style_file = SQLiteFilePath . '/styles/doc.css';
if (file_exists($style_file)) {
wp_enqueue_style('sqlite_integration_doc_style', $style_url);
}
}
function add_sqlite_script() {
$script_url = SQLiteUrl . '/js/sqlite.js';
$script_file = SQLiteFilePath . '/js/sqlite.js';
$script_url = SQLiteUrl . '/js/sqlite.min.js';
$script_file = SQLiteFilePath . '/js/sqlite.min.js';
if (file_exists($script_file)) {
wp_enqueue_script('sqlite-integration', $script_url, 'jquery');
}

37
styles/blue.css Normal file
View File

@ -0,0 +1,37 @@
@import url('./style.min.css');
@CHARSET "UTF-8";
#sqlite-admin-wrap h2,
#sqlite-admin-side-wrap h2 {
background: #4796b3;
color: rgb(255, 255, 255);
padding-left: 5px;
}
.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: #4796b3;
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: #096484;
color: rgb(255, 255, 255);
}
.menu-item a {
text-decoration: none;
color: rgb(255, 255, 255);
}

1
styles/blue.min.css vendored Normal file
View File

@ -0,0 +1 @@
@import url('./style.min.css');@CHARSET "UTF-8";#sqlite-admin-wrap h2,#sqlite-admin-side-wrap h2{background:#4796b3;color:#fff;padding-left:5px}.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:#4796b3;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:#096484;color:#fff}.menu-item a{text-decoration:none;color:#fff}

36
styles/coffee.css Normal file
View File

@ -0,0 +1,36 @@
@import url('./style.min.css');
@CHARSET "UTF-8";
#sqlite-admin-wrap h2,
#sqlite-admin-side-wrap h2 {
background: #59524c;
color: rgb(255, 255, 255);
padding-left: 5px;
}
.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: #59524c;
color: rgb(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;
background: #c7a589;
color: rgb(255, 255, 255);
}
.menu-item a {
text-decoration: none;
color: rgb(255, 255, 255);
}

1
styles/coffee.min.css vendored Normal file
View File

@ -0,0 +1 @@
@import url('./style.min.css');@CHARSET "UTF-8";#sqlite-admin-wrap h2,#sqlite-admin-side-wrap h2{background:#59524c;color:#fff;padding-left:5px}.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:#59524c;color:#fff;line-height:40px}.menu-selected{font-size:20px;display:inline;min-width:150px;height:50px;margin-left:0;margin-right:10px;padding:5px;background:#c7a589;color:#fff}.menu-item a{text-decoration:none;color:#fff}

View File

@ -1,141 +0,0 @@
@CHARSET "UTF-8";
#sqlite-admin-wrap h2,
#sqlite-admin-side-wrap h2 {
background: rgb(73, 90, 88);
background: -moz-linear-gradient(bottom, rgba(73, 90, 88, 1), rgba(73, 90, 88, 0.5), rgba(73, 90, 88, 0));
background: -webkit-gradient(linear, bottom, top, from(rgba(73, 90, 88, 1)), color-stop(0.5, rgba(73, 90, 88, 0.5)), to(rgba(73, 90, 88, 0)));
background: linear-gradient(to top, rgba(73, 90, 88, 1), rgba(73, 90, 88, 0.2));
color: rgb(247, 254, 236);
-webkit-border-top-right-radius: 6px;
-webkit-border-top-left-radius: 6px;
-moz-border-radius-topright: 6px;
-moz-border-radius-topleft: 6px;
border-top-right-radius: 6px;
border-top-left-radius: 6px;
text-shadow: -1px -1px 0 rgb(93, 69, 35),
1px -1px 0 rgb(93, 69, 35),
-1px 1px 0 rgb(93, 69, 35),
1px 1px 0 rgb(93, 69, 35);
padding-left: 5px;
}
.navigation {
display: block;
margin-top: 0;
margin-bottom: 0;
min-height: 20px;
/* border: 1px solid #000; */
}
.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;
-webkit-border-top-right-radius: 6px;
-webkit-border-top-left-radius: 6px;
-moz-border-radius-topright: 6px;
-moz-border-radius-topleft: 6px;
border-top-right-radius: 6px;
border-top-left-radius: 6px;
box-shadow: 5px 5px 5px #eee;
}
.menu-selected {
font-size: 20px;
display: inline;
min-width: 150px;
height: 50px;
margin-left: 0;
margin-right: 10px;
padding: 5px;
border: .5px solit #000;
-webkit-border-top-right-radius: 6px;
-webkit-border-top-left-radius: 6px;
-moz-border-radius-topright: 6px;
-moz-border-radius-topleft: 6px;
border-top-right-radius: 6px;
border-top-left-radius: 6px;
box-shadow: 5px 5px 5px #eee;
background: rgb(73, 90, 88);
background: -moz-linear-gradient(bottom, rgba(73, 90, 88, 1), rgba(73, 90, 88, 0.5), rgba(73, 90, 88, 0));
background: -webkit-gradient(linear, bottom, top, from(rgba(73, 90, 88, 1)), color-stop(0.5, rgba(73, 90, 88, 0.5)), to(rgba(73, 90, 88, 0)));
background: linear-gradient(to top, rgba(73, 90, 88, 1), rgba(73, 90, 88, 0.2));
color: rgb(247, 254, 236);
text-shadow: -1px -1px 0 rgb(93, 69, 35),
1px -1px 0 rgb(93, 69, 35),
-1px 1px 0 rgb(93, 69, 35),
1px 1px 0 rgb(93, 69, 35);
}
.menu-item a {
text-decoration: none;
}
#sqlite-admin-wrap {
color: #1d1d1d;
font-size: 10pt;
border: 1px solid #ddd;
/* border-top: 0; */
-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;
display: block;
float: left;
min-height: 100px;
position: relative;
width: 47%;
margin-top: 10px;
padding: 5px;
box-shadow: 5px 5px 5px #eee;
z-index: 1;
}
#sqlite-admin-side-wrap {
color: #1d1d1d;
font-size: 10pt;
border: 1px solid #ddd;
/* border-top: 0; */
-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;
display: block;
float: left;
min-height: 100px;
position: relative;
width: 47%;
margin-top: 10px;
padding: 5px;
box-shadow: 5px 5px 5px #eee;
z-index: 1;
}
p {
text-indent: 15px;
line-height: 150%;
margin-left: 10px;
margin-right: 10px;
}
ul {
margin-left: 20px;
}
ol {
margin-left: 40px;
}
pre.code {
margin-left: 10px;
background: #eee;
}
.alt {
background: rgb(247, 254, 236);
}
.em {
font-weight: bold;
text-transform: capitalize;
}

36
styles/ectoplasm.css Normal file
View File

@ -0,0 +1,36 @@
@import url('./style.min.css');
@CHARSET "UTF-8";
#sqlite-admin-wrap h2,
#sqlite-admin-side-wrap h2 {
background: #523f6d;
color: rgb(255, 255, 255);
padding-left: 5px;
}
.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: #523f6d;
color: rgb(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;
background: #a3b745;
color: rgb(255, 255, 255);
}
.menu-item a {
text-decoration: none;
color: rgb(255, 255, 255);
}

1
styles/ectoplasm.min.css vendored Normal file
View File

@ -0,0 +1 @@
@import url('./style.min.css');@CHARSET "UTF-8";#sqlite-admin-wrap h2,#sqlite-admin-side-wrap h2{background:#523f6d;color:#fff;padding-left:5px}.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:#523f6d;color:#fff;line-height:40px}.menu-selected{font-size:20px;display:inline;min-width:150px;height:50px;margin-left:0;margin-right:10px;padding:5px;background:#a3b745;color:#fff}.menu-item a{text-decoration:none;color:#fff}

2
styles/index.php Normal file
View File

@ -0,0 +1,2 @@
<?php
/* Silence is golden */

38
styles/light.css Normal file
View File

@ -0,0 +1,38 @@
@import url('./style.min.css');
@CHARSET "UTF-8";
#sqlite-admin-wrap h2,
#sqlite-admin-side-wrap h2 {
background: #e5e5e5;
color: rgb(55, 55, 55);
padding-left: 5px;
}
.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: #e5e5e5;
color: rgb(55, 55, 55);
border-bottom-color: whitesmoke;
line-height: 40px;
}
.menu-selected {
font-size: 20px;
display: inline;
min-width: 150px;
height: 50px;
margin-left: 0;
margin-right: 10px;
padding: 5px;
background: #888888;
color: rgb(255, 255, 255);
border-bottom-color: whitesmoke;
}
.menu-item a {
text-decoration: none;
color: rgb(55, 55, 55);
}

1
styles/light.min.css vendored Normal file
View File

@ -0,0 +1 @@
@import url('./style.min.css');@CHARSET "UTF-8";#sqlite-admin-wrap h2,#sqlite-admin-side-wrap h2{background:#e5e5e5;color:#373737;padding-left:5px}.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:#e5e5e5;color:#373737;border-bottom-color:whitesmoke;line-height:40px}.menu-selected{font-size:20px;display:inline;min-width:150px;height:50px;margin-left:0;margin-right:10px;padding:5px;background:#888;color:#fff;border-bottom-color:whitesmoke}.menu-item a{text-decoration:none;color:#373737}

40
styles/midnight.css Normal file
View File

@ -0,0 +1,40 @@
@import url('./style.min.css');
@CHARSET "UTF-8";
#sqlite-admin-wrap h2,
#sqlite-admin-side-wrap h2 {
background: #363b3f;
color: rgb(255, 255, 255);
padding-left: 5px;
}
.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: #363b3f;
color: rgb(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;
background: #e14d43;
color: rgb(255, 255, 255);
}
.menu-item a {
text-decoration: none;
color: rgb(255, 255, 255);
}
.menu-item {
background: #363b3f;
color: rgb(255, 255, 255);
}

1
styles/midnight.min.css vendored Normal file
View File

@ -0,0 +1 @@
@import url('./style.min.css');@CHARSET "UTF-8";#sqlite-admin-wrap h2,#sqlite-admin-side-wrap h2{background:#363b3f;color:#fff;padding-left:5px}.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:#363b3f;color:#fff;line-height:40px}.menu-selected{font-size:20px;display:inline;min-width:150px;height:50px;margin-left:0;margin-right:10px;padding:5px;background:#e14d43;color:#fff}.menu-item a{text-decoration:none;color:#fff}.menu-item{background:#363b3f;color:#fff}

36
styles/ocean.css Normal file
View File

@ -0,0 +1,36 @@
@import url('./style.min.css');
@CHARSET "UTF-8";
#sqlite-admin-wrap h2,
#sqlite-admin-side-wrap h2 {
background: #738e96;
color: rgb(255, 255, 255);
padding-left: 5px;
}
.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: #738e96;
color: rgb(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;
background: #9ebaa0;
color: rgb(255, 255, 255);
}
.menu-item a {
text-decoration: none;
color: rgb(255, 255, 255);
}

1
styles/ocean.min.css vendored Normal file
View File

@ -0,0 +1 @@
@import url('./style.min.css');@CHARSET "UTF-8";#sqlite-admin-wrap h2,#sqlite-admin-side-wrap h2{background:#738e96;color:#fff;padding-left:5px}.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:#738e96;color:#fff;line-height:40px}.menu-selected{font-size:20px;display:inline;min-width:150px;height:50px;margin-left:0;margin-right:10px;padding:5px;background:#9ebaa0;color:#fff}.menu-item a{text-decoration:none;color:#fff}

View File

@ -1,22 +1,12 @@
/*
* Basic style for administration panel
*/
@CHARSET "UTF-8";
#sqlite-admin-wrap h2,
#sqlite-admin-side-wrap h2 {
background: rgb(73, 90, 88);
background: -moz-linear-gradient(bottom, rgba(73, 90, 88, 1), rgba(73, 90, 88, 0.5), rgba(73, 90, 88, 0));
background: -webkit-gradient(linear, bottom, top, from(rgba(73, 90, 88, 1)), color-stop(0.5, rgba(73, 90, 88, 0.5)), to(rgba(73, 90, 88, 0)));
background: linear-gradient(to top, rgba(73, 90, 88, 1), rgba(73, 90, 88, 0.2));
color: rgb(247, 254, 236);
-webkit-border-top-right-radius: 6px;
-webkit-border-top-left-radius: 6px;
-moz-border-radius-topright: 6px;
-moz-border-radius-topleft: 6px;
border-top-right-radius: 6px;
border-top-left-radius: 6px;
text-shadow: -1px -1px 0 rgb(93, 69, 35),
1px -1px 0 rgb(93, 69, 35),
-1px 1px 0 rgb(93, 69, 35),
1px 1px 0 rgb(93, 69, 35);
padding-left: 5px;
background: rgb(34, 34, 34);
color: rgb(255, 255, 255);
padding-left: 5px;
}
h3 {
clear: both;
@ -26,7 +16,6 @@ h3 {
margin-top: 0;
margin-bottom: 0;
min-height: 20px;
/* border: 1px solid #000; */
}
.navi-menu {
margin-left: 0;
@ -40,13 +29,9 @@ h3 {
margin-right: 10px;
padding: 5px;
border: .5px solit #000;
-webkit-border-top-right-radius: 6px;
-webkit-border-top-left-radius: 6px;
-moz-border-radius-topright: 6px;
-moz-border-radius-topleft: 6px;
border-top-right-radius: 6px;
border-top-left-radius: 6px;
box-shadow: 5px 5px 5px #eee;
background: rgb(51, 51, 51);
color: (255, 255, 255);
line-height: 40px;
}
.menu-selected {
font-size: 20px;
@ -57,51 +42,48 @@ h3 {
margin-right: 10px;
padding: 5px;
border: .5px solit #000;
background: rgb(46, 162, 204);
color: rgb(255, 255, 255);
}
.menu-item a {
text-decoration: none;
color: rgb(255, 255, 255);
}
#sqlite-admin-wrap {
color: #1d1d1d;
font-size: 11pt;
border: 1px solid #ddd;
background: rgb(255, 255, 255);
-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;
box-shadow: 5px 5px 5px #eee;
background: rgb(73, 90, 88);
background: -moz-linear-gradient(bottom, rgba(73, 90, 88, 1), rgba(73, 90, 88, 0.5), rgba(73, 90, 88, 0));
background: -webkit-gradient(linear, bottom, top, from(rgba(73, 90, 88, 1)), color-stop(0.5, rgba(73, 90, 88, 0.5)), to(rgba(73, 90, 88, 0)));
background: linear-gradient(to top, rgba(73, 90, 88, 1), rgba(73, 90, 88, 0.2));
color: rgb(247, 254, 236);
text-shadow: -1px -1px 0 rgb(93, 69, 35),
1px -1px 0 rgb(93, 69, 35),
-1px 1px 0 rgb(93, 69, 35),
1px 1px 0 rgb(93, 69, 35);
}
.menu-item a {
text-decoration: none;
}
#sqlite-admin-wrap {
color: #1d1d1d;
font-size: 10pt;
border: 1px solid #ddd;
/* border-top: 0; */
-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;
display: block;
float: left;
min-height: 100%;
position: relative;
width: 60%;
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: 10pt;
font-size: 11pt;
border: 1px solid #ddd;
background: rgb(255, 255, 255);
/* border-top: 0; */
-webkit-border-bottom-right-radius: 6px;
-webkit-border-bottom-left-radius: 6px;
@ -109,6 +91,12 @@ h3 {
-moz-border-radius-bottomleft: 6px;
border-bottom-right-radius: 6px;
border-bottom-left-radius: 6px;
-webkit-border-top-right-radius: 6px;
-webkit-border-top-left-radius: 6px;
-moz-border-radius-topright: 6px;
-moz-border-radius-topleft: 6px;
border-top-right-radius: 6px;
border-top-left-radius: 6px;
display: block;
float: left;
min-height: 100%;
@ -122,26 +110,29 @@ h3 {
p {
text-indent: 15px;
line-height: 150%;
font-size: 11pt;
margin-left: 10px;
margin-right: 10px;
}
table#sys-info{
/* width: 600px; */
width: 450px;
width: 80%;
}
table#status {
width: 450px;
width: 100%;
}
table#sqlite-table {
/* width: 700px; */
width: 650px;
width: 100%;
}
th.tbl-name {
width: 200px;
width: 25%;
}
th.tbl_owner {
width: 105px;
width: 25%;
}
th.tbl_index {
width: 350px;
width: 50%;
}
td.system {
color: rgb(153, 0, 0);
@ -150,12 +141,12 @@ td.user {
color: rgb(0, 0, 255);
}
td.menu-title {
width: 90px;
width: 95px;
}
table.statement {
width: 500px;
}
ul {
ul.in-body-list {
margin-left: 20px;
}
ol {
@ -166,6 +157,9 @@ pre.code {
margin-left: 15px;
margin-right: 10px;
background: #eee;
white-space: pre-wrap;
word-wrap: break-word;
overflow: auto;
}
tr.incompatible {
background: rgb(251, 229, 221);
@ -176,10 +170,10 @@ tr.workaround {
tr.compatible {
}
th.active-plugins {
width: 100px;
width: 20%;
}
th.compatible {
width: 80px;
width: 30%;
}
input.button-primary {
display: block;
@ -189,18 +183,23 @@ input.button-primary {
.alt {
background: rgb(247, 254, 236);
}
table#patch-files .item {
.em {
font-weight: bold;
text-transform: capitalize;
}
table#patch-files .item,
table#backup-files .item {
width: 40px;
}
.alert {
color: rgb(256, 0, 0);
color: rgb(255, 0, 0);
}
div.alert {
display: block;
width: 95%;
text-align: center;
margin: 0 auto;
color: rgb(256, 0, 0);
color: rgb(255, 0, 0);
text-transform: capitalize;
}
blockquote.caution {
@ -213,4 +212,151 @@ blockquote.caution {
blockquote.caution > p {
margin: 5px;
padding: 0;
}
#errorlog,
#dbfile {
width: 100%;
}
/*
* Media Query
*/
@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;
}
}

1
styles/style.min.css vendored Normal file
View File

@ -0,0 +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}}

36
styles/sunrise.css Normal file
View File

@ -0,0 +1,36 @@
@import url('./style.min.css');
@CHARSET "UTF-8";
#sqlite-admin-wrap h2,
#sqlite-admin-side-wrap h2 {
background: #cf4944;
color: rgb(255, 255, 255);
padding-left: 5px;
}
.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: #cf4944;
color: rgb(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;
background: #dd823b;
color: rgb(256, 256, 256);
}
.menu-item a {
text-decoration: none;
color: rgb(255, 255, 255);
}

1
styles/sunrise.min.css vendored Normal file
View File

@ -0,0 +1 @@
@import url('./style.min.css');@CHARSET "UTF-8";#sqlite-admin-wrap h2,#sqlite-admin-side-wrap h2{background:#cf4944;color:#fff;padding-left:5px}.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:#cf4944;color:#fff;line-height:40px}.menu-selected{font-size:20px;display:inline;min-width:150px;height:50px;margin-left:0;margin-right:10px;padding:5px;background:#dd823b;color:#100100100}.menu-item a{text-decoration:none;color:#fff}

View File

@ -0,0 +1,559 @@
<?php
/**
* database check and restoration
* This file is for temporary use and will be removed or changed in the future release.
*/
class DatabaseMaintenance {
private function sanity_check() {
global $wpdb;
$results_table = array();
$columns_to_check = array(
$wpdb->prefix.'commentmeta' => array(
'comment_id' => '\'0\'',
'meta_key' => 'NULL'
),
$wpdb->prefix.'comments' => array(
'comment_post_ID' => '\'0\'',
'comment_author_email' => '\'\'',
'comment_author_url' => '\'\'',
'comment_author_IP' => '\'\'',
'comment_date_gmt' => '\'0000-00-00 00:00:00\'',
'comment_date' => '\'0000-00-00 00:00:00\'',
'comment_karma' => '\'0\'',
'comment_approved' => '\'1\'',
'comment_agent' => '\'\'',
'comment_type' => '\'\'',
'comment_parent' => '\'0\'',
'user_id' => '\'0\''
),
$wpdb->prefix.'links' => array(
'link_url' => '\'\'',
'link_name' => '\'\'',
'link_image' => '\'\'',
'link_target' => '\'\'',
'link_description' => '\'\'',
'link_visible' => '\'Y\'',
'link_owner' => '\'1\'',
'link_rating' => '\'0\'',
'link_updated' => '\'0000-00-00 00:00:00\'',
'link_rel' => '\'\'',
'link_rss' => '\'\''
),
$wpdb->prefix.'options' => array(
'option_name' => '\'\'',
'autoload' => '\'yes\''
),
$wpdb->prefix.'postmeta' => array(
'post_id' => '\'0\'',
'meta_key' => 'NULL'
),
$wpdb->prefix.'posts' => array(
'post_author' => '\'0\'',
'post_date_gmt' => '\'0000-00-00 00:00:00\'',
'post_date' => '\'0000-00-00 00:00:00\'',
'post_status' => '\'publish\'',
'comment_status' => '\'open\'',
'ping_status' => '\'open\'',
'post_password' => '\'\'',
'post_name' => '\'\'',
'post_modified_gmt' => '\'0000-00-00 00:00:00\'',
'post_modified' => '\'0000-00-00 00:00:00\'',
'post_parent' => '\'0\'',
'guid' => '\'\'',
'menu_order' => '\'0\'',
'post_type' => '\'post\'',
'post_mime_type' => '\'\'',
'comment_count' => '\'0\''
),
$wpdb->prefix.'term_relationships' => array(
'term_order' => '0'
),
$wpdb->prefix.'term_taxonomy' => array(
'taxonomy' => '\'\'',
'parent' => '0',
'count' => '0'
),
$wpdb->prefix.'terms' => array(
'name' => '\'\'',
'slug' => '\'\'',
'term_group' => '0'
),
$wpdb->prefix.'users' => array(
'user_login' => '\'\'',
'user_pass' => '\'\'',
'user_nicename' => '\'\'',
'user_email' => '\'\'',
'user_url' => '\'\'',
'user_registered' => '\'0000-00-00 00:00:00\'',
'user_activation_key' => '\'\'',
'user_status' => '\'0\'',
'display_name' => '\'\'',
// for network install
'spam' => '\'0\'',
'deleted' => '\'0\''
),
$wpdb->prefix.'usermeta' => array(
'user_id' => '\'0\'',
'meta_key' => 'NULL',
),
// for network install
$wpdb->prefix.'blog_versions' => array(
'blog_id' => '\'0\'',
'db_version' => '\'\'',
'last_updated' => '\'0000-00-00 00:00:00\''
),
$wpdb->prefix.'blogs' => array(
'site_id' => '\'0\'',
'domain' => '\'\'',
'path' => '\'\'',
'registered' => '\'0000-00-00 00:00:00\'',
'last_updated' => '\'0000-00-00 00:00:00\'',
'public' => '\'1\'',
'mature' => '\'0\'',
'spam' => '\'0\'',
'deleted' => '\'0\'',
'lang_id' => '\'0\''
),
$wpdb->prefix.'registration_log' => array(
'email' => '\'\'',
'IP' => '\'\'',
'blog_id' => '\'0\'',
'date_registered' => '\'0000-00-00 00:00:00\''
),
$wpdb->prefix.'signups' => array(
'domain' => '\'\'',
'path' => '\'\'',
'user_login' => '\'\'',
'user_email' => '\'\'',
'registered' => '\'0000-00-00 00:00:00\'',
'activated' => '\'0000-00-00 00:00:00\'',
'active' => '\'0\'',
'activation_key' => '\'\'',
),
$wpdb->prefix.'site' => array(
'domain' => '\'\'',
'path' => '\'\''
),
$wpdb->prefix.'sitemeta' => array(
'site_id' => '\'0\'',
'meta_key' => 'NULL',
)
);
$tables = $wpdb->tables('all');
foreach ($tables as $table) {
$col_infos = $wpdb->get_results("SHOW COLUMNS FROM $table");
foreach ($col_infos as $col) {
if (array_key_exists($col->Field, $columns_to_check[$table]) && $col->Default != $columns_to_check[$table][$col->Field]) {
$results_table[$table] = 'damaged';
break;
}
}
}
if (empty($results_table)) {
return true;
} else {
return $results_table;
}
}
private function do_fix_database() {
global $wpdb, $wp_version, $utils;
$global_schema_to_change = array(
$wpdb->prefix.'commentmeta' => array(
"comment_id bigint(20) unsigned NOT NULL default '0'",
"meta_key varchar(255) default NULL",
"meta_value longtext"
),
$wpdb->prefix.'comments' => array(
"comment_post_ID bigint(20) unsigned NOT NULL default '0'",
"comment_author_email varchar(100) NOT NULL default ''",
"comment_author_url varchar(200) NOT NULL default ''",
"comment_author_IP varchar(100) NOT NULL default ''",
"comment_date datetime NOT NULL default '0000-00-00 00:00:00'",
"comment_date_gmt datetime NOT NULL default '0000-00-00 00:00:00'",
"comment_karma int(11) NOT NULL default '0'",
"comment_approved varchar(20) NOT NULL default '1'",
"comment_agent varchar(255) NOT NULL default ''",
"comment_type varchar(20) NOT NULL default ''",
"comment_parent bigint(20) unsigned NOT NULL default '0'",
"user_id bigint(20) unsigned NOT NULL default '0'"
),
$wpdb->prefix.'links' => array(
"link_url varchar(255) NOT NULL default ''",
"link_name varchar(255) NOT NULL default ''",
"link_image varchar(255) NOT NULL default ''",
"link_target varchar(25) NOT NULL default ''",
"link_description varchar(255) NOT NULL default ''",
"link_visible varchar(20) NOT NULL default 'Y'",
"link_owner bigint(20) unsigned NOT NULL default '1'",
"link_rating int(11) NOT NULL default '0'",
"link_updated datetime NOT NULL default '0000-00-00 00:00:00'",
"link_rel varchar(255) NOT NULL default ''",
"link_notes mediumtext NOT NULL",
"link_rss varchar(255) NOT NULL default ''"
),
$wpdb->prefix.'options' => array(
"option_name varchar(64) NOT NULL default ''",
"option_value longtext NOT NULL",
"autoload varchar(20) NOT NULL default 'yes'"
),
$wpdb->prefix.'postmeta' => array(
"post_id bigint(20) unsigned NOT NULL default '0'",
"meta_key varchar(255) default NULL",
"meta_value longtext"
),
$wpdb->prefix.'posts' => array(
"post_author bigint(20) unsigned NOT NULL default '0'",
"post_date datetime NOT NULL default '0000-00-00 00:00:00'",
"post_date_gmt datetime NOT NULL default '0000-00-00 00:00:00'",
"post_status varchar(20) NOT NULL default 'publish'",
"comment_status varchar(20) NOT NULL default 'open'",
"ping_status varchar(20) NOT NULL default 'open'",
"post_password varchar(20) NOT NULL default ''",
"post_name varchar(200) NOT NULL default ''",
"post_modified datetime NOT NULL default '0000-00-00 00:00:00'",
"post_modified_gmt datetime NOT NULL default '0000-00-00 00:00:00'",
"post_content_filtered longtext NOT NULL",
"post_parent bigint(20) unsigned NOT NULL default '0'",
"guid varchar(255) NOT NULL default ''",
"menu_order int(11) NOT NULL default '0'",
"post_type varchar(20) NOT NULL default 'post'",
"post_mime_type varchar(100) NOT NULL default ''",
"comment_count bigint(20) NOT NULL default '0'"
),
$wpdb->prefix.'term_relationships' => array(
"term_order int(11) NOT NULL default 0"
),
$wpdb->prefix.'term_taxonomy' => array(
"taxonomy varchar(32) NOT NULL default ''",
"description longtext NOT NULL",
"parent bigint(20) unsigned NOT NULL default 0",
"count bigint(20) NOT NULL default 0"
),
$wpdb->prefix.'terms' => array(
"name varchar(200) NOT NULL default ''",
"slug varchar(200) NOT NULL default ''",
"term_group bigint(10) NOT NULL default 0"
),
$wpdb->prefix.'users' => array(
"user_login varchar(60) NOT NULL default ''",
"user_pass varchar(64) NOT NULL default ''",
"user_nicename varchar(50) NOT NULL default ''",
"user_email varchar(100) NOT NULL default ''",
"user_url varchar(100) NOT NULL default ''",
"user_registered datetime NOT NULL default '0000-00-00 00:00:00'",
"user_activation_key varchar(60) NOT NULL default ''",
"user_status int(11) NOT NULL default '0'",
"display_name varchar(250) NOT NULL default ''"
),
$wpdb->prefix.'usermeta' => array(
"user_id bigint(20) unsigned NOT NULL default '0'",
"meta_key varchar(255) default NULL",
"meta_value longtext"
)
);
$network_schema_to_change = array(
$wpdb->prefix.'blog_versions' => array(
"blog_id bigint(20) NOT NULL default '0'",
"db_version varchar(20) NOT NULL default ''",
"last_updated datetime NOT NULL default '0000-00-00 00:00:00'"
),
$wpdb->prefix.'blogs' => array(
"site_id bigint(20) NOT NULL default '0'",
"domain varchar(200) NOT NULL default ''",
"path varchar(100) NOT NULL default ''",
"registered datetime NOT NULL default '0000-00-00 00:00:00'",
"last_updated datetime NOT NULL default '0000-00-00 00:00:00'",
"public tinyint(2) NOT NULL default '1'",
"mature tinyint(2) NOT NULL default '0'",
"spam tinyint(2) NOT NULL default '0'",
"deleted tinyint(2) NOT NULL default '0'",
"lang_id int(11) NOT NULL default '0'"
),
$wpdb->prefix.'registration_log' => array(
"email varchar(255) NOT NULL default ''",
"IP varchar(30) NOT NULL default ''",
"blog_id bigint(20) NOT NULL default '0'",
"date_registered datetime NOT NULL default '0000-00-00 00:00:00'"
),
$wpdb->prefix.'signups' => array(
"domain varchar(200) NOT NULL default ''",
"path varchar(100) NOT NULL default ''",
"title longtext NOT NULL",
"user_login varchar(60) NOT NULL default ''",
"user_email varchar(100) NOT NULL default ''",
"registered datetime NOT NULL default '0000-00-00 00:00:00'",
"activated datetime NOT NULL default '0000-00-00 00:00:00'",
"active tinyint(1) NOT NULL default '0'",
"activation_key varchar(50) NOT NULL default ''",
"meta longtext"
),
$wpdb->prefix.'site' => array(
"domain varchar(200) NOT NULL default ''",
"path varchar(100) NOT NULL default ''"
),
$wpdb->prefix.'sitemeta' => array(
"site_id bigint(20) NOT NULL default '0'",
"meta_key varchar(255) default NULL",
"meta_value longtext"
),
$wpdb->prefix.'users' => array(
"user_login varchar(60) NOT NULL default ''",
"spam tinyint(2) NOT NULL default '0'",
"deleted tinyint(2) NOT NULL default '0'"
)
);
if (version_compare($wp_version, '3.6', '<')) return false;
$return_val = array();
$queries = array();
$results = $this->sanity_check();
if ($results !== true) {
if (!$this->maintenance_backup()) {
$message = __('Can\'t create backup file.', $domain);
return $message;
}
$tables = array_keys($results);
foreach ($tables as $table) {
if (key_exists($table, $global_schema_to_change)) {
$queries = $global_schema_to_change[$table];
}
if (key_exists($table, $network_schema_to_change)) {
if (!empty($queries)) {
$queries = array_merge($queries, $network_schema_to_change[$table]);
} else {
$queries = $network_schema_to_change[$table];
}
}
foreach ($queries as $query) {
$sql = 'ALTER TABLE' . ' ' . $table . ' ' . 'CHANGE COLUMN' . ' ' . $query;
$res = $wpdb->query($sql);
if ($res === false) {
$return_val[] = __('Failed: ', $domain) . $query;
}
}
}
} else {
$message = __('Your database is OK. You don\'t have to restore it.', $domain);
return $message;
}
if (empty($return_val)) {
$message = __('Your database restoration is successfully finished!', $domain);
return $message;
} else {
return $return_val;
}
}
private function show_columns() {
global $wpdb, $utils;
$domain = $utils->text_domain;
$tables = $wpdb->tables('all');
if (!isset($_POST['table'])) {
$message = __('Table name is not selected.', $domain);
return $message;
} elseif (!in_array($_POST['table'], $tables)) {
$message = __('There\'s no such table.', $domain);
return $message;
} else {
$table_name = $_POST['table'];
$results = $wpdb->get_results("SHOW COLUMNS FROM $table_name");
return $results;
}
}
private function maintenance_backup() {
$result = array();
$database_file = FQDB;
$db_name = basename(FQDB);
if (!file_exists($database_file)) {
return false;
}
$today = date("Ymd-His");
if (!extension_loaded('zip')) {
$backup_file = $database_file . '.' . $today . '.maintenance-backup';
if (copy($database_file, $backup_file)) {
$result = true;
} else {
$result = false;
}
} else {
$backup_file = $database_file . '.' . $today . '.maintenance-backup.zip';
$zip = new ZipArchive();
$res = $zip->open($backup_file, ZipArchive::CREATE | ZipArchive::OVERWRITE);
if ($res === true) {
$zip->addFile($database_file, $db_name);
$result = true;
} else {
$result = false;
}
$zip->close();
}
return $result;
}
function show_maintenance_page() {
global $utils, $wpdb;
$domain = $utils->text_domain;
if (is_multisite() && !current_user_can('manage_network_options')) {
die(__('You are not allowed to access this page!', $domain));
} elseif (!current_user_can('manage_options')) {
die(__('You are not allowed to access this page!', $domain));
}
if (isset($_GET['page']) && $_GET['page'] == 'maintenance') : ?>
<div class="navigation">
<ul class="navi-menu">
<li class="menu-item"><a href="<?php echo $utils->show_parent();?>?page=doc"><?php _e('Documentation', $domain);?></a></li>
<li class="menu-item"><a href="<?php echo $utils->show_parent();?>?page=sys-info"><?php _e('System Info', $domain);?></a></li>
<li class="menu-item"><a href="<?php echo $utils->show_parent();?>?page=setting-file"><?php _e('Miscellaneous', $domain);?></a></li>
<li class="menu-item"><a href="<?php echo $utils->show_parent();?>?page=patch"><?php _e('Patch Utility', $domain);?></a></li>
<li class="menu-selected"><?php _e('Maintenance', $domain);?></li>
</ul>
</div>
<div class="wrap" id="sqlite-admin-wrap">
<h2><?php _e('Database Maintenace', $domain);?></h2>
<h3><?php _e('Important Notice', $domain);?></h3>
<p>
<span style="color: red;"><?php _e('When you installed WordPress 3.5.x with SQLite Integration and upgraded to 3.6, your database might not function as expected.', $domain);?></span>
<?php _e('This page provide you the database sanity check utility and the restore utility.', $domain);?>
</p>
<p>
<?php _e('Click "Sanity Check" button first, and see if you need to fix database or not. If needed, click "Fix Database" button. Afterward you may go to Miscellaneous page and optimize database (this is not required).', $domain);?>
</p>
<p>
<?php _e('Fix Database procedure will create a database backup file each time the button clicked. The backup file is named with "maintenance-backup", so you can remove it if you don\'t need it. Please go to Miscellaneous page and check if there is one.', $domain);?>
</p>
<p>
<?php _e('If you installed WordPress 3.6 (not upgraded), you don\'t have to restore the database.', $domain);?>
</p>
<form action="" method="post">
<?php
if (function_exists('wp_nonce_field')) {
wp_nonce_field('sqliteintegration-database-manip-stats');
}
?>
<input type="submit" name="sanity-check" class="button-primary" value="<?php _e('Sanity Check', $domain);?>" onclick="return confirm('<?php _e('Are you sure to check the database? This will take some time.\n\nClick [Cancel] to stop, [OK] to continue.', $domain);?>')" />
<input type="submit" name="do-fix-database" class="button-primary" value="<?php _e('Fix database', $domain);?>" onclick="return confirm('<?php _e('Are you sure to do fix the database? This will take some time.\n\nClick [Cancel] to stop, [OK] to continue.', $domain);?>')" />
</form>
<?php if (defined('WP_DEBUG') && WP_DEBUG == true) : ?>
<h3><?php _e('Columns Information', $domain);?></h3>
<p>
<?php _e('Select a table name and click "Display Columns" button, and you\'ll see the column property of that table. This information is for debug use.', $domain);?>
</p>
<?php
$wp_tables = $wpdb->tables('all');
?>
<form action="" method="post">
<?php
if (function_exists('wp_nonce_field')) {
wp_nonce_field('sqliteintegration-database-manip-stats');
}
?>
<label for="table"/><?php _e('Table Name: ', $domain);?></label>
<select name="table" id="table">
<?php foreach ($wp_tables as $table) :?>
<option value="<?php echo $table;?>"><?php echo $table;?></option>
<?php endforeach;?>
</select>
<input type="submit" name="show-columns" class="button-secondary" value="<?php _e('Display Columns', $domain);?>" onclick="return confirm('<?php _e('Display columns in the selected table.\n\nClick [Cancel] to stop, [OK] to continue.', $domain);?>')" />
</form>
<?php endif; ?>
</div>
<?php endif;
if (isset($_POST['do-fix-database'])) {
check_admin_referer('sqliteintegration-database-manip-stats');
if (is_multisite() && !current_user_can('manage_network_options')) {
die(__('You are not allowed to do this operation!', $domain));
} elseif (!current_user_can('manage_options')) {
die(__('You are not allowed to do this operation!', $domain));
}
$fix_results = $this->do_fix_database();
if (is_array($fix_results)) {
$title = '<h3>'. __('Results', $domain) . '</h3>';
echo '<div class="wrap" id="sqlite-admin-side-wrap">';
echo $title;
echo '<ul>';
foreach ($fix_results as $result) {
echo '<li>' . $result . '</li>';
}
echo '</ul>';
echo '</div>';
} else {
$title = '<h3>'. __('Results', $domain) . '</h3>';
echo '<div class="wrap" id="sqlite-admin-side-wrap">';
echo $title;
echo '<p>'.$fix_results.'</p>';
echo '</div>';
}
}
if (isset($_POST['sanity-check'])) {
check_admin_referer('sqliteintegration-database-manip-stats');
if (is_multisite() && !current_user_can('manage_network_options')) {
die(__('You are not allowed to do this operation!', $domain));
} elseif (!current_user_can('manage_options')) {
die(__('You are not allowed to do this operation!', $domain));
}
$check_results = $this->sanity_check();
if ($check_results !== true) {
$title = '<h3>'. __('Checked Results', $domain) . '</h3>';
echo '<div class="wrap" id="sqlite-admin-side-wrap">';
echo $title;
echo '<ul>';
foreach ($check_results as $table => $damaged) {
$message = __(' needs restoring.', $domain);
echo '<li><span class="em">' . $table . '</span>' . $message . '</li>';
}
echo '</ul>';
echo '</div>';
} else {
$title = '<h3>'. __('Checked Results', $domain) . '</h3>';
$message = __('Your database is OK. You don\'t have to restore it.', $domain);
echo '<div class="wrap" id="sqlite-admin-side-wrap">';
echo $title;
echo '<p>'.$message.'</p>';
echo '</div>';
}
}
if (isset($_POST['show-columns'])) {
check_admin_referer('sqliteintegration-database-manip-stats');
if (is_multisite() && !current_user_can('manage_network_options')) {
die(__('You are not allowed to do this operation!', $domain));
} elseif (!current_user_can('manage_options')) {
die(__('You are not allowed to do this operation!', $domain));
}
$results = $this->show_columns();
if (is_array($results)) {
$title = '<h3>'. sprintf(__('Columns In %s', $domain), $_POST['table']) . '</h3>';
$column_header = __('Column', $domain);
$type_header = __('Type', $domain);
$null_header = __('Null', $domain);
$default_header = __('Default', $domain);
echo '<div class="wrap" id="sqlite-admin-side-wrap" style="clear: both;">';
echo $title;
echo '<table class="widefat page fixed"><thead><tr><th>'. $column_header . '</th><th>'. $type_header . '</th><th>' . $null_header . '</th><th>' . $default_header . '</th></tr></thead>';
echo '<tbody>';
$counter = 0;
foreach ($results as $column) {
echo (($counter % 2) == 1) ? '<tr class="alt">' : '<tr>';
echo '<td>' . $column->Field . '</td>';
echo '<td>' . $column->Type . '</td>';
echo '<td>' . $column->Null . '</td>';
echo '<td>' . $column->Default . '</td>';
echo '</tr>';
$counter++;
}
echo '</tbody></table></div>';
} else {
$title = '<h3>'. __('Columns Info', $domain) . '</h3>';
echo '<div class="wrap" id="sqlite-admin-side-wrap">';
echo $title;
echo '<p>' . $results;
echo '</p></div>';
}
}
}
}
?>

View File

@ -1,8 +1,7 @@
<?php
/**
* @package SQLite Integration
* @version 1.1
* @author Toshiyasu Kojima
* @author Kojima Toshiyasu
*
*/
/**
@ -25,6 +24,7 @@ class SQLiteIntegrationDocument {
<li class="menu-item"><a href="<?php echo $utils->show_parent();?>?page=sys-info"><?php _e('System Info', $domain); ?></a></li>
<li class="menu-item"><a href="<?php echo $utils->show_parent();?>?page=setting-file"><?php _e('Miscellaneous', $domain);?></a></li>
<li class="menu-item"><a href="<?php echo $utils->show_parent();?>?page=patch"><?php _e('Patch Utility', $domain);?></a></li>
<li class="menu-item"><a href="<?php echo $utils->show_parent();?>?page=maintenance"><?php _e('Maintenance', $domain);?></a></li>
</ul>
</div>
<div class="wrap" id="sqlite-admin-wrap">
@ -38,7 +38,7 @@ class SQLiteIntegrationDocument {
<h3><?php _e('Features', $domain);?></h3>
<p>
<?php _e('This plugin is a successor to <a href="http://wordpress.org/extend/plugins/pdo-for-wordpress/">PDO for WordPress</a>, which enabled WordPress to use SQLite for its database. But PDO for WordPress doesn\'t seem to be maintained any more only to be outdated. SQLite Integration makes use of the basic ideas and framework of PDO for WordPress, adds some new features and updates it to be able to work with the newest version of WordPress(3.5.1 and 3.6 beta).', $domain); ?>
<?php _e('This plugin is a successor to <a href="http://wordpress.org/extend/plugins/pdo-for-wordpress/">PDO for WordPress</a>, which enabled WordPress to use SQLite for its database. But PDO for WordPress doesn\'t seem to be maintained any more only to be outdated. SQLite Integration makes use of the basic ideas and framework of PDO for WordPress, adds some new features and updates it to be able to work with the newest version of WordPress(3.8).', $domain); ?>
</p>
<p>
<?php _e('<a href="http://www.sqlite.org/">SQLite Web Page</a> says &mdash; SQLite is a &quot;software library that implements selfcontained, serverless, zero-configuration, transactional SQL database engine&quot;. It is &quot;a good choice for small to medium size websites&quot;. It\'s small and portable, and you don\'t need any database server system.', $domain); ?>
@ -86,7 +86,7 @@ class SQLiteIntegrationDocument {
<p>
<?php _e('SQLite Integration doesn\'t contain database maintenace functionality, because there are some other free or proprietary softwares that give you such functionalities. For example, these are among free softwares:', $domain);?>
</p>
<ul>
<ul class="in-body-list">
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/">SQLite Manager Mozilla Addon</a>(<?php _e('my recommendation', $domain);?>)</li>
<li><a href="http://www.sqlitemanager.org/">SQLiteManager</a>(<?php _e('unfortunately seems not to maintained...', $domain); ?>)</li>
</ul>
@ -109,8 +109,8 @@ class SQLiteIntegrationDocument {
<thead>
<tr>
<th data-sort='{"key":"name"}' class="item"><?php _e('Plugins Name', $domain); ?></th>
<th data-sort='{"key":"compat"}'><?php _e('Compatibility', $domain); ?></th>
<th data-sort='{"key":"reason"}'><?php _e('Reasons', $domain);?></th>
<th data-sort='{"key":"compat"}' class="compat"><?php _e('Compatibility', $domain); ?></th>
<th data-sort='{"key":"reason"}' class="reason"><?php _e('Reasons', $domain);?></th>
</tr>
</thead>
<tbody>
@ -131,8 +131,8 @@ class SQLiteIntegrationDocument {
<td><?php _e('No', $domain);?></td>
<?php endif;?>
<td><?php echo $plugin_info->reason;?></td>
<?php endif;?>
</tr>
<?php endif;?>
<?php endforeach;?>
<?php endif;?>
</tbody>

2
utilities/index.php Normal file
View File

@ -0,0 +1,2 @@
<?php
/* Silence is golden */

View File

@ -3,7 +3,7 @@
* This file contains PatchUtils class
*
* @package SQLite Integration
* @since 1.1
* @author Kojima Toshiyasu
*
*/
class PatchUtils {
@ -34,11 +34,14 @@ class PatchUtils {
* @return boolean|array
*/
private function apply_patches() {
global $utils;
$domain = $utils->text_domain;
$installed_plugins = array();
$file_names = array();
$output = array();
$retval = 0;
$patch_results = array();
$message = '';
if (isset($_POST['plugin_checked'])) {
$file_names = $_POST['plugin_checked'];
} else {
@ -103,6 +106,8 @@ class PatchUtils {
* @return boolean|array
*/
private function delete_patch_files() {
global $utils;
$domain = $utils->text_domain;
$file_names = array();
$rm_results = array();
if (isset($_POST['plugin_checked'])) {
@ -110,18 +115,16 @@ class PatchUtils {
} else {
return false;
}
$command = 'rm -f';
foreach ($file_names as $file) {
if (chdir(SQLitePatchDir)) {
exec("$command $file", $output, $retval);
} else {
$rm_results[$file] = __('Error!: patches directory is not accessible.', $domain);
}
if ($retval > 0) {
$rm_results[$file] = sprintf(__('Error! Messages: %s', $domain), $output);
} else {
$rm_results[$file] = sprintf(__('File %s is deleted.', $domain), $file);
}
if (chdir(SQLitePatchDir)) {
foreach ($file_names as $file) {
if (unlink($file)) {
$rm_results[$file] = sprintf(__('File %s is deleted.', $domain), $file);
} else {
$rm_results[$file] = sprintf(__('Error! File %s is not deleted.', $domain), $file);
}
}
} else {
$rm_results[$file] = __('Error!: patches directory is not accessible.', $domain);
}
return $rm_results;
}
@ -130,6 +133,8 @@ class PatchUtils {
* No return values.
*/
private function upload_file() {
global $utils;
$domain = $utils->text_domain;
if (!file_exists(SQLitePatchDir) || !is_dir(SQLitePatchDir)) {
mkdir(SQLitePatchDir, 0705, true);
}
@ -198,7 +203,7 @@ class PatchUtils {
}
echo '</div>';
} else {
$message = __('Error! Please remove files manually');
$message = __('Error! Please remove files manually', $domain);
echo '<div id="message" class="updated fade">'.$message.'</div>';
}
}
@ -218,6 +223,7 @@ class PatchUtils {
<li class="menu-item"><a href="<?php echo $utils->show_parent();?>?page=sys-info"><?php _e('System Info', $domain);?></a></li>
<li class="menu-item"><a href="<?php echo $utils->show_parent();?>?page=setting-file"><?php _e('Miscellaneous', $domain);?></a></li>
<li class="menu-selected"><?php _e('Patch Utility', $domain);?></li>
<li class="menu-item"><a href="<?php echo $utils->show_parent();?>?page=maintenance"><?php _e('Maintenance', $domain);?></a></li>
</ul>
</div>
<div class="wrap" id="sqlite-admin-wrap">

View File

@ -22,7 +22,14 @@
"compat":"Checked",
"class":"compatible"
},
{
"name":"Better Delete Revision",
"compat":"No",
"reason":"DELETE with JOIN/etc",
"class":"incompatible"
},
{
"name":"Better Related Posts",
"compat":"No",
@ -111,6 +118,14 @@
"class":"compatible"
},
{
"name":"FeedWordPress",
"compat":"Needs patch",
"patch_url":"http://dogwood.skr.jp/wordpress/plugins/",
"reason":"MySQL specific function",
"class":"workaround"
},
{
"name":"Google Analyticator",
"compat":"Checked",
@ -162,6 +177,34 @@
"class":"compatible"
},
{
"name":"Mathjax Latex",
"compat":"Checked",
"class":"compatible"
},
{
"name":"MP6",
"compat":"Checked",
"class":"compatible"
},
{
"name":"NewStatPress",
"compat":"Needs Patch",
"patch_url":"http://dogwood.skr.jp/wordpress/plugins/",
"reason":"MySQL specific data",
"class":"workaround"
},
{
"name":"NextGEN Gallery",
"compat":"Needs patch",
"patch_url":"http://dogwood.skr.jp/wordpress/plugins/",
"reason":"MySQL specific function",
"class":"workaround"
},
{
"name":"Optimize Database after Deleting Revisions",
"compat":"Probably No",
@ -175,6 +218,12 @@
"class":"compatible"
},
{
"name":"Redirection",
"compat":"Checked",
"class":"compatible"
},
{
"name":"Related Posts",
"compat":"Checked",
@ -237,12 +286,20 @@
{
"name":"Wordpress Popular Posts",
"compat":"Needs Patch",
"patch_url":"http://dogwood.skr.jp/wordpress/plugins/",
"reason":"MySQL specific query",
"class":"workaround"
},
{
"name":"WordPress Related Posts",
"compat":"Checked",
"class":"compatible"
},
{
"name":"WordPress Related Posts",
"name":"WP Emmet",
"compat":"Checked",
"class":"compatible"
},
@ -264,7 +321,13 @@
"compat":"Checked",
"class":"compatible"
},
{
"name":"WP-PostViews",
"compat":"Checked",
"class":"compatible"
},
{
"name":"WP-reCAPTCHA",
"compat":"Checked",

View File

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