> SQLite Integration >> Miscellaneous, and click the button "update" at the bottom of the page. Or else replace wp-content/db.php with the one in sqlite-integration directory manually.', 'sqlite-integration'); $current_version = defined('SQLITE_INTEGRATION_VERSION') ? SQLITE_INTEGRATION_VERSION : ''; if (version_compare($current_version, '1.6.1', '=')) return; $version = ''; if (defined('WP_CONTENT_DIR')) { $path = WP_CONTENT_DIR . '/db.php'; } else { $path = ABSPATH . 'wp-content/db.php'; } if (!$file_handle = @fopen($path, 'r')) return; while (($buffer = fgets($file_handle)) !== false) { if (stripos($buffer, '@version') !== false) { $version = str_ireplace('*@version ', '', $buffer); $version = trim($version); break; } } fclose($file_handle); if (empty($version) || version_compare($version, $current_version, '<')) { echo '
* sys_info['WordPress'] => WordPress Version
* sys_info['PHP'] => PHP Version
*
*
* @return array
* @access private
*/
private function get_system_info() {
global $wp_version;
$sys_info = array();
$sys_info['WordPress'] = $wp_version;
$sys_info['PHP'] = PHP_VERSION;
return $sys_info;
}
/**
* Method to get database information from the database and returns its data.
*
* Returned value is an associative array.
*
* @return array
* @access private
*/
private function get_database_status() {
global $wpdb;
$status = array();
$db_size = $this->get_database_size();
$encoding = $wpdb->get_var("PRAGMA encoding");
$integrity = $wpdb->get_var("PRAGMA integrity_check");
$page_size = $wpdb->get_var("PRAGMA page_size");
$page_count = $wpdb->get_var("PRAGMA page_count");
$unused_page = $wpdb->get_var("PRAGMA freelist_count");
$collation_list = $wpdb->get_results("PRAGMA collation_list");
$compile_options = $wpdb->get_results("PRAGMA compile_options");
foreach ($collation_list as $col) {
$collations[] = $col->name;
}
foreach ($compile_options as $opt) {
$options[] = $opt->compile_option;
}
$status['size'] = $db_size;
$status['integrity'] = $integrity;
$status['pagesize'] = $page_size;
$status['page'] = $page_count;
$status['unused'] = $unused_page;
$status['encoding'] = $encoding;
$status['collations'] = $collations;
$status['options'] = $options;
return $status;
}
/**
* Method to get table information and returns its data.
*
* Returned value is an associative array like:
*
* array( table name => array( index name ( column name )))
*
* for each table in the database
*
* @return array
* @access private
*/
private function get_tables_info() {
global $wpdb;
$table_info = array();
$tables = $wpdb->get_col("SHOW TABLES");
foreach ($tables as $table) {
$index_object = $wpdb->get_results("SHOW INDEX FROM $table");
if (empty($index_object)) {
$table_info[$table][] = 'no index';
} else {
foreach ($index_object as $index) {
$table_info[$table][] = $index->Key_name . ' ( ' . $index->Column_name . ' )';
}
}
}
$table_info = array_reverse($table_info);
return $table_info;
}
/**
* Method to get the autoincremented values of each table and returns it.
*
* The data is from sqlite_sequence table.
*
* @return assoc array name => sequence, or false
* @access private
*/
private function get_sequence() {
global $wpdb;
$sequence_info = array();
$results = $wpdb->get_results("SELECT name, seq FROM sqlite_sequence");
if (is_null($results) || empty($results)) {
return false;
} else {
foreach ($results as $result) {
$sequence_info[$result->name] = $result->seq;
}
return $sequence_info;
}
}
/**
* Method to show the contents of 'wp-content/db.php' file.
*
* If this file is not existent, shows message and returns false.
*
* @return string
* @access private
*/
private function show_db_php() {
if (defined('WP_CONTENT_DIR')) {
$file = WP_CONTENT_DIR . '/db.php';
} else {
$file = ABSPATH . 'wp-content/db.php';
}
if (file_exists($file)) {
if (is_readable($file)) {
$contents = file_get_contents($file);
return $contents;
} else {
$contents = 'file is not readable';
}
} else {
$contents = 'file doesn\'t exist';
}
return $contents;
}
/**
* Method to get the textarea content and write it to db.php file.
*
* @param string $contents
* @return boolean
* @access private
*/
private function save_db_php($contents) {
if (defined('WP_CONTENT_DIR')) {
$file = WP_CONTENT_DIR . '/db.php';
} else {
$file = ABSPATH . 'wp-content/db.php';
}
$fh = fopen($file, "w+");
if ($fh) {
if (flock($fh, LOCK_EX)) {
if (fwrite($fh, $contents) === false) {
return false;
}
flock($fh, LOCK_UN);
} else {
return false;
}
}
fclose($fh);
return true;
}
/**
* Method to replace the old db.php with the new one.
*
* @return boolean
* @access private
*/
private function update_db_file() {
$new_file = PDODIR . 'db.php';
if (file_exists($new_file) && is_readable($new_file)) {
$contents = file_get_contents($new_file);
} else {
return false;
}
if (defined('WP_CONTENT_DIR')) {
$path = WP_CONTENT_DIR . '/db.php';
} else {
$path = ABSPATH . 'wp-content/db.php';
}
if (($handle = @fopen($path, 'w+')) && flock($handle, LOCK_EX)) {
if (fwrite($handle, $contents) == false) {
flock($handle, LOCK_UN);
fclose($handle);
return false;
}
flock($handle, LOCK_UN);
fclose($handle);
} else {
return false;
}
return true;
}
/**
* Method to optimize SQLite database.
*
* This only gives VACUUM command to SQLite database. This query is rewritten in
* the query.class.php file.
*
* @return boolean
* @access private
*/
private function optimize_db() {
global $wpdb;
$result = $wpdb->query("OPTIMIZE");
return $result;
}
/**
* Method to get SQLite database file size.
*
* @return string
* @access private
*/
private function get_database_size() {
$db_file = FQDB;
if (file_exists($db_file)) {
$size = filesize($db_file);
clearstatcache(true, $db_file);
return $this->convert_to_formatted_number($size);
}
}
/**
* Method to format the file size number to the unit byte.
*
* @param integer $size
* @return string
* @access private
*/
private function convert_to_formatted_number($size) {
$unim = array('Bytes', 'KB', 'MB', 'GB', 'TB', 'PB');
$count = 0;
while ($size >= 1024) {
$count++;
$size = $size / 1024;
}
return number_format($size, ($count ? 2 : 0), '.', ',') . ' ' . $unim[$count];
}
/**
* Method to echo plugins info table component.
*
* @return nothing returned.
* @access private
*/
private function show_plugins_info() {
$domain = $this->text_domain;
if (file_exists(SQLiteListFile)) {
$contents = file_get_contents(SQLiteListFile);
$plugin_info_list = json_decode($contents);
$plugins = get_plugins();
foreach ($plugins as $key => $data) {
$name = ''.$data['Name'].'';
foreach ($plugin_info_list as $plugin_info) {
if ($data['Name'] == $plugin_info->name) {
$class = 'class="'.$plugin_info->class.'"';
// for Internationalization... it's a redundant codes, mm...
// I might have made a mistake to store data in json format...
switch ($plugin_info->compat) {
case 'Needs Patch':
if (!empty($plugin_info->patch_url)) {
$compat = ''.__('Needs Patch', $domain).'';
} else {
$compat = __('Needs Patch', $domain);
}
break;
case 'Probably No':
$compat = __('Probably No', $domain);
break;
case 'Probably Yes':
$compat = __('Probably Yes', $domain);
break;
case 'No':
$compat = __('No', $domain);
break;
case 'Checked':
if (!empty($plugin_info->informed) && stripos($plugin_info->informed, 'Users\' Information') !== false) {
$compat = __('Checked*', $domain);
} else {
$compat = __('Checked', $domain);
}
break;
default:
$compat = __('Not Checked', $domain);
break;
}
break;
} else {
$class = 'class="compatible"';
$compat = __('Not Checked', $domain);
}
}
if (is_plugin_active_for_network($key)) {
echo 'get_module_setting('PDO', 'PDO support');?> | |
get_module_setting('PDO', 'PDO drivers');?> | |
get_module_setting('pdo_sqlite', 'PDO Driver for SQLite 3.x');?> | |
get_module_setting('pdo_sqlite', 'SQLite Library');?> |
'; echo ($i+1).'. '.$col; $i++; } ?> | |
'; echo ($i+1).'. '.$op; $i++; } ?> |
' . $tbl_name . ' | '; echo '' . $which_table . ' table | ';?>';} ?> |
get_backup_files();?>
';?>
'; ?> If you don\'t understand well, please don\'t edit this file.', $domain)?> '; ?> '; ?> show_db_php();?> '.$db_contents.'
'; ?> ', __('Save', $domain), __('Are you sure to save this file?\n\nClick [Cancel] to stop, [OK] to continue.', $domain)); ?> '; ?>