Upload 3 files
Browse files- db.php +361 -6
- test-php.php +40 -2
db.php
CHANGED
@@ -55,16 +55,23 @@ class SQLite_DB {
|
|
55 |
public $collate;
|
56 |
public $dbname;
|
57 |
public $ready = false;
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
public function __construct() {
|
60 |
global $table_prefix;
|
61 |
$this->prefix = isset($table_prefix) ? $table_prefix : 'wp_';
|
62 |
$this->charset = 'utf8';
|
63 |
$this->collate = '';
|
64 |
-
$this->dbname = '
|
65 |
$this->set_table_names();
|
66 |
$this->connect();
|
67 |
$this->ready = true;
|
|
|
|
|
68 |
}
|
69 |
|
70 |
private function set_table_names() {
|
@@ -84,12 +91,23 @@ class SQLite_DB {
|
|
84 |
|
85 |
private function connect() {
|
86 |
try {
|
87 |
-
|
|
|
|
|
88 |
$this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
89 |
$this->pdo->exec('PRAGMA foreign_keys = ON');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
} catch (PDOException $e) {
|
91 |
$this->last_error = $e->getMessage();
|
92 |
-
|
|
|
93 |
}
|
94 |
}
|
95 |
|
@@ -121,6 +139,13 @@ class SQLite_DB {
|
|
121 |
return false;
|
122 |
} catch (PDOException $e) {
|
123 |
$this->last_error = $e->getMessage();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
return false;
|
125 |
}
|
126 |
}
|
@@ -214,8 +239,45 @@ class SQLite_DB {
|
|
214 |
}
|
215 |
|
216 |
public function print_error($str = '') {
|
217 |
-
|
218 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
}
|
220 |
}
|
221 |
|
@@ -276,7 +338,56 @@ class SQLite_DB {
|
|
276 |
}
|
277 |
|
278 |
public function db_version() {
|
279 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
280 |
}
|
281 |
|
282 |
public function flush() {
|
@@ -318,6 +429,25 @@ class SQLite_DB {
|
|
318 |
return true;
|
319 |
}
|
320 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
321 |
// WordPress data manipulation methods
|
322 |
public function insert($table, $data, $format = null) {
|
323 |
return $this->_insert_replace_helper($table, $data, $format, 'INSERT');
|
@@ -410,6 +540,231 @@ class SQLite_DB {
|
|
410 |
$sql = "$type INTO `$table` (`" . implode('`,`', $fields) . '`) VALUES (' . implode(',', $formatted_fields) . ')';
|
411 |
return $this->query($this->prepare($sql, array_values($data)));
|
412 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
413 |
}
|
414 |
|
415 |
// Initialize SQLite database connection
|
|
|
55 |
public $collate;
|
56 |
public $dbname;
|
57 |
public $ready = false;
|
58 |
+
public $suppress_errors = false;
|
59 |
+
public $show_errors = true;
|
60 |
+
public $time_start = 0;
|
61 |
+
public $blogid = 1;
|
62 |
+
public $base_prefix = 'wp_';
|
63 |
|
64 |
public function __construct() {
|
65 |
global $table_prefix;
|
66 |
$this->prefix = isset($table_prefix) ? $table_prefix : 'wp_';
|
67 |
$this->charset = 'utf8';
|
68 |
$this->collate = '';
|
69 |
+
$this->dbname = '/var/www/html/wp-content/database';
|
70 |
$this->set_table_names();
|
71 |
$this->connect();
|
72 |
$this->ready = true;
|
73 |
+
$this->base_prefix = $this->prefix;
|
74 |
+
$this->timer_start();
|
75 |
}
|
76 |
|
77 |
private function set_table_names() {
|
|
|
91 |
|
92 |
private function connect() {
|
93 |
try {
|
94 |
+
// Use in-memory SQLite database for Hugging Face Spaces
|
95 |
+
// This avoids file permission issues and improves performance
|
96 |
+
$this->pdo = new PDO('sqlite::memory:');
|
97 |
$this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
98 |
$this->pdo->exec('PRAGMA foreign_keys = ON');
|
99 |
+
$this->pdo->exec('PRAGMA journal_mode = MEMORY');
|
100 |
+
$this->pdo->exec('PRAGMA synchronous = OFF');
|
101 |
+
$this->pdo->exec('PRAGMA cache_size = 10000');
|
102 |
+
|
103 |
+
// Initialize WordPress tables in memory
|
104 |
+
$this->create_wordpress_tables();
|
105 |
+
|
106 |
+
return true;
|
107 |
} catch (PDOException $e) {
|
108 |
$this->last_error = $e->getMessage();
|
109 |
+
error_log("SQLite connection error: " . $e->getMessage());
|
110 |
+
return false;
|
111 |
}
|
112 |
}
|
113 |
|
|
|
139 |
return false;
|
140 |
} catch (PDOException $e) {
|
141 |
$this->last_error = $e->getMessage();
|
142 |
+
|
143 |
+
if (!$this->suppress_errors) {
|
144 |
+
if ($this->show_errors) {
|
145 |
+
error_log("SQLite Error: " . $e->getMessage());
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
return false;
|
150 |
}
|
151 |
}
|
|
|
239 |
}
|
240 |
|
241 |
public function print_error($str = '') {
|
242 |
+
global $EZSQL_ERROR;
|
243 |
+
|
244 |
+
if (!$str) {
|
245 |
+
$str = $this->last_error;
|
246 |
+
}
|
247 |
+
|
248 |
+
$EZSQL_ERROR[] = array(
|
249 |
+
'query' => $this->last_query,
|
250 |
+
'error_str' => $str
|
251 |
+
);
|
252 |
+
|
253 |
+
if ($this->suppress_errors) {
|
254 |
+
return false;
|
255 |
+
}
|
256 |
+
|
257 |
+
if ($this->show_errors) {
|
258 |
+
if (function_exists('wp_die')) {
|
259 |
+
wp_die($str);
|
260 |
+
} else {
|
261 |
+
die($str);
|
262 |
+
}
|
263 |
+
}
|
264 |
+
|
265 |
+
return false;
|
266 |
+
}
|
267 |
+
|
268 |
+
public function bail($message, $error_code = '500') {
|
269 |
+
if (!$this->show_errors) {
|
270 |
+
if (class_exists('WP_Error')) {
|
271 |
+
return new WP_Error($error_code, $message);
|
272 |
+
} else {
|
273 |
+
return false;
|
274 |
+
}
|
275 |
+
}
|
276 |
+
|
277 |
+
if (function_exists('wp_die')) {
|
278 |
+
wp_die($message);
|
279 |
+
} else {
|
280 |
+
die($message);
|
281 |
}
|
282 |
}
|
283 |
|
|
|
338 |
}
|
339 |
|
340 |
public function db_version() {
|
341 |
+
try {
|
342 |
+
$result = $this->pdo->query('SELECT sqlite_version()');
|
343 |
+
return $result->fetchColumn();
|
344 |
+
} catch (PDOException $e) {
|
345 |
+
return '0';
|
346 |
+
}
|
347 |
+
}
|
348 |
+
|
349 |
+
// Additional WordPress methods
|
350 |
+
public function get_col($query = null, $x = 0) {
|
351 |
+
if ($query) {
|
352 |
+
$this->query($query);
|
353 |
+
}
|
354 |
+
|
355 |
+
$new_array = array();
|
356 |
+
if ($this->last_result) {
|
357 |
+
for ($i = 0; $i < count($this->last_result); $i++) {
|
358 |
+
$row = (array) $this->last_result[$i];
|
359 |
+
$values = array_values($row);
|
360 |
+
if (isset($values[$x]) && $values[$x] !== '') {
|
361 |
+
$new_array[] = $values[$x];
|
362 |
+
}
|
363 |
+
}
|
364 |
+
}
|
365 |
+
return $new_array;
|
366 |
+
}
|
367 |
+
|
368 |
+
public function timer_start() {
|
369 |
+
$this->time_start = microtime(true);
|
370 |
+
return true;
|
371 |
+
}
|
372 |
+
|
373 |
+
public function timer_stop() {
|
374 |
+
return (microtime(true) - $this->time_start);
|
375 |
+
}
|
376 |
+
|
377 |
+
public function get_blog_prefix($blog_id = null) {
|
378 |
+
if (defined('MULTISITE') && MULTISITE) {
|
379 |
+
if (null === $blog_id) {
|
380 |
+
$blog_id = $this->blogid;
|
381 |
+
}
|
382 |
+
$blog_id = (int) $blog_id;
|
383 |
+
if (0 == $blog_id || 1 == $blog_id) {
|
384 |
+
return $this->base_prefix;
|
385 |
+
} else {
|
386 |
+
return $this->base_prefix . $blog_id . '_';
|
387 |
+
}
|
388 |
+
} else {
|
389 |
+
return $this->prefix;
|
390 |
+
}
|
391 |
}
|
392 |
|
393 |
public function flush() {
|
|
|
429 |
return true;
|
430 |
}
|
431 |
|
432 |
+
// Error handling methods
|
433 |
+
public function suppress_errors($suppress = true) {
|
434 |
+
$errors_before = $this->suppress_errors;
|
435 |
+
$this->suppress_errors = $suppress;
|
436 |
+
return $errors_before;
|
437 |
+
}
|
438 |
+
|
439 |
+
public function hide_errors() {
|
440 |
+
$show = $this->show_errors;
|
441 |
+
$this->show_errors = false;
|
442 |
+
return $show;
|
443 |
+
}
|
444 |
+
|
445 |
+
public function show_errors($show = true) {
|
446 |
+
$errors_before = $this->show_errors;
|
447 |
+
$this->show_errors = $show;
|
448 |
+
return $errors_before;
|
449 |
+
}
|
450 |
+
|
451 |
// WordPress data manipulation methods
|
452 |
public function insert($table, $data, $format = null) {
|
453 |
return $this->_insert_replace_helper($table, $data, $format, 'INSERT');
|
|
|
540 |
$sql = "$type INTO `$table` (`" . implode('`,`', $fields) . '`) VALUES (' . implode(',', $formatted_fields) . ')';
|
541 |
return $this->query($this->prepare($sql, array_values($data)));
|
542 |
}
|
543 |
+
|
544 |
+
// Create WordPress tables in memory
|
545 |
+
private function create_wordpress_tables() {
|
546 |
+
$tables = array(
|
547 |
+
// Posts table
|
548 |
+
"CREATE TABLE IF NOT EXISTS {$this->prefix}posts (
|
549 |
+
ID bigint(20) unsigned NOT NULL PRIMARY KEY,
|
550 |
+
post_author bigint(20) unsigned NOT NULL DEFAULT 0,
|
551 |
+
post_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
552 |
+
post_date_gmt datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
553 |
+
post_content longtext NOT NULL,
|
554 |
+
post_title text NOT NULL,
|
555 |
+
post_excerpt text NOT NULL,
|
556 |
+
post_status varchar(20) NOT NULL DEFAULT 'publish',
|
557 |
+
comment_status varchar(20) NOT NULL DEFAULT 'open',
|
558 |
+
ping_status varchar(20) NOT NULL DEFAULT 'open',
|
559 |
+
post_password varchar(255) NOT NULL DEFAULT '',
|
560 |
+
post_name varchar(200) NOT NULL DEFAULT '',
|
561 |
+
to_ping text NOT NULL,
|
562 |
+
pinged text NOT NULL,
|
563 |
+
post_modified datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
564 |
+
post_modified_gmt datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
565 |
+
post_content_filtered longtext NOT NULL,
|
566 |
+
post_parent bigint(20) unsigned NOT NULL DEFAULT 0,
|
567 |
+
guid varchar(255) NOT NULL DEFAULT '',
|
568 |
+
menu_order int(11) NOT NULL DEFAULT 0,
|
569 |
+
post_type varchar(20) NOT NULL DEFAULT 'post',
|
570 |
+
post_mime_type varchar(100) NOT NULL DEFAULT '',
|
571 |
+
comment_count bigint(20) NOT NULL DEFAULT 0
|
572 |
+
)",
|
573 |
+
|
574 |
+
// Users table
|
575 |
+
"CREATE TABLE IF NOT EXISTS {$this->prefix}users (
|
576 |
+
ID bigint(20) unsigned NOT NULL PRIMARY KEY,
|
577 |
+
user_login varchar(60) NOT NULL DEFAULT '',
|
578 |
+
user_pass varchar(255) NOT NULL DEFAULT '',
|
579 |
+
user_nicename varchar(50) NOT NULL DEFAULT '',
|
580 |
+
user_email varchar(100) NOT NULL DEFAULT '',
|
581 |
+
user_url varchar(100) NOT NULL DEFAULT '',
|
582 |
+
user_registered datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
583 |
+
user_activation_key varchar(255) NOT NULL DEFAULT '',
|
584 |
+
user_status int(11) NOT NULL DEFAULT 0,
|
585 |
+
display_name varchar(250) NOT NULL DEFAULT ''
|
586 |
+
)",
|
587 |
+
|
588 |
+
// Options table
|
589 |
+
"CREATE TABLE IF NOT EXISTS {$this->prefix}options (
|
590 |
+
option_id bigint(20) unsigned NOT NULL PRIMARY KEY,
|
591 |
+
option_name varchar(191) NOT NULL DEFAULT '',
|
592 |
+
option_value longtext NOT NULL,
|
593 |
+
autoload varchar(20) NOT NULL DEFAULT 'yes'
|
594 |
+
)",
|
595 |
+
|
596 |
+
// Comments table
|
597 |
+
"CREATE TABLE IF NOT EXISTS {$this->prefix}comments (
|
598 |
+
comment_ID bigint(20) unsigned NOT NULL PRIMARY KEY,
|
599 |
+
comment_post_ID bigint(20) unsigned NOT NULL DEFAULT 0,
|
600 |
+
comment_author tinytext NOT NULL,
|
601 |
+
comment_author_email varchar(100) NOT NULL DEFAULT '',
|
602 |
+
comment_author_url varchar(200) NOT NULL DEFAULT '',
|
603 |
+
comment_author_IP varchar(100) NOT NULL DEFAULT '',
|
604 |
+
comment_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
605 |
+
comment_date_gmt datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
606 |
+
comment_content text NOT NULL,
|
607 |
+
comment_karma int(11) NOT NULL DEFAULT 0,
|
608 |
+
comment_approved varchar(20) NOT NULL DEFAULT '1',
|
609 |
+
comment_agent varchar(255) NOT NULL DEFAULT '',
|
610 |
+
comment_type varchar(20) NOT NULL DEFAULT 'comment',
|
611 |
+
comment_parent bigint(20) unsigned NOT NULL DEFAULT 0,
|
612 |
+
user_id bigint(20) unsigned NOT NULL DEFAULT 0
|
613 |
+
)",
|
614 |
+
|
615 |
+
// Terms table
|
616 |
+
"CREATE TABLE IF NOT EXISTS {$this->prefix}terms (
|
617 |
+
term_id bigint(20) unsigned NOT NULL PRIMARY KEY,
|
618 |
+
name varchar(200) NOT NULL DEFAULT '',
|
619 |
+
slug varchar(200) NOT NULL DEFAULT '',
|
620 |
+
term_group bigint(10) NOT NULL DEFAULT 0
|
621 |
+
)",
|
622 |
+
|
623 |
+
// Term taxonomy table
|
624 |
+
"CREATE TABLE IF NOT EXISTS {$this->prefix}term_taxonomy (
|
625 |
+
term_taxonomy_id bigint(20) unsigned NOT NULL PRIMARY KEY,
|
626 |
+
term_id bigint(20) unsigned NOT NULL DEFAULT 0,
|
627 |
+
taxonomy varchar(32) NOT NULL DEFAULT '',
|
628 |
+
description longtext NOT NULL,
|
629 |
+
parent bigint(20) unsigned NOT NULL DEFAULT 0,
|
630 |
+
count bigint(20) NOT NULL DEFAULT 0
|
631 |
+
)",
|
632 |
+
|
633 |
+
// Term relationships table
|
634 |
+
"CREATE TABLE IF NOT EXISTS {$this->prefix}term_relationships (
|
635 |
+
object_id bigint(20) unsigned NOT NULL DEFAULT 0,
|
636 |
+
term_taxonomy_id bigint(20) unsigned NOT NULL DEFAULT 0,
|
637 |
+
term_order int(11) NOT NULL DEFAULT 0,
|
638 |
+
PRIMARY KEY (object_id, term_taxonomy_id)
|
639 |
+
)"
|
640 |
+
);
|
641 |
+
|
642 |
+
foreach ($tables as $sql) {
|
643 |
+
try {
|
644 |
+
$this->pdo->exec($sql);
|
645 |
+
} catch (PDOException $e) {
|
646 |
+
error_log("Error creating table: " . $e->getMessage());
|
647 |
+
}
|
648 |
+
}
|
649 |
+
|
650 |
+
// Insert default options
|
651 |
+
$this->insert_default_options();
|
652 |
+
}
|
653 |
+
|
654 |
+
// Insert default WordPress options
|
655 |
+
private function insert_default_options() {
|
656 |
+
$default_options = array(
|
657 |
+
array('option_name' => 'siteurl', 'option_value' => 'http://localhost', 'autoload' => 'yes'),
|
658 |
+
array('option_name' => 'home', 'option_value' => 'http://localhost', 'autoload' => 'yes'),
|
659 |
+
array('option_name' => 'blogname', 'option_value' => 'WordPress on Hugging Face', 'autoload' => 'yes'),
|
660 |
+
array('option_name' => 'blogdescription', 'option_value' => 'Just another WordPress site', 'autoload' => 'yes'),
|
661 |
+
array('option_name' => 'users_can_register', 'option_value' => '0', 'autoload' => 'yes'),
|
662 |
+
array('option_name' => 'admin_email', 'option_value' => '[email protected]', 'autoload' => 'yes'),
|
663 |
+
array('option_name' => 'start_of_week', 'option_value' => '1', 'autoload' => 'yes'),
|
664 |
+
array('option_name' => 'use_balanceTags', 'option_value' => '0', 'autoload' => 'yes'),
|
665 |
+
array('option_name' => 'use_smilies', 'option_value' => '1', 'autoload' => 'yes'),
|
666 |
+
array('option_name' => 'require_name_email', 'option_value' => '1', 'autoload' => 'yes'),
|
667 |
+
array('option_name' => 'comments_notify', 'option_value' => '1', 'autoload' => 'yes'),
|
668 |
+
array('option_name' => 'posts_per_rss', 'option_value' => '10', 'autoload' => 'yes'),
|
669 |
+
array('option_name' => 'rss_use_excerpt', 'option_value' => '0', 'autoload' => 'yes'),
|
670 |
+
array('option_name' => 'mailserver_url', 'option_value' => 'mail.example.com', 'autoload' => 'yes'),
|
671 |
+
array('option_name' => 'mailserver_login', 'option_value' => '[email protected]', 'autoload' => 'yes'),
|
672 |
+
array('option_name' => 'mailserver_pass', 'option_value' => 'password', 'autoload' => 'yes'),
|
673 |
+
array('option_name' => 'mailserver_port', 'option_value' => '110', 'autoload' => 'yes'),
|
674 |
+
array('option_name' => 'default_category', 'option_value' => '1', 'autoload' => 'yes'),
|
675 |
+
array('option_name' => 'default_comment_status', 'option_value' => 'open', 'autoload' => 'yes'),
|
676 |
+
array('option_name' => 'default_ping_status', 'option_value' => 'open', 'autoload' => 'yes'),
|
677 |
+
array('option_name' => 'default_pingback_flag', 'option_value' => '1', 'autoload' => 'yes'),
|
678 |
+
array('option_name' => 'posts_per_page', 'option_value' => '10', 'autoload' => 'yes'),
|
679 |
+
array('option_name' => 'date_format', 'option_value' => 'F j, Y', 'autoload' => 'yes'),
|
680 |
+
array('option_name' => 'time_format', 'option_value' => 'g:i a', 'autoload' => 'yes'),
|
681 |
+
array('option_name' => 'links_updated_date_format', 'option_value' => 'F j, Y g:i a', 'autoload' => 'yes'),
|
682 |
+
array('option_name' => 'comment_moderation', 'option_value' => '0', 'autoload' => 'yes'),
|
683 |
+
array('option_name' => 'moderation_notify', 'option_value' => '1', 'autoload' => 'yes'),
|
684 |
+
array('option_name' => 'permalink_structure', 'option_value' => '/%year%/%monthnum%/%day%/%postname%/', 'autoload' => 'yes'),
|
685 |
+
array('option_name' => 'rewrite_rules', 'option_value' => '', 'autoload' => 'yes'),
|
686 |
+
array('option_name' => 'hack_file', 'option_value' => '0', 'autoload' => 'yes'),
|
687 |
+
array('option_name' => 'blog_charset', 'option_value' => 'UTF-8', 'autoload' => 'yes'),
|
688 |
+
array('option_name' => 'moderation_keys', 'option_value' => '', 'autoload' => 'no'),
|
689 |
+
array('option_name' => 'active_plugins', 'option_value' => 'a:0:{}', 'autoload' => 'yes'),
|
690 |
+
array('option_name' => 'category_base', 'option_value' => '', 'autoload' => 'yes'),
|
691 |
+
array('option_name' => 'ping_sites', 'option_value' => 'http://rpc.pingomatic.com/', 'autoload' => 'yes'),
|
692 |
+
array('option_name' => 'comment_max_links', 'option_value' => '2', 'autoload' => 'yes'),
|
693 |
+
array('option_name' => 'gmt_offset', 'option_value' => '0', 'autoload' => 'yes'),
|
694 |
+
array('option_name' => 'default_email_category', 'option_value' => '1', 'autoload' => 'yes'),
|
695 |
+
array('option_name' => 'recently_edited', 'option_value' => '', 'autoload' => 'no'),
|
696 |
+
array('option_name' => 'template', 'option_value' => 'twentytwentyfour', 'autoload' => 'yes'),
|
697 |
+
array('option_name' => 'stylesheet', 'option_value' => 'twentytwentyfour', 'autoload' => 'yes'),
|
698 |
+
array('option_name' => 'comment_registration', 'option_value' => '0', 'autoload' => 'yes'),
|
699 |
+
array('option_name' => 'html_type', 'option_value' => 'text/html', 'autoload' => 'yes'),
|
700 |
+
array('option_name' => 'use_trackback', 'option_value' => '0', 'autoload' => 'yes'),
|
701 |
+
array('option_name' => 'default_role', 'option_value' => 'subscriber', 'autoload' => 'yes'),
|
702 |
+
array('option_name' => 'db_version', 'option_value' => '57155', 'autoload' => 'yes'),
|
703 |
+
array('option_name' => 'uploads_use_yearmonth_folders', 'option_value' => '1', 'autoload' => 'yes'),
|
704 |
+
array('option_name' => 'upload_path', 'option_value' => '', 'autoload' => 'yes'),
|
705 |
+
array('option_name' => 'blog_public', 'option_value' => '1', 'autoload' => 'yes'),
|
706 |
+
array('option_name' => 'default_link_category', 'option_value' => '2', 'autoload' => 'yes'),
|
707 |
+
array('option_name' => 'show_on_front', 'option_value' => 'posts', 'autoload' => 'yes'),
|
708 |
+
array('option_name' => 'tag_base', 'option_value' => '', 'autoload' => 'yes'),
|
709 |
+
array('option_name' => 'show_avatars', 'option_value' => '1', 'autoload' => 'yes'),
|
710 |
+
array('option_name' => 'avatar_rating', 'option_value' => 'G', 'autoload' => 'yes'),
|
711 |
+
array('option_name' => 'upload_url_path', 'option_value' => '', 'autoload' => 'yes'),
|
712 |
+
array('option_name' => 'thumbnail_size_w', 'option_value' => '150', 'autoload' => 'yes'),
|
713 |
+
array('option_name' => 'thumbnail_size_h', 'option_value' => '150', 'autoload' => 'yes'),
|
714 |
+
array('option_name' => 'thumbnail_crop', 'option_value' => '1', 'autoload' => 'yes'),
|
715 |
+
array('option_name' => 'medium_size_w', 'option_value' => '300', 'autoload' => 'yes'),
|
716 |
+
array('option_name' => 'medium_size_h', 'option_value' => '300', 'autoload' => 'yes'),
|
717 |
+
array('option_name' => 'avatar_default', 'option_value' => 'mystery', 'autoload' => 'yes'),
|
718 |
+
array('option_name' => 'large_size_w', 'option_value' => '1024', 'autoload' => 'yes'),
|
719 |
+
array('option_name' => 'large_size_h', 'option_value' => '1024', 'autoload' => 'yes'),
|
720 |
+
array('option_name' => 'image_default_link_type', 'option_value' => 'none', 'autoload' => 'yes'),
|
721 |
+
array('option_name' => 'image_default_size', 'option_value' => '', 'autoload' => 'yes'),
|
722 |
+
array('option_name' => 'image_default_align', 'option_value' => '', 'autoload' => 'yes'),
|
723 |
+
array('option_name' => 'close_comments_for_old_posts', 'option_value' => '0', 'autoload' => 'yes'),
|
724 |
+
array('option_name' => 'close_comments_days_old', 'option_value' => '14', 'autoload' => 'yes'),
|
725 |
+
array('option_name' => 'thread_comments', 'option_value' => '1', 'autoload' => 'yes'),
|
726 |
+
array('option_name' => 'thread_comments_depth', 'option_value' => '5', 'autoload' => 'yes'),
|
727 |
+
array('option_name' => 'page_comments', 'option_value' => '0', 'autoload' => 'yes'),
|
728 |
+
array('option_name' => 'comments_per_page', 'option_value' => '50', 'autoload' => 'yes'),
|
729 |
+
array('option_name' => 'default_comments_page', 'option_value' => 'newest', 'autoload' => 'yes'),
|
730 |
+
array('option_name' => 'comment_order', 'option_value' => 'asc', 'autoload' => 'yes'),
|
731 |
+
array('option_name' => 'sticky_posts', 'option_value' => 'a:0:{}', 'autoload' => 'yes'),
|
732 |
+
array('option_name' => 'widget_categories', 'option_value' => 'a:0:{}', 'autoload' => 'yes'),
|
733 |
+
array('option_name' => 'widget_text', 'option_value' => 'a:0:{}', 'autoload' => 'yes'),
|
734 |
+
array('option_name' => 'widget_rss', 'option_value' => 'a:0:{}', 'autoload' => 'yes'),
|
735 |
+
array('option_name' => 'uninstall_plugins', 'option_value' => 'a:0:{}', 'autoload' => 'no'),
|
736 |
+
array('option_name' => 'timezone_string', 'option_value' => '', 'autoload' => 'yes'),
|
737 |
+
array('option_name' => 'page_for_posts', 'option_value' => '0', 'autoload' => 'yes'),
|
738 |
+
array('option_name' => 'page_on_front', 'option_value' => '0', 'autoload' => 'yes'),
|
739 |
+
array('option_name' => 'default_post_format', 'option_value' => '0', 'autoload' => 'yes'),
|
740 |
+
array('option_name' => 'link_manager_enabled', 'option_value' => '0', 'autoload' => 'yes'),
|
741 |
+
array('option_name' => 'finished_splitting_shared_terms', 'option_value' => '1', 'autoload' => 'yes'),
|
742 |
+
array('option_name' => 'site_icon', 'option_value' => '0', 'autoload' => 'yes'),
|
743 |
+
array('option_name' => 'medium_large_size_w', 'option_value' => '768', 'autoload' => 'yes'),
|
744 |
+
array('option_name' => 'medium_large_size_h', 'option_value' => '0', 'autoload' => 'yes'),
|
745 |
+
array('option_name' => 'wp_page_for_privacy_policy', 'option_value' => '3', 'autoload' => 'yes'),
|
746 |
+
array('option_name' => 'show_comments_cookies_opt_in', 'option_value' => '1', 'autoload' => 'yes'),
|
747 |
+
array('option_name' => 'admin_email_lifespan', 'option_value' => '1735689600', 'autoload' => 'yes'),
|
748 |
+
array('option_name' => 'disallowed_keys', 'option_value' => '', 'autoload' => 'no'),
|
749 |
+
array('option_name' => 'comment_previously_approved', 'option_value' => '1', 'autoload' => 'yes'),
|
750 |
+
array('option_name' => 'auto_plugin_theme_update_emails', 'option_value' => 'a:0:{}', 'autoload' => 'no'),
|
751 |
+
array('option_name' => 'auto_update_core_dev', 'option_value' => 'enabled', 'autoload' => 'yes'),
|
752 |
+
array('option_name' => 'auto_update_core_minor', 'option_value' => 'enabled', 'autoload' => 'yes'),
|
753 |
+
array('option_name' => 'auto_update_core_major', 'option_value' => 'enabled', 'autoload' => 'yes'),
|
754 |
+
array('option_name' => 'wp_force_deactivated_plugins', 'option_value' => 'a:0:{}', 'autoload' => 'yes'),
|
755 |
+
array('option_name' => 'initial_db_version', 'option_value' => '57155', 'autoload' => 'yes'),
|
756 |
+
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'),
|
757 |
+
array('option_name' => 'fresh_site', 'option_value' => '1', 'autoload' => 'yes')
|
758 |
+
);
|
759 |
+
|
760 |
+
foreach ($default_options as $option) {
|
761 |
+
try {
|
762 |
+
$this->insert($this->prefix . 'options', $option);
|
763 |
+
} catch (Exception $e) {
|
764 |
+
// Ignore duplicate key errors
|
765 |
+
}
|
766 |
+
}
|
767 |
+
}
|
768 |
}
|
769 |
|
770 |
// Initialize SQLite database connection
|
test-php.php
CHANGED
@@ -61,7 +61,7 @@ if (file_exists('/var/www/html/wp-content/db.php')) {
|
|
61 |
echo "<p>β SQLite_DB class loaded successfully</p>";
|
62 |
|
63 |
// Test required methods
|
64 |
-
$methods = ['set_prefix', 'get_results', 'get_row', 'get_var', 'prepare', 'insert', 'update', 'delete'];
|
65 |
foreach ($methods as $method) {
|
66 |
if (method_exists($test_db, $method)) {
|
67 |
echo "<p style='color: green;'>β Method $method exists</p>";
|
@@ -71,7 +71,7 @@ if (file_exists('/var/www/html/wp-content/db.php')) {
|
|
71 |
}
|
72 |
|
73 |
// Test properties
|
74 |
-
$properties = ['prefix', 'posts', 'users', 'options', 'ready', 'field_types'];
|
75 |
foreach ($properties as $prop) {
|
76 |
if (property_exists($test_db, $prop)) {
|
77 |
echo "<p style='color: green;'>β Property $prop exists</p>";
|
@@ -87,6 +87,44 @@ if (file_exists('/var/www/html/wp-content/db.php')) {
|
|
87 |
echo "<p style='color: red;'>β wp-content/db.php not found</p>";
|
88 |
}
|
89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
echo "<hr>";
|
91 |
echo "<p><a href='/'>Try WordPress</a> | <a href='/debug.php'>Debug Info</a></p>";
|
92 |
?>
|
|
|
61 |
echo "<p>β SQLite_DB class loaded successfully</p>";
|
62 |
|
63 |
// Test required methods
|
64 |
+
$methods = ['set_prefix', 'get_results', 'get_row', 'get_var', 'get_col', 'prepare', 'insert', 'update', 'delete', 'suppress_errors', 'show_errors', 'hide_errors', 'bail', 'timer_start', 'timer_stop', 'get_blog_prefix'];
|
65 |
foreach ($methods as $method) {
|
66 |
if (method_exists($test_db, $method)) {
|
67 |
echo "<p style='color: green;'>β Method $method exists</p>";
|
|
|
71 |
}
|
72 |
|
73 |
// Test properties
|
74 |
+
$properties = ['prefix', 'posts', 'users', 'options', 'ready', 'field_types', 'suppress_errors', 'show_errors', 'time_start', 'blogid', 'base_prefix', 'charset', 'collate', 'dbname'];
|
75 |
foreach ($properties as $prop) {
|
76 |
if (property_exists($test_db, $prop)) {
|
77 |
echo "<p style='color: green;'>β Property $prop exists</p>";
|
|
|
87 |
echo "<p style='color: red;'>β wp-content/db.php not found</p>";
|
88 |
}
|
89 |
|
90 |
+
// Test database connection
|
91 |
+
echo "<h3>Database Connection Test</h3>";
|
92 |
+
if ($db->ready) {
|
93 |
+
echo "<p style='color: green;'>β Database connection successful</p>";
|
94 |
+
echo "<p>Database type: SQLite (in-memory)</p>";
|
95 |
+
echo "<p>Database prefix: " . $db->prefix . "</p>";
|
96 |
+
|
97 |
+
// Test if WordPress tables were created
|
98 |
+
echo "<h4>WordPress Tables Test</h4>";
|
99 |
+
$tables_to_check = array('posts', 'users', 'options', 'comments', 'terms', 'term_taxonomy', 'term_relationships');
|
100 |
+
foreach ($tables_to_check as $table) {
|
101 |
+
$table_name = $db->prefix . $table;
|
102 |
+
$result = $db->get_results("SELECT name FROM sqlite_master WHERE type='table' AND name='$table_name'");
|
103 |
+
if (!empty($result)) {
|
104 |
+
echo "<p style='color: green;'>β Table '$table_name' exists</p>";
|
105 |
+
} else {
|
106 |
+
echo "<p style='color: red;'>β Table '$table_name' missing</p>";
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
// Test default options
|
111 |
+
echo "<h4>Default Options Test</h4>";
|
112 |
+
$option_count = $db->get_var("SELECT COUNT(*) FROM {$db->prefix}options");
|
113 |
+
echo "<p>Total options in database: $option_count</p>";
|
114 |
+
|
115 |
+
$test_options = array('siteurl', 'home', 'blogname', 'admin_email');
|
116 |
+
foreach ($test_options as $option) {
|
117 |
+
$value = $db->get_var($db->prepare("SELECT option_value FROM {$db->prefix}options WHERE option_name = %s", $option));
|
118 |
+
if ($value !== null) {
|
119 |
+
echo "<p style='color: green;'>β Option '$option': $value</p>";
|
120 |
+
} else {
|
121 |
+
echo "<p style='color: red;'>β Option '$option' not found</p>";
|
122 |
+
}
|
123 |
+
}
|
124 |
+
} else {
|
125 |
+
echo "<p style='color: red;'>β Database connection failed</p>";
|
126 |
+
}
|
127 |
+
|
128 |
echo "<hr>";
|
129 |
echo "<p><a href='/'>Try WordPress</a> | <a href='/debug.php'>Debug Info</a></p>";
|
130 |
?>
|