| <?php |
| |
| |
| |
| |
|
|
| |
| if (!defined('ABSPATH')) { |
| exit; |
| } |
|
|
| |
| if (!extension_loaded('pdo_sqlite')) { |
| wp_die('SQLite PDO extension is not available. Please install php-sqlite3.'); |
| } |
|
|
| |
| if (!defined('DB_FILE')) { |
| define('DB_FILE', ABSPATH . 'wp-content/database/wordpress.db'); |
| } |
|
|
| |
| $db_dir = dirname(DB_FILE); |
| if (!file_exists($db_dir)) { |
| wp_mkdir_p($db_dir); |
| } |
|
|
| |
| |
| |
| class SQLite_DB { |
| public $pdo; |
| public $last_error = ''; |
| public $error = ''; |
| public $insert_id = 0; |
| public $num_rows = 0; |
| public $last_query = ''; |
| public $last_result = null; |
| public $prefix = 'wp_'; |
| |
| |
| public $posts; |
| public $users; |
| public $options; |
| public $postmeta; |
| public $usermeta; |
| public $terms; |
| public $term_taxonomy; |
| public $term_relationships; |
| public $termmeta; |
| public $comments; |
| public $commentmeta; |
| public $links; |
| public $field_types = array(); |
| public $charset; |
| public $collate; |
| public $dbname; |
| public $ready = false; |
| public $suppress_errors = false; |
| public $show_errors = true; |
| public $time_start = 0; |
| public $blogid = 1; |
| public $base_prefix = 'wp_'; |
| |
| public function __construct() { |
| global $table_prefix; |
| $this->prefix = isset($table_prefix) ? $table_prefix : 'wp_'; |
| $this->charset = 'utf8'; |
| $this->collate = ''; |
| $this->dbname = '/var/www/html/wp-content/database'; |
| $this->set_table_names(); |
| |
| if ($this->connect()) { |
| $this->ready = true; |
| $this->base_prefix = $this->prefix; |
| $this->timer_start(); |
| } else { |
| $this->ready = false; |
| |
| } |
| } |
| |
| private function set_table_names() { |
| $this->posts = $this->prefix . 'posts'; |
| $this->users = $this->prefix . 'users'; |
| $this->options = $this->prefix . 'options'; |
| $this->postmeta = $this->prefix . 'postmeta'; |
| $this->usermeta = $this->prefix . 'usermeta'; |
| $this->terms = $this->prefix . 'terms'; |
| $this->term_taxonomy = $this->prefix . 'term_taxonomy'; |
| $this->term_relationships = $this->prefix . 'term_relationships'; |
| $this->termmeta = $this->prefix . 'termmeta'; |
| $this->comments = $this->prefix . 'comments'; |
| $this->commentmeta = $this->prefix . 'commentmeta'; |
| $this->links = $this->prefix . 'links'; |
| } |
| |
| private function connect() { |
| try { |
| |
| |
| $this->pdo = new PDO('sqlite::memory:'); |
| $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| $this->pdo->exec('PRAGMA foreign_keys = ON'); |
| $this->pdo->exec('PRAGMA journal_mode = MEMORY'); |
| $this->pdo->exec('PRAGMA synchronous = OFF'); |
| $this->pdo->exec('PRAGMA cache_size = 10000'); |
| |
| |
| $this->create_wordpress_tables(); |
| |
| return true; |
| } catch (PDOException $e) { |
| $this->last_error = $e->getMessage(); |
| $this->error = $e->getMessage(); |
| error_log("SQLite connection error: " . $e->getMessage()); |
| $this->ready = false; |
| return false; |
| } |
| } |
| |
| public function query($sql) { |
| $this->last_query = $sql; |
| $this->last_error = ''; |
| $this->last_result = null; |
| |
| try { |
| |
| $sql = $this->mysql_to_sqlite($sql); |
| |
| $stmt = $this->pdo->prepare($sql); |
| $result = $stmt->execute(); |
| |
| if ($result) { |
| $this->insert_id = $this->pdo->lastInsertId(); |
| $this->num_rows = $stmt->rowCount(); |
| $this->last_result = $stmt; |
| |
| |
| if (stripos(trim($sql), 'SELECT') === 0) { |
| return $this->num_rows; |
| } |
| |
| return true; |
| } |
| |
| return false; |
| } catch (PDOException $e) { |
| $this->last_error = $e->getMessage(); |
| $this->error = $e->getMessage(); |
| |
| if (!$this->suppress_errors) { |
| if ($this->show_errors) { |
| error_log("SQLite Error: " . $e->getMessage()); |
| } |
| } |
| |
| return false; |
| } |
| } |
| |
| private function mysql_to_sqlite($sql) { |
| |
| $sql = str_replace('`', '"', $sql); |
| $sql = preg_replace('/AUTO_INCREMENT/i', 'AUTOINCREMENT', $sql); |
| $sql = preg_replace('/INT\(\d+\)/i', 'INTEGER', $sql); |
| $sql = preg_replace('/TINYINT\(\d+\)/i', 'INTEGER', $sql); |
| $sql = preg_replace('/BIGINT\(\d+\)/i', 'INTEGER', $sql); |
| $sql = preg_replace('/VARCHAR\((\d+)\)/i', 'TEXT', $sql); |
| $sql = preg_replace('/LONGTEXT/i', 'TEXT', $sql); |
| $sql = preg_replace('/DATETIME/i', 'TEXT', $sql); |
| $sql = preg_replace('/TIMESTAMP/i', 'TEXT', $sql); |
| |
| return $sql; |
| } |
| |
| public function get_results($sql, $output = OBJECT) { |
| $this->query($sql); |
| if (!$this->last_result) return null; |
| |
| $results = []; |
| while ($row = $this->last_result->fetch(PDO::FETCH_ASSOC)) { |
| if ($output === OBJECT) { |
| $results[] = (object) $row; |
| } else { |
| $results[] = $row; |
| } |
| } |
| |
| return $results; |
| } |
| |
| public function get_row($sql, $output = OBJECT) { |
| $this->query($sql); |
| if (!$this->last_result) return null; |
| |
| $row = $this->last_result->fetch(PDO::FETCH_ASSOC); |
| if (!$row) return null; |
| |
| if ($output === OBJECT) { |
| return (object) $row; |
| } |
| |
| return $row; |
| } |
| |
| public function get_var($sql) { |
| $this->query($sql); |
| if (!$this->last_result) return null; |
| |
| $row = $this->last_result->fetch(PDO::FETCH_NUM); |
| return $row ? $row[0] : null; |
| } |
| |
| public function insert_id() { |
| return $this->insert_id; |
| } |
| |
| public function last_error() { |
| return $this->last_error; |
| } |
| |
| public function num_rows() { |
| return $this->num_rows; |
| } |
| |
| |
| public function prepare($query, ...$args) { |
| if (empty($args)) { |
| return $query; |
| } |
| |
| $query = str_replace("'%s'", '%s', $query); |
| $query = str_replace('"%s"', '%s', $query); |
| $query = str_replace('%s', "'%s'", $query); |
| $query = str_replace("'%d'", '%d', $query); |
| $query = str_replace('"%d"', '%d', $query); |
| |
| return vsprintf($query, $args); |
| } |
| |
| public function get_charset_collate() { |
| return ''; |
| } |
| |
| public function esc_like($text) { |
| return addcslashes($text, '\\%_'); |
| } |
| |
| public function _escape($data) { |
| if (is_array($data)) { |
| return array_map(array($this, '_escape'), $data); |
| } |
| |
| if (is_string($data)) { |
| return addslashes($data); |
| } |
| |
| return $data; |
| } |
| |
| public function _real_escape($data) { |
| if (!is_scalar($data)) { |
| return ''; |
| } |
| |
| |
| $escaped = addslashes($data); |
| return $this->add_placeholder_escape($escaped); |
| } |
| |
| public function _weak_escape($data) { |
| if (func_num_args() === 1 && function_exists('_deprecated_function')) { |
| _deprecated_function(__METHOD__, '3.6.0', 'wpdb::prepare() or esc_sql()'); |
| } |
| return addslashes($data); |
| } |
| |
| public function escape($data) { |
| if (func_num_args() === 1 && function_exists('_deprecated_function')) { |
| _deprecated_function(__METHOD__, '3.6.0', 'wpdb::prepare() or esc_sql()'); |
| } |
| if (is_array($data)) { |
| foreach ($data as $k => $v) { |
| if (is_array($v)) { |
| $data[$k] = $this->escape($v); |
| } else { |
| $data[$k] = $this->_weak_escape($v); |
| } |
| } |
| } else { |
| $data = $this->_weak_escape($data); |
| } |
| return $data; |
| } |
| |
| public function add_placeholder_escape($query) { |
| |
| return str_replace('%', $this->placeholder_escape(), $query); |
| } |
| |
| public function placeholder_escape() { |
| static $placeholder; |
| if (!$placeholder) { |
| |
| $placeholder = '{' . wp_generate_password(20, false) . '}'; |
| } |
| return $placeholder; |
| } |
| |
| public function print_error($str = '') { |
| global $EZSQL_ERROR; |
| |
| if (!$str) { |
| $str = $this->last_error; |
| } |
| |
| $EZSQL_ERROR[] = array( |
| 'query' => $this->last_query, |
| 'error_str' => $str |
| ); |
| |
| if ($this->suppress_errors) { |
| return false; |
| } |
| |
| if ($this->show_errors) { |
| if (function_exists('wp_die')) { |
| wp_die($str); |
| } else { |
| die($str); |
| } |
| } |
| |
| return false; |
| } |
| |
| public function bail($message, $error_code = '500') { |
| if (!$this->show_errors) { |
| if (class_exists('WP_Error')) { |
| return new WP_Error($error_code, $message); |
| } else { |
| return false; |
| } |
| } |
| |
| if (function_exists('wp_die')) { |
| wp_die($message); |
| } else { |
| die($message); |
| } |
| } |
| |
| |
| public function set_prefix($prefix, $set_table_names = true) { |
| if (preg_match('|[^a-z0-9_]|i', $prefix)) { |
| |
| return false; |
| } |
| |
| $old_prefix = $this->prefix; |
| $this->prefix = $prefix; |
| |
| if ($set_table_names) { |
| $this->set_table_names(); |
| } |
| |
| return $old_prefix; |
| } |
| |
| public function set_blog_id($blog_id, $network_id = 0) { |
| |
| return $this->prefix; |
| } |
| |
| public function tables($scope = 'all', $prefix = true, $blog_id = 0) { |
| $tables = array( |
| 'posts', 'comments', 'links', 'options', 'postmeta', |
| 'terms', 'term_taxonomy', 'term_relationships', 'termmeta', |
| 'commentmeta', 'users', 'usermeta' |
| ); |
| |
| if ($prefix) { |
| $prefixed_tables = array(); |
| foreach ($tables as $table) { |
| $prefixed_tables[] = $this->prefix . $table; |
| } |
| return $prefixed_tables; |
| } |
| |
| return $tables; |
| } |
| |
| public function get_table_charset($table) { |
| return 'utf8'; |
| } |
| |
| public function get_col_charset($table, $column) { |
| return 'utf8'; |
| } |
| |
| public function check_connection($allow_bail = true) { |
| if (!$this->pdo) { |
| if ($allow_bail) { |
| $this->bail('Error establishing a database connection'); |
| } |
| return false; |
| } |
| |
| try { |
| |
| $this->pdo->query('SELECT 1'); |
| return true; |
| } catch (PDOException $e) { |
| $this->last_error = $e->getMessage(); |
| $this->error = $e->getMessage(); |
| |
| if ($allow_bail) { |
| $this->bail('Error establishing a database connection: ' . $e->getMessage()); |
| } |
| return false; |
| } |
| } |
| |
| public function bail($message, $error_code = '500') { |
| if (!$this->show_errors) { |
| if (class_exists('WP_Error')) { |
| $this->error = new WP_Error('db_connect_fail', $message); |
| } else { |
| $this->error = $message; |
| } |
| return false; |
| } |
| |
| if (function_exists('wp_die')) { |
| wp_die($message); |
| } else { |
| die($message); |
| } |
| } |
| |
| public function db_connect($allow_bail = true) { |
| $this->ready = false; |
| |
| if ($this->connect()) { |
| $this->ready = true; |
| return true; |
| } |
| |
| if ($allow_bail) { |
| $this->bail('Error establishing a database connection'); |
| } |
| |
| return false; |
| } |
| |
| public function db_version() { |
| try { |
| $result = $this->pdo->query('SELECT sqlite_version()'); |
| return $result->fetchColumn(); |
| } catch (PDOException $e) { |
| return '0'; |
| } |
| } |
| |
| |
| public function get_col($query = null, $x = 0) { |
| if ($query) { |
| $this->query($query); |
| } |
| |
| $new_array = array(); |
| if ($this->last_result) { |
| for ($i = 0; $i < count($this->last_result); $i++) { |
| $row = (array) $this->last_result[$i]; |
| $values = array_values($row); |
| if (isset($values[$x]) && $values[$x] !== '') { |
| $new_array[] = $values[$x]; |
| } |
| } |
| } |
| return $new_array; |
| } |
| |
| public function timer_start() { |
| $this->time_start = microtime(true); |
| return true; |
| } |
| |
| public function timer_stop() { |
| return (microtime(true) - $this->time_start); |
| } |
| |
| public function get_blog_prefix($blog_id = null) { |
| if (defined('MULTISITE') && MULTISITE) { |
| if (null === $blog_id) { |
| $blog_id = $this->blogid; |
| } |
| $blog_id = (int) $blog_id; |
| if (0 == $blog_id || 1 == $blog_id) { |
| return $this->base_prefix; |
| } else { |
| return $this->base_prefix . $blog_id . '_'; |
| } |
| } else { |
| return $this->prefix; |
| } |
| } |
| |
| public function flush() { |
| $this->last_result = null; |
| $this->last_query = null; |
| $this->last_error = ''; |
| } |
| |
| public function close() { |
| $this->pdo = null; |
| return true; |
| } |
| |
| public function has_cap($db_cap) { |
| switch (strtolower($db_cap)) { |
| case 'collation': |
| case 'group_concat': |
| case 'subqueries': |
| return true; |
| default: |
| return false; |
| } |
| } |
| |
| public function get_caller() { |
| if (function_exists('wp_debug_backtrace_summary')) { |
| return wp_debug_backtrace_summary(__CLASS__); |
| } |
| return ''; |
| } |
| |
| public function init_charset() { |
| |
| return true; |
| } |
| |
| public function set_charset($dbh, $charset = null, $collate = null) { |
| |
| return true; |
| } |
| |
| |
| public function suppress_errors($suppress = true) { |
| $errors_before = $this->suppress_errors; |
| $this->suppress_errors = $suppress; |
| return $errors_before; |
| } |
| |
| public function hide_errors() { |
| $show = $this->show_errors; |
| $this->show_errors = false; |
| return $show; |
| } |
| |
| public function show_errors($show = true) { |
| $errors_before = $this->show_errors; |
| $this->show_errors = $show; |
| return $errors_before; |
| } |
| |
| |
| public function insert($table, $data, $format = null) { |
| return $this->_insert_replace_helper($table, $data, $format, 'INSERT'); |
| } |
| |
| public function replace($table, $data, $format = null) { |
| return $this->_insert_replace_helper($table, $data, $format, 'REPLACE'); |
| } |
| |
| public function update($table, $data, $where, $format = null, $where_format = null) { |
| if (!is_array($data) || !is_array($where)) { |
| return false; |
| } |
| |
| $formats = $format = (array) $format; |
| $bits = $wheres = array(); |
| foreach ((array) array_keys($data) as $field) { |
| if (!empty($formats)) { |
| $form = ($form = array_shift($formats)) ? $form : $formats[0]; |
| } elseif (isset($this->field_types[$field])) { |
| $form = $this->field_types[$field]; |
| } else { |
| $form = '%s'; |
| } |
| $bits[] = "`$field` = {$form}"; |
| } |
| |
| $where_formats = $where_format = (array) $where_format; |
| foreach ((array) array_keys($where) as $field) { |
| if (!empty($where_formats)) { |
| $form = ($form = array_shift($where_formats)) ? $form : $where_formats[0]; |
| } elseif (isset($this->field_types[$field])) { |
| $form = $this->field_types[$field]; |
| } else { |
| $form = '%s'; |
| } |
| $wheres[] = "`$field` = {$form}"; |
| } |
| |
| $sql = "UPDATE `$table` SET " . implode(', ', $bits) . ' WHERE ' . implode(' AND ', $wheres); |
| return $this->query($this->prepare($sql, ...array_merge(array_values($data), array_values($where)))); |
| } |
| |
| public function delete($table, $where, $where_format = null) { |
| if (!is_array($where)) { |
| return false; |
| } |
| |
| $where_formats = $where_format = (array) $where_format; |
| $wheres = array(); |
| foreach (array_keys($where) as $field) { |
| if (!empty($where_formats)) { |
| $form = ($form = array_shift($where_formats)) ? $form : $where_formats[0]; |
| } elseif (isset($this->field_types[$field])) { |
| $form = $this->field_types[$field]; |
| } else { |
| $form = '%s'; |
| } |
| $wheres[] = "`$field` = {$form}"; |
| } |
| |
| $sql = "DELETE FROM `$table` WHERE " . implode(' AND ', $wheres); |
| return $this->query($this->prepare($sql, ...array_values($where))); |
| } |
| |
| private function _insert_replace_helper($table, $data, $format = null, $type = 'INSERT') { |
| if (!in_array(strtoupper($type), array('INSERT', 'REPLACE'))) { |
| return false; |
| } |
| |
| if (!is_array($data)) { |
| return false; |
| } |
| |
| $formats = $format = (array) $format; |
| $fields = array_keys($data); |
| $formatted_fields = array(); |
| |
| foreach ($fields as $field) { |
| if (!empty($formats)) { |
| $form = ($form = array_shift($formats)) ? $form : $formats[0]; |
| } elseif (isset($this->field_types[$field])) { |
| $form = $this->field_types[$field]; |
| } else { |
| $form = '%s'; |
| } |
| $formatted_fields[] = $form; |
| } |
| |
| $sql = "$type INTO `$table` (`" . implode('`,`', $fields) . '`) VALUES (' . implode(',', $formatted_fields) . ')'; |
| return $this->query($this->prepare($sql, ...array_values($data))); |
| } |
| |
| |
| private function create_wordpress_tables() { |
| $tables = array( |
| |
| "CREATE TABLE IF NOT EXISTS {$this->prefix}posts ( |
| ID bigint(20) unsigned NOT NULL PRIMARY KEY, |
| 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_content longtext NOT NULL, |
| post_title text NOT NULL, |
| post_excerpt text NOT NULL, |
| 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(255) NOT NULL DEFAULT '', |
| post_name varchar(200) NOT NULL DEFAULT '', |
| to_ping text NOT NULL, |
| pinged text NOT NULL, |
| 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 |
| )", |
| |
| |
| "CREATE TABLE IF NOT EXISTS {$this->prefix}users ( |
| ID bigint(20) unsigned NOT NULL PRIMARY KEY, |
| user_login varchar(60) NOT NULL DEFAULT '', |
| user_pass varchar(255) 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(255) NOT NULL DEFAULT '', |
| user_status int(11) NOT NULL DEFAULT 0, |
| display_name varchar(250) NOT NULL DEFAULT '' |
| )", |
| |
| |
| "CREATE TABLE IF NOT EXISTS {$this->prefix}options ( |
| option_id bigint(20) unsigned NOT NULL PRIMARY KEY, |
| option_name varchar(191) NOT NULL DEFAULT '', |
| option_value longtext NOT NULL, |
| autoload varchar(20) NOT NULL DEFAULT 'yes' |
| )", |
| |
| |
| "CREATE TABLE IF NOT EXISTS {$this->prefix}comments ( |
| comment_ID bigint(20) unsigned NOT NULL PRIMARY KEY, |
| comment_post_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
| comment_author tinytext NOT NULL, |
| 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_content text NOT NULL, |
| 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', |
| comment_parent bigint(20) unsigned NOT NULL DEFAULT 0, |
| user_id bigint(20) unsigned NOT NULL DEFAULT 0 |
| )", |
| |
| |
| "CREATE TABLE IF NOT EXISTS {$this->prefix}terms ( |
| term_id bigint(20) unsigned NOT NULL PRIMARY KEY, |
| name varchar(200) NOT NULL DEFAULT '', |
| slug varchar(200) NOT NULL DEFAULT '', |
| term_group bigint(10) NOT NULL DEFAULT 0 |
| )", |
| |
| |
| "CREATE TABLE IF NOT EXISTS {$this->prefix}term_taxonomy ( |
| term_taxonomy_id bigint(20) unsigned NOT NULL PRIMARY KEY, |
| term_id bigint(20) unsigned NOT NULL DEFAULT 0, |
| 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 |
| )", |
| |
| |
| "CREATE TABLE IF NOT EXISTS {$this->prefix}term_relationships ( |
| object_id bigint(20) unsigned NOT NULL DEFAULT 0, |
| term_taxonomy_id bigint(20) unsigned NOT NULL DEFAULT 0, |
| term_order int(11) NOT NULL DEFAULT 0, |
| PRIMARY KEY (object_id, term_taxonomy_id) |
| )" |
| ); |
| |
| foreach ($tables as $sql) { |
| try { |
| $this->pdo->exec($sql); |
| } catch (PDOException $e) { |
| error_log("Error creating table: " . $e->getMessage()); |
| } |
| } |
| |
| |
| $this->insert_default_options(); |
| } |
| |
| |
| private function insert_default_options() { |
| $default_options = array( |
| array('option_name' => 'siteurl', 'option_value' => 'http://localhost', 'autoload' => 'yes'), |
| array('option_name' => 'home', 'option_value' => 'http://localhost', 'autoload' => 'yes'), |
| array('option_name' => 'blogname', 'option_value' => 'WordPress on Hugging Face', 'autoload' => 'yes'), |
| array('option_name' => 'blogdescription', 'option_value' => 'Just another WordPress site', 'autoload' => 'yes'), |
| array('option_name' => 'users_can_register', 'option_value' => '0', 'autoload' => 'yes'), |
| array('option_name' => 'admin_email', 'option_value' => '[email protected]', 'autoload' => 'yes'), |
| array('option_name' => 'start_of_week', 'option_value' => '1', 'autoload' => 'yes'), |
| array('option_name' => 'use_balanceTags', 'option_value' => '0', 'autoload' => 'yes'), |
| array('option_name' => 'use_smilies', 'option_value' => '1', 'autoload' => 'yes'), |
| array('option_name' => 'require_name_email', 'option_value' => '1', 'autoload' => 'yes'), |
| array('option_name' => 'comments_notify', 'option_value' => '1', 'autoload' => 'yes'), |
| array('option_name' => 'posts_per_rss', 'option_value' => '10', 'autoload' => 'yes'), |
| array('option_name' => 'rss_use_excerpt', 'option_value' => '0', 'autoload' => 'yes'), |
| array('option_name' => 'mailserver_url', 'option_value' => 'mail.example.com', 'autoload' => 'yes'), |
| array('option_name' => 'mailserver_login', 'option_value' => '[email protected]', 'autoload' => 'yes'), |
| array('option_name' => 'mailserver_pass', 'option_value' => 'password', 'autoload' => 'yes'), |
| array('option_name' => 'mailserver_port', 'option_value' => '110', 'autoload' => 'yes'), |
| array('option_name' => 'default_category', 'option_value' => '1', 'autoload' => 'yes'), |
| array('option_name' => 'default_comment_status', 'option_value' => 'open', 'autoload' => 'yes'), |
| array('option_name' => 'default_ping_status', 'option_value' => 'open', 'autoload' => 'yes'), |
| array('option_name' => 'default_pingback_flag', 'option_value' => '1', 'autoload' => 'yes'), |
| array('option_name' => 'posts_per_page', 'option_value' => '10', 'autoload' => 'yes'), |
| array('option_name' => 'date_format', 'option_value' => 'F j, Y', 'autoload' => 'yes'), |
| array('option_name' => 'time_format', 'option_value' => 'g:i a', 'autoload' => 'yes'), |
| array('option_name' => 'links_updated_date_format', 'option_value' => 'F j, Y g:i a', 'autoload' => 'yes'), |
| array('option_name' => 'comment_moderation', 'option_value' => '0', 'autoload' => 'yes'), |
| array('option_name' => 'moderation_notify', 'option_value' => '1', 'autoload' => 'yes'), |
| array('option_name' => 'permalink_structure', 'option_value' => '/%year%/%monthnum%/%day%/%postname%/', 'autoload' => 'yes'), |
| array('option_name' => 'rewrite_rules', 'option_value' => '', 'autoload' => 'yes'), |
| array('option_name' => 'hack_file', 'option_value' => '0', 'autoload' => 'yes'), |
| array('option_name' => 'blog_charset', 'option_value' => 'UTF-8', 'autoload' => 'yes'), |
| array('option_name' => 'moderation_keys', 'option_value' => '', 'autoload' => 'no'), |
| array('option_name' => 'active_plugins', 'option_value' => 'a:0:{}', 'autoload' => 'yes'), |
| array('option_name' => 'category_base', 'option_value' => '', 'autoload' => 'yes'), |
| array('option_name' => 'ping_sites', 'option_value' => 'http://rpc.pingomatic.com/', 'autoload' => 'yes'), |
| array('option_name' => 'comment_max_links', 'option_value' => '2', 'autoload' => 'yes'), |
| array('option_name' => 'gmt_offset', 'option_value' => '0', 'autoload' => 'yes'), |
| array('option_name' => 'default_email_category', 'option_value' => '1', 'autoload' => 'yes'), |
| array('option_name' => 'recently_edited', 'option_value' => '', 'autoload' => 'no'), |
| array('option_name' => 'template', 'option_value' => 'twentytwentyfour', 'autoload' => 'yes'), |
| array('option_name' => 'stylesheet', 'option_value' => 'twentytwentyfour', 'autoload' => 'yes'), |
| array('option_name' => 'comment_registration', 'option_value' => '0', 'autoload' => 'yes'), |
| array('option_name' => 'html_type', 'option_value' => 'text/html', 'autoload' => 'yes'), |
| array('option_name' => 'use_trackback', 'option_value' => '0', 'autoload' => 'yes'), |
| array('option_name' => 'default_role', 'option_value' => 'subscriber', 'autoload' => 'yes'), |
| array('option_name' => 'db_version', 'option_value' => '57155', 'autoload' => 'yes'), |
| array('option_name' => 'uploads_use_yearmonth_folders', 'option_value' => '1', 'autoload' => 'yes'), |
| array('option_name' => 'upload_path', 'option_value' => '', 'autoload' => 'yes'), |
| array('option_name' => 'blog_public', 'option_value' => '1', 'autoload' => 'yes'), |
| array('option_name' => 'default_link_category', 'option_value' => '2', 'autoload' => 'yes'), |
| array('option_name' => 'show_on_front', 'option_value' => 'posts', 'autoload' => 'yes'), |
| array('option_name' => 'tag_base', 'option_value' => '', 'autoload' => 'yes'), |
| array('option_name' => 'show_avatars', 'option_value' => '1', 'autoload' => 'yes'), |
| array('option_name' => 'avatar_rating', 'option_value' => 'G', 'autoload' => 'yes'), |
| array('option_name' => 'upload_url_path', 'option_value' => '', 'autoload' => 'yes'), |
| array('option_name' => 'thumbnail_size_w', 'option_value' => '150', 'autoload' => 'yes'), |
| array('option_name' => 'thumbnail_size_h', 'option_value' => '150', 'autoload' => 'yes'), |
| array('option_name' => 'thumbnail_crop', 'option_value' => '1', 'autoload' => 'yes'), |
| array('option_name' => 'medium_size_w', 'option_value' => '300', 'autoload' => 'yes'), |
| array('option_name' => 'medium_size_h', 'option_value' => '300', 'autoload' => 'yes'), |
| array('option_name' => 'avatar_default', 'option_value' => 'mystery', 'autoload' => 'yes'), |
| array('option_name' => 'large_size_w', 'option_value' => '1024', 'autoload' => 'yes'), |
| array('option_name' => 'large_size_h', 'option_value' => '1024', 'autoload' => 'yes'), |
| array('option_name' => 'image_default_link_type', 'option_value' => 'none', 'autoload' => 'yes'), |
| array('option_name' => 'image_default_size', 'option_value' => '', 'autoload' => 'yes'), |
| array('option_name' => 'image_default_align', 'option_value' => '', 'autoload' => 'yes'), |
| array('option_name' => 'close_comments_for_old_posts', 'option_value' => '0', 'autoload' => 'yes'), |
| array('option_name' => 'close_comments_days_old', 'option_value' => '14', 'autoload' => 'yes'), |
| array('option_name' => 'thread_comments', 'option_value' => '1', 'autoload' => 'yes'), |
| array('option_name' => 'thread_comments_depth', 'option_value' => '5', 'autoload' => 'yes'), |
| array('option_name' => 'page_comments', 'option_value' => '0', 'autoload' => 'yes'), |
| array('option_name' => 'comments_per_page', 'option_value' => '50', 'autoload' => 'yes'), |
| array('option_name' => 'default_comments_page', 'option_value' => 'newest', 'autoload' => 'yes'), |
| array('option_name' => 'comment_order', 'option_value' => 'asc', 'autoload' => 'yes'), |
| array('option_name' => 'sticky_posts', 'option_value' => 'a:0:{}', 'autoload' => 'yes'), |
| array('option_name' => 'widget_categories', 'option_value' => 'a:0:{}', 'autoload' => 'yes'), |
| array('option_name' => 'widget_text', 'option_value' => 'a:0:{}', 'autoload' => 'yes'), |
| array('option_name' => 'widget_rss', 'option_value' => 'a:0:{}', 'autoload' => 'yes'), |
| array('option_name' => 'uninstall_plugins', 'option_value' => 'a:0:{}', 'autoload' => 'no'), |
| array('option_name' => 'timezone_string', 'option_value' => '', 'autoload' => 'yes'), |
| array('option_name' => 'page_for_posts', 'option_value' => '0', 'autoload' => 'yes'), |
| array('option_name' => 'page_on_front', 'option_value' => '0', 'autoload' => 'yes'), |
| array('option_name' => 'default_post_format', 'option_value' => '0', 'autoload' => 'yes'), |
| array('option_name' => 'link_manager_enabled', 'option_value' => '0', 'autoload' => 'yes'), |
| array('option_name' => 'finished_splitting_shared_terms', 'option_value' => '1', 'autoload' => 'yes'), |
| array('option_name' => 'site_icon', 'option_value' => '0', 'autoload' => 'yes'), |
| array('option_name' => 'medium_large_size_w', 'option_value' => '768', 'autoload' => 'yes'), |
| array('option_name' => 'medium_large_size_h', 'option_value' => '0', 'autoload' => 'yes'), |
| array('option_name' => 'wp_page_for_privacy_policy', 'option_value' => '3', 'autoload' => 'yes'), |
| array('option_name' => 'show_comments_cookies_opt_in', 'option_value' => '1', 'autoload' => 'yes'), |
| array('option_name' => 'admin_email_lifespan', 'option_value' => '1735689600', 'autoload' => 'yes'), |
| array('option_name' => 'disallowed_keys', 'option_value' => '', 'autoload' => 'no'), |
| array('option_name' => 'comment_previously_approved', 'option_value' => '1', 'autoload' => 'yes'), |
| array('option_name' => 'auto_plugin_theme_update_emails', 'option_value' => 'a:0:{}', 'autoload' => 'no'), |
| array('option_name' => 'auto_update_core_dev', 'option_value' => 'enabled', 'autoload' => 'yes'), |
| array('option_name' => 'auto_update_core_minor', 'option_value' => 'enabled', 'autoload' => 'yes'), |
| array('option_name' => 'auto_update_core_major', 'option_value' => 'enabled', 'autoload' => 'yes'), |
| array('option_name' => 'wp_force_deactivated_plugins', 'option_value' => 'a:0:{}', 'autoload' => 'yes'), |
| array('option_name' => 'initial_db_version', 'option_value' => '57155', 'autoload' => 'yes'), |
| array('option_name' => 'wp_user_roles', 'option_value' => 'a:5:{s:13:"administrator";a:2:{s:4:"name";s:13:"Administrator";s:12:"capabilities";a:61:{s:13:"switch_themes";b:1;s:11:"edit_themes";b:1;s:16:"activate_plugins";b:1;s:12:"edit_plugins";b:1;s:10:"edit_users";b:1;s:10:"edit_files";b:1;s:14:"manage_options";b:1;s:17:"moderate_comments";b:1;s:17:"manage_categories";b:1;s:12:"manage_links";b:1;s:12:"upload_files";b:1;s:6:"import";b:1;s:15:"unfiltered_html";b:1;s:10:"edit_posts";b:1;s:17:"edit_others_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:10:"edit_pages";b:1;s:4:"read";b:1;s:8:"level_10";b:1;s:7:"level_9";b:1;s:7:"level_8";b:1;s:7:"level_7";b:1;s:7:"level_6";b:1;s:7:"level_5";b:1;s:7:"level_4";b:1;s:7:"level_3";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:17:"edit_others_pages";b:1;s:20:"edit_published_pages";b:1;s:13:"publish_pages";b:1;s:12:"delete_pages";b:1;s:19:"delete_others_pages";b:1;s:22:"delete_published_pages";b:1;s:12:"delete_posts";b:1;s:19:"delete_others_posts";b:1;s:22:"delete_published_posts";b:1;s:20:"delete_private_posts";b:1;s:18:"edit_private_posts";b:1;s:18:"read_private_posts";b:1;s:20:"delete_private_pages";b:1;s:18:"edit_private_pages";b:1;s:18:"read_private_pages";b:1;s:12:"delete_users";b:1;s:12:"create_users";b:1;s:17:"unfiltered_upload";b:1;s:14:"edit_dashboard";b:1;s:14:"update_plugins";b:1;s:14:"delete_plugins";b:1;s:15:"install_plugins";b:1;s:13:"update_themes";b:1;s:14:"install_themes";b:1;s:11:"update_core";b:1;s:10:"list_users";b:1;s:12:"remove_users";b:1;s:13:"promote_users";b:1;s:18:"edit_theme_options";b:1;s:13:"delete_themes";b:1;s:6:"export";b:1;}}s:6:"editor";a:2:{s:4:"name";s:6:"Editor";s:12:"capabilities";a:34:{s:17:"moderate_comments";b:1;s:17:"manage_categories";b:1;s:12:"manage_links";b:1;s:12:"upload_files";b:1;s:15:"unfiltered_html";b:1;s:10:"edit_posts";b:1;s:17:"edit_others_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:10:"edit_pages";b:1;s:4:"read";b:1;s:7:"level_7";b:1;s:7:"level_6";b:1;s:7:"level_5";b:1;s:7:"level_4";b:1;s:7:"level_3";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:17:"edit_others_pages";b:1;s:20:"edit_published_pages";b:1;s:13:"publish_pages";b:1;s:12:"delete_pages";b:1;s:19:"delete_others_pages";b:1;s:22:"delete_published_pages";b:1;s:12:"delete_posts";b:1;s:19:"delete_others_posts";b:1;s:22:"delete_published_posts";b:1;s:20:"delete_private_posts";b:1;s:18:"edit_private_posts";b:1;s:18:"read_private_posts";b:1;s:20:"delete_private_pages";b:1;s:18:"edit_private_pages";b:1;s:18:"read_private_pages";b:1;}}s:6:"author";a:2:{s:4:"name";s:6:"Author";s:12:"capabilities";a:10:{s:12:"upload_files";b:1;s:10:"edit_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:4:"read";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:12:"delete_posts";b:1;s:22:"delete_published_posts";b:1;}}s:11:"contributor";a:2:{s:4:"name";s:11:"Contributor";s:12:"capabilities";a:5:{s:10:"edit_posts";b:1;s:4:"read";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:12:"delete_posts";b:1;}}s:10:"subscriber";a:2:{s:4:"name";s:10:"Subscriber";s:12:"capabilities";a:2:{s:4:"read";b:1;s:7:"level_0";b:1;}}}', 'autoload' => 'yes'), |
| array('option_name' => 'fresh_site', 'option_value' => '1', 'autoload' => 'yes') |
| ); |
| |
| foreach ($default_options as $option) { |
| try { |
| $this->insert($this->prefix . 'options', $option); |
| } catch (Exception $e) { |
| |
| } |
| } |
| } |
| } |
|
|
| |
| $wpdb = new SQLite_DB(); |
|
|
| |
| if (!isset($GLOBALS['wpdb'])) { |
| $GLOBALS['wpdb'] = $wpdb; |
| } |