[^<]+?<\/h2>)/', $infos, -1, PREG_SPLIT_DELIM_CAPTURE);
$modules = array();
for ($i = 1; $i < count($info_array); $i++) {
if (preg_match('/
([^<]+)<\/h2>/', $info_array[$i], $match)) {
$name = trim($match[1]);
$info_array2 = explode("\n", $info_array[$i+1]);
foreach ($info_array2 as $info) {
$pattern = '([^<]+)<\/info>';
$pattern3 = "/$pattern\\s*$pattern\\s*$pattern/";
$pattern2 = "/$pattern\\s*$pattern/";
if (preg_match($pattern3, $info, $match)) {
$modules[$name][trim($match[1])] = array(trim($match[2]), trim($match[3]));
} elseif (preg_match($pattern2, $info, $match)) {
$modules[$name][trim($match[1])] = trim($match[2]);
}
}
}
}
return $modules;
}
/**
* Method to echo PHP module info.
*
* @param string $module_name
* @param string $setting_name
* @access private
*/
private function get_module_setting($module_name, $setting_name) {
$module_info = $this->parse_php_modules();
echo $module_info[$module_name][$setting_name];
}
function show_parent() {
if (function_exists('is_multisite') && is_multisite()) {
return 'settings.php';
} else {
return 'options-general.php';
}
}
/**
* Method to parse FQDBDIR and return backup database files.
*
* @return nothing returned.
* @access private
*/
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;
}
/**
* Method to create backup database file.
*
* @return string array
* @access private
*/
private function backup_db() {
$domain = $this->text_domain;
$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;
}
/**
* Method to delete backup database file(s).
*
* Users can delete multiple files at a time.
*
* @return false if file names aren't checked, empty array if failed, array of messages if succeeded.
* @access private
*/
private function delete_backup_db() {
$domain = $this->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;
}
/**
* Method to download a backup file.
*
* This method uses header() function, so we have to register this function using
* admin_init action hook. It must also be declared as public. We check HTTP_REFERER
* and input button name, and ,after that, wp_nonce. When the admin_init is executed
* it only returns true.
*
* The database file might be several hundred mega bytes, so we don't use readfile()
* but use fread() instead.
*
* Users can download one file at a time.
*
* @return 1 if the file name isn't checked, 2 if multiple files are checked, true if succeeded.
*/
static function download_backup_db() {
if (is_multisite()) {
$script_url = network_admin_url('settings.php?page=setting-file');
} else {
$script_url = admin_url('options-general.php?page=setting-file');
}
if (isset($_POST['download_backup_file']) && stripos($_SERVER['HTTP_REFERER'], $script_url) !== false) {
check_admin_referer('sqliteintegration-backup-manip-stats');
if (!isset($_POST['backup_checked'])) return 1;
$file_names = array();
$file_names = $_POST['backup_checked'];
if (count($file_names) != 1) return 2;
$file_name = $file_names[0];
$file_path = FQDBDIR . $file_name;
$blog_name = str_replace(array(' ', ' ', ';'), array('_', '_', '_'), get_bloginfo('name'));
$download_file_name = $blog_name . '_' . $file_name;
header('Pragma: public');
header('Cache-Control: must-revalidate,post-check=0,pre-check=0');
header('Content-Type: application/force-download');
header('Content-Type: application/octet-stream');
header('Content-Type: application/download');
header('Content-Disposition: attachment; filename='.$download_file_name.';');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.filesize($file_path));
$fp = fopen($file_path, 'r');
while (!feof($fp)) {
echo fread($fp, 65536);
flush();
}
fclose($fp);
}
return true;
}
/**
* Method to show Welcome page.
*
*/
function welcome() {
$domain = $this->text_domain;
if (isset($_GET['page']) && $_GET['page'] == 'sqlite-integration') :?>
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'] == 'sys-info') :?>
get_system_info(); ?>
get_module_setting('PDO', 'PDO support');?>
get_module_setting('PDO', 'PDO drivers');?>
get_module_setting('pdo_sqlite', 'PDO Driver for SQLite 3.x');?>
';
if (array_key_exists($tbl_name, $table_seq)) $tbl_name .= " ($table_seq[$tbl_name])";
echo '
' . $tbl_name . '
';
echo '
' . $which_table . ' table
';?>
';} ?>
show_plugins_info();?>
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($_POST['sqlitewordpress_log_reset'])) {
check_admin_referer('sqlitewordpress-log-reset-stats');
if ($this->clear_log_file()) {
$messages = __('Log cleared', $domain);
echo '