Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Hannes Landeholm committed Sep 25, 2014
0 parents commit c9ca728
Show file tree
Hide file tree
Showing 48 changed files with 14,127 additions and 0 deletions.
8 changes: 8 additions & 0 deletions BUGS
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
* Version 1.7 can't create wp-config.php when installing with WordPress 4.0

When install process notices that there's no wp-config.php, it tries to
create one from wp-config-sample.php. During that time, WordPress unsets
global $wpdb and calls require_wp_db() function.
That function newly instantiates wpdb class. SQLite Integration has no
way of intercepting that process.

8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
2014-09-05 KOJIMA Toshiyasu

* version 1.7 release.
* update readme.txt and readme-ja.txt.

2014-08-29 KOJIMA Toshiyasu

* Added ChangeLog and BUGS files.
130 changes: 130 additions & 0 deletions db.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?php
/**
* This file defines some constant required for SQLite Integration.
*
* This file must be placed in the directory wordpress/wp-content/db.php.
* WordPress loads this file automatically.
*
* @version 1.7
* @package SQLite Integration
* @author Kojima Toshiyasu
*
*/
if (!defined('ABSPATH')) { // Oh, you are not WordPress!
echo 'Thank you, but you are not allowed to access here.';
die();
}

/*
* USE_MYSQL is a directive for using MySQL for database.
* If you want to change the database from SQLite to MySQL or from MySQL to SQLite,
* the line below in the wp-config.php will enable you to use MySQL.
*
* <code>
* define('USE_MYSQL', true);
* </code>
*
* If you want to use SQLite, the line below will do. Or simply removing the line will
* be enough.
*
* <code>
* define('USE_MYSQL', false);
* </code>
*/
if (defined('USE_MYSQL') && USE_MYSQL) return;

function pdo_log_error($message, $data = null) {
if (strpos($_SERVER['SCRIPT_NAME'], 'wp-admin') !== false) {
$admin_dir = '';
} else {
$admin_dir = 'wp-admin/';
}
die(<<<HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>WordPress &rsaquo; Error</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="{$admin_dir}css/install.css" type="text/css" />
</head>
<body>
<h1 id="logo"><img alt="WordPress" src="{$admin_dir}images/wordpress-logo.png" /></h1>
<p>$message</p>
<p>$data</p>
</body>
<html>
HTML
);
}

if (version_compare( PHP_VERSION, '5.2.4', '<')) {
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_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_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.');
}

/*
* Notice:
* Your scripts have the permission to create directories or files on your server.
* If you write in your wp-config.php like below, we take these definitions.
* define('DB_DIR', '/full_path_to_the_database_directory/');
* define('DB_FILE', 'database_file_name');
*/

/*
* PDODIR is SQLite Integration installed directory.
*/
if (defined('WP_PLUGIN_DIR')) {
define('PDODIR', WP_PLUGIN_DIR . '/sqlite-integration/');
} else {
if (defined('WP_CONTENT_DIR')) {
define('PDODIR', WP_CONTENT_DIR . '/plugins/sqlite-integration/');
} else {
define('PDODIR', ABSPATH . 'wp-content/plugins/sqlite-integration/');
}
}
/*
* FQDBDIR is a directory where the sqlite database file is placed.
* If DB_DIR is defined, it is used as FQDBDIR.
*/
if (defined('DB_DIR')) {
if (substr(DB_DIR, -1, 1) != '/') {
define('FQDBDIR', DB_DIR . '/');
} else {
define('FQDBDIR', DB_DIR);
}
} else {
if (defined('WP_CONTENT_DIR')) {
define('FQDBDIR', WP_CONTENT_DIR . '/database/');
} else {
define('FQDBDIR', ABSPATH . 'wp-content/database/');
}
}
/*
* FQDB is a database file name. If DB_FILE is defined, it is used
* as FQDB.
*/
if ( defined('DB_FILE' )) {
define('FQDB', FQDBDIR . DB_FILE);
} else {
define('FQDB', FQDBDIR . '.ht.sqlite');
}
/*
* UDF_FILE is a file that contains user defined functions.
*/
if (version_compare(PHP_VERSION, '5.3', '<')) {
define('UDF_FILE', PDODIR . 'functions-5-2.php');
} elseif (version_compare(PHP_VERSION, '5.3', '>=')) {
define('UDF_FILE', PDODIR . 'functions.php');
}

require_once PDODIR . 'pdodb.class.php';
?>

0 comments on commit c9ca728

Please sign in to comment.