@wp-playground/wordpress 3.1.36 → 3.1.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +342 -69
- package/index.cjs.map +1 -1
- package/index.js +1004 -560
- package/index.js.map +1 -1
- package/legacy-wp/legacy-fixes.d.ts +5 -2
- package/legacy-wp/mysql-shims.d.ts +1 -1
- package/legacy-wp/relative-paths.d.ts +13 -0
- package/legacy-wp/wp-07-support.d.ts +11 -0
- package/package.json +8 -7
package/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { isLegacyPHPVersion as
|
|
2
|
-
import { joinPaths as
|
|
3
|
-
import { unzipFile as
|
|
4
|
-
import { logger as
|
|
5
|
-
async function
|
|
1
|
+
import { isLegacyPHPVersion as m, setPhpIniEntries as N, withPHPIniValues as A, sandboxedSpawnHandlerFactory as W, PHPRequestHandler as G, PHP as M, writeFiles as O } from "@php-wasm/universal";
|
|
2
|
+
import { joinPaths as a, phpVar as p, phpVars as P, dirname as B, basename as H } from "@php-wasm/util";
|
|
3
|
+
import { unzipFile as g, createMemoizedFetch as X } from "@wp-playground/common";
|
|
4
|
+
import { logger as d } from "@php-wasm/logger";
|
|
5
|
+
async function U(e) {
|
|
6
6
|
await e.writeFile(
|
|
7
7
|
"/internal/shared/mu-plugins/0-playground.php",
|
|
8
8
|
`<?php
|
|
@@ -208,7 +208,7 @@ async function S(e) {
|
|
|
208
208
|
`
|
|
209
209
|
);
|
|
210
210
|
}
|
|
211
|
-
function
|
|
211
|
+
function S(e) {
|
|
212
212
|
return `
|
|
213
213
|
/**
|
|
214
214
|
* Loads the SQLite integration plugin before WordPress is loaded
|
|
@@ -281,7 +281,7 @@ $wpdb = $GLOBALS['wpdb'] = new Playground_SQLite_Integration_Loader();
|
|
|
281
281
|
*/
|
|
282
282
|
`;
|
|
283
283
|
}
|
|
284
|
-
const
|
|
284
|
+
const V = `
|
|
285
285
|
if (function_exists('is_user_logged_in') && is_user_logged_in()) {
|
|
286
286
|
return;
|
|
287
287
|
}
|
|
@@ -375,7 +375,7 @@ const H = `
|
|
|
375
375
|
return;
|
|
376
376
|
}
|
|
377
377
|
`;
|
|
378
|
-
async function
|
|
378
|
+
async function Y(e) {
|
|
379
379
|
await e.mkdir("/internal/shared/mu-plugins"), await e.writeFile(
|
|
380
380
|
"/internal/shared/auto_prepend_file.php",
|
|
381
381
|
`<?php
|
|
@@ -639,7 +639,7 @@ function playground_load_mu_plugins() {
|
|
|
639
639
|
if ((function_exists('wp_doing_ajax') && wp_doing_ajax()) || defined('REST_REQUEST')) {
|
|
640
640
|
return;
|
|
641
641
|
}
|
|
642
|
-
${
|
|
642
|
+
${V}
|
|
643
643
|
}
|
|
644
644
|
add_action('init', 'playground_auto_login', 1);
|
|
645
645
|
|
|
@@ -666,7 +666,7 @@ function playground_load_mu_plugins() {
|
|
|
666
666
|
return $interval;
|
|
667
667
|
}
|
|
668
668
|
`
|
|
669
|
-
), await
|
|
669
|
+
), await U(e), await e.writeFile(
|
|
670
670
|
"/internal/shared/preload/error-handler.php",
|
|
671
671
|
`<?php
|
|
672
672
|
$GLOBALS['_playground_consts'] = array();
|
|
@@ -677,13 +677,13 @@ if (file_exists('/internal/shared/consts.json')) {
|
|
|
677
677
|
}
|
|
678
678
|
function _playground_error_handler($severity, $message, $file, $line) {
|
|
679
679
|
$playground_consts = $GLOBALS['_playground_consts'];
|
|
680
|
-
${
|
|
680
|
+
${K}
|
|
681
681
|
return false;
|
|
682
682
|
}
|
|
683
683
|
set_error_handler('_playground_error_handler');`
|
|
684
684
|
);
|
|
685
685
|
}
|
|
686
|
-
const
|
|
686
|
+
const K = `
|
|
687
687
|
// http_api_transports is deprecated since 6.4.0 but Playground's
|
|
688
688
|
// networking layer still registers it for wp_http_supports().
|
|
689
689
|
// @see https://core.trac.wordpress.org/ticket/37708
|
|
@@ -726,62 +726,513 @@ const V = `
|
|
|
726
726
|
return;
|
|
727
727
|
}
|
|
728
728
|
`;
|
|
729
|
-
|
|
730
|
-
|
|
729
|
+
function I(e) {
|
|
730
|
+
return [
|
|
731
|
+
// Parenthesized forms.
|
|
732
|
+
/(^|[^\w$])((?:require|include)(?:_once)?)\s*\(\s*(['"])(\.\.\/[^'"]+)\3\s*\)/g,
|
|
733
|
+
/(^|[^\w$])((?:require|include)(?:_once)?)\s*\(\s*(['"])(\.\/[^'"]+)\3\s*\)/g,
|
|
734
|
+
// Bare filename (e.g. 'admin-header.php'). Restrict to .php to
|
|
735
|
+
// avoid false positives.
|
|
736
|
+
/(^|[^\w$])((?:require|include)(?:_once)?)\s*\(\s*(['"])([a-z][\w-]*\.php)\3\s*\)/g,
|
|
737
|
+
// Statement forms without parentheses (WP 2.0 uses this).
|
|
738
|
+
/(^|[^\w$])((?:require|include)(?:_once)?)\s+(['"])(\.\.\/[^'"]+)\3/g,
|
|
739
|
+
/(^|[^\w$])((?:require|include)(?:_once)?)\s+(['"])(\.\/[^'"]+)\3/g,
|
|
740
|
+
/(^|[^\w$])((?:require|include)(?:_once)?)\s+(['"])([a-z][\w-]*\.php)\3/g
|
|
741
|
+
].reduce(
|
|
742
|
+
(i, t) => i.replace(
|
|
743
|
+
t,
|
|
744
|
+
(s, r, o, _, l) => `${r}${o}(${Q(l)})`
|
|
745
|
+
),
|
|
746
|
+
e
|
|
747
|
+
);
|
|
748
|
+
}
|
|
749
|
+
function Q(e) {
|
|
750
|
+
let n = e, i = 0;
|
|
751
|
+
for (; n.startsWith("../"); )
|
|
752
|
+
i++, n = n.slice(3);
|
|
753
|
+
for (; n.startsWith("./"); )
|
|
754
|
+
n = n.slice(2);
|
|
755
|
+
let t = "dirname(__FILE__)";
|
|
756
|
+
for (let s = 0; s < i; s++)
|
|
757
|
+
t = `dirname(${t})`;
|
|
758
|
+
return `${t} . '/${n}'`;
|
|
759
|
+
}
|
|
760
|
+
async function j(e, n) {
|
|
761
|
+
return R(e, n) ? (await Z(e, n), await J(e, n), await ee(e, n), await te(e, n), await ne(e, n), await se(e, n), await re(e, n), !0) : !1;
|
|
762
|
+
}
|
|
763
|
+
async function z(e) {
|
|
764
|
+
return R(e, e.documentRoot) ? (await e.run({
|
|
765
|
+
code: `<?php
|
|
766
|
+
$db_dir = getenv('DOCUMENT_ROOT') . '/wp-content/database/';
|
|
767
|
+
if (!is_dir($db_dir)) { @mkdir($db_dir, 0777, true); }
|
|
768
|
+
$db_path = $db_dir . '.ht.sqlite';
|
|
769
|
+
$pdo = new PDO('sqlite:' . $db_path);
|
|
770
|
+
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
771
|
+
$now = date('Y-m-d H:i:s');
|
|
772
|
+
|
|
773
|
+
$tables_sql = array(
|
|
774
|
+
'b2posts' => "CREATE TABLE IF NOT EXISTS b2posts (
|
|
775
|
+
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
776
|
+
post_author INTEGER NOT NULL DEFAULT 0,
|
|
777
|
+
post_date TEXT NOT NULL DEFAULT '0000-00-00 00:00:00',
|
|
778
|
+
post_content TEXT NOT NULL DEFAULT '',
|
|
779
|
+
post_title TEXT NOT NULL DEFAULT '',
|
|
780
|
+
post_category INTEGER NOT NULL DEFAULT 0,
|
|
781
|
+
post_excerpt TEXT NOT NULL DEFAULT '',
|
|
782
|
+
post_status TEXT NOT NULL DEFAULT 'publish',
|
|
783
|
+
comment_status TEXT NOT NULL DEFAULT 'open',
|
|
784
|
+
ping_status TEXT NOT NULL DEFAULT 'open',
|
|
785
|
+
post_password TEXT NOT NULL DEFAULT ''
|
|
786
|
+
)",
|
|
787
|
+
'b2categories' => "CREATE TABLE IF NOT EXISTS b2categories (
|
|
788
|
+
cat_ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
789
|
+
cat_name TEXT NOT NULL DEFAULT ''
|
|
790
|
+
)",
|
|
791
|
+
'b2comments' => "CREATE TABLE IF NOT EXISTS b2comments (
|
|
792
|
+
comment_ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
793
|
+
comment_post_ID INTEGER NOT NULL DEFAULT 0,
|
|
794
|
+
comment_author TEXT NOT NULL DEFAULT '',
|
|
795
|
+
comment_author_email TEXT NOT NULL DEFAULT '',
|
|
796
|
+
comment_author_url TEXT NOT NULL DEFAULT '',
|
|
797
|
+
comment_author_IP TEXT NOT NULL DEFAULT '',
|
|
798
|
+
comment_date TEXT NOT NULL DEFAULT '0000-00-00 00:00:00',
|
|
799
|
+
comment_content TEXT NOT NULL DEFAULT '',
|
|
800
|
+
comment_karma INTEGER NOT NULL DEFAULT 0
|
|
801
|
+
)",
|
|
802
|
+
'b2settings' => "CREATE TABLE IF NOT EXISTS b2settings (
|
|
803
|
+
ID INTEGER NOT NULL DEFAULT 1,
|
|
804
|
+
posts_per_page INTEGER NOT NULL DEFAULT 20,
|
|
805
|
+
what_to_show TEXT NOT NULL DEFAULT 'posts',
|
|
806
|
+
archive_mode TEXT NOT NULL DEFAULT 'postbypost',
|
|
807
|
+
time_difference INTEGER NOT NULL DEFAULT 0,
|
|
808
|
+
AutoBR INTEGER NOT NULL DEFAULT 1,
|
|
809
|
+
time_format TEXT NOT NULL DEFAULT 'g:i a',
|
|
810
|
+
date_format TEXT NOT NULL DEFAULT 'n/j/Y',
|
|
811
|
+
PRIMARY KEY (ID)
|
|
812
|
+
)",
|
|
813
|
+
'b2users' => "CREATE TABLE IF NOT EXISTS b2users (
|
|
814
|
+
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
815
|
+
user_login TEXT NOT NULL DEFAULT '',
|
|
816
|
+
user_pass TEXT NOT NULL DEFAULT '',
|
|
817
|
+
user_firstname TEXT NOT NULL DEFAULT '',
|
|
818
|
+
user_lastname TEXT NOT NULL DEFAULT '',
|
|
819
|
+
user_nickname TEXT NOT NULL DEFAULT '',
|
|
820
|
+
user_icq INTEGER NOT NULL DEFAULT 0,
|
|
821
|
+
user_email TEXT NOT NULL DEFAULT '',
|
|
822
|
+
user_url TEXT NOT NULL DEFAULT '',
|
|
823
|
+
user_ip TEXT NOT NULL DEFAULT '',
|
|
824
|
+
user_domain TEXT NOT NULL DEFAULT '',
|
|
825
|
+
user_browser TEXT NOT NULL DEFAULT '',
|
|
826
|
+
dateYMDhour TEXT NOT NULL DEFAULT '0000-00-00 00:00:00',
|
|
827
|
+
user_level INTEGER NOT NULL DEFAULT 0,
|
|
828
|
+
user_aim TEXT NOT NULL DEFAULT '',
|
|
829
|
+
user_msn TEXT NOT NULL DEFAULT '',
|
|
830
|
+
user_yim TEXT NOT NULL DEFAULT '',
|
|
831
|
+
user_idmode TEXT NOT NULL DEFAULT ''
|
|
832
|
+
)",
|
|
833
|
+
'b2links' => "CREATE TABLE IF NOT EXISTS b2links (
|
|
834
|
+
link_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
835
|
+
link_url TEXT NOT NULL DEFAULT '',
|
|
836
|
+
link_name TEXT NOT NULL DEFAULT '',
|
|
837
|
+
link_image TEXT NOT NULL DEFAULT '',
|
|
838
|
+
link_target TEXT NOT NULL DEFAULT '',
|
|
839
|
+
link_category INTEGER NOT NULL DEFAULT 0,
|
|
840
|
+
link_description TEXT NOT NULL DEFAULT '',
|
|
841
|
+
link_visible TEXT NOT NULL DEFAULT 'Y',
|
|
842
|
+
link_owner INTEGER NOT NULL DEFAULT 1,
|
|
843
|
+
link_rating INTEGER NOT NULL DEFAULT 0,
|
|
844
|
+
link_updated TEXT NOT NULL DEFAULT '0000-00-00 00:00:00',
|
|
845
|
+
link_rel TEXT NOT NULL DEFAULT '',
|
|
846
|
+
link_notes TEXT NOT NULL DEFAULT '',
|
|
847
|
+
link_rss TEXT NOT NULL DEFAULT ''
|
|
848
|
+
)",
|
|
849
|
+
'b2linkcategories' => "CREATE TABLE IF NOT EXISTS b2linkcategories (
|
|
850
|
+
cat_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
851
|
+
cat_name TEXT NOT NULL DEFAULT '',
|
|
852
|
+
auto_toggle TEXT NOT NULL DEFAULT 'N',
|
|
853
|
+
show_images TEXT NOT NULL DEFAULT 'Y',
|
|
854
|
+
show_description TEXT NOT NULL DEFAULT 'N',
|
|
855
|
+
show_rating TEXT NOT NULL DEFAULT 'Y',
|
|
856
|
+
show_updated TEXT NOT NULL DEFAULT 'Y',
|
|
857
|
+
sort_order TEXT NOT NULL DEFAULT 'name',
|
|
858
|
+
sort_desc TEXT NOT NULL DEFAULT 'ASC',
|
|
859
|
+
text_before_link TEXT NOT NULL DEFAULT '<li>',
|
|
860
|
+
text_after_link TEXT NOT NULL DEFAULT '<br />',
|
|
861
|
+
text_after_all TEXT NOT NULL DEFAULT '</li>',
|
|
862
|
+
list_limit INTEGER NOT NULL DEFAULT -1
|
|
863
|
+
)"
|
|
864
|
+
);
|
|
865
|
+
foreach ($tables_sql as $sql) {
|
|
866
|
+
$pdo->exec($sql);
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
if (!$pdo->query("SELECT COUNT(*) FROM b2categories")->fetchColumn()) {
|
|
870
|
+
$pdo->exec("INSERT INTO b2categories (cat_ID, cat_name) VALUES (1, 'General')");
|
|
871
|
+
}
|
|
872
|
+
if (!$pdo->query("SELECT COUNT(*) FROM b2settings")->fetchColumn()) {
|
|
873
|
+
$pdo->exec("INSERT INTO b2settings (ID, posts_per_page, what_to_show, archive_mode, time_difference, AutoBR, time_format, date_format) VALUES (1, 20, 'posts', 'postbypost', 0, 1, 'g:i a', 'n/j/Y')");
|
|
874
|
+
}
|
|
875
|
+
if (!$pdo->query("SELECT COUNT(*) FROM b2users")->fetchColumn()) {
|
|
876
|
+
$pass = md5('password');
|
|
877
|
+
$pdo->exec("INSERT INTO b2users (ID, user_login, user_pass, user_nickname, user_email, user_level, dateYMDhour, user_idmode) VALUES (1, 'admin', '{$pass}', 'admin', 'admin@localhost.com', 10, '{$now}', 'nickname')");
|
|
878
|
+
} else {
|
|
879
|
+
$pass = md5('password');
|
|
880
|
+
$pdo->exec("UPDATE b2users SET user_pass = '{$pass}', user_level = 10 WHERE user_login = 'admin'");
|
|
881
|
+
}
|
|
882
|
+
if (!$pdo->query("SELECT COUNT(*) FROM b2posts")->fetchColumn()) {
|
|
883
|
+
$content = 'Welcome to WordPress. This is the first post. Edit or delete it, then start blogging!';
|
|
884
|
+
$pdo->exec("INSERT INTO b2posts (ID, post_author, post_date, post_content, post_title, post_category, post_excerpt, post_status, comment_status, ping_status, post_password) VALUES (1, 1, '{$now}', '{$content}', 'Hello world!', 1, '', 'publish', 'open', 'open', '')");
|
|
885
|
+
}
|
|
886
|
+
if (!$pdo->query("SELECT COUNT(*) FROM b2comments")->fetchColumn()) {
|
|
887
|
+
$pdo->exec("INSERT INTO b2comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_karma) VALUES (1, 'Mr WordPress', 'mr@wordpress.org', 'http://wordpress.org', '127.0.0.1', '{$now}', 'Hi, this is a comment. To delete a comment, just log in and view the comments for this post.', 0)");
|
|
888
|
+
}
|
|
889
|
+
if (!$pdo->query("SELECT COUNT(*) FROM b2linkcategories")->fetchColumn()) {
|
|
890
|
+
$pdo->exec("INSERT INTO b2linkcategories (cat_id, cat_name) VALUES (1, 'General')");
|
|
891
|
+
}
|
|
892
|
+
if (!$pdo->query("SELECT COUNT(*) FROM b2links")->fetchColumn()) {
|
|
893
|
+
$pdo->exec("INSERT INTO b2links (link_url, link_name, link_category, link_visible, link_owner) VALUES ('http://wordpress.org', 'WordPress', 1, 'Y', 1)");
|
|
894
|
+
}
|
|
895
|
+
`,
|
|
896
|
+
env: {
|
|
897
|
+
DOCUMENT_ROOT: e.documentRoot
|
|
898
|
+
}
|
|
899
|
+
}), !0) : !1;
|
|
900
|
+
}
|
|
901
|
+
function R(e, n) {
|
|
902
|
+
const i = a(n, "b2config.php"), t = a(n, "b2-include/b2vars.php");
|
|
903
|
+
return !e.fileExists(i) || !e.fileExists(t) ? !1 : e.readFileAsText(t).includes("$b2_version = '0.71'");
|
|
904
|
+
}
|
|
905
|
+
async function Z(e, n) {
|
|
906
|
+
for (const i of [
|
|
907
|
+
a(n, "wp-includes"),
|
|
908
|
+
a(n, "wp-content"),
|
|
909
|
+
a(n, "wp-content/database")
|
|
910
|
+
])
|
|
911
|
+
e.isDir(i) || await e.mkdir(i);
|
|
912
|
+
}
|
|
913
|
+
async function J(e, n) {
|
|
914
|
+
const i = a(n, "wp-includes/version.php");
|
|
915
|
+
await e.writeFile(
|
|
916
|
+
i,
|
|
917
|
+
`<?php
|
|
918
|
+
$wp_version = '0.71';
|
|
919
|
+
$wp_db_version = 71;
|
|
920
|
+
`
|
|
921
|
+
);
|
|
922
|
+
const t = a(n, "wp-config.php");
|
|
923
|
+
e.fileExists(t) || await e.writeFile(
|
|
924
|
+
t,
|
|
925
|
+
"<?php require_once dirname(__FILE__) . '/b2config.php';"
|
|
926
|
+
);
|
|
927
|
+
const s = a(n, "wp-load.php");
|
|
928
|
+
e.fileExists(s) || await e.writeFile(
|
|
929
|
+
s,
|
|
930
|
+
`<?php
|
|
931
|
+
if (!defined('ABSPATH')) {
|
|
932
|
+
define('ABSPATH', dirname(__FILE__) . '/');
|
|
933
|
+
}
|
|
934
|
+
require_once ABSPATH . 'b2config.php';
|
|
935
|
+
`
|
|
936
|
+
);
|
|
937
|
+
const r = a(n, "wp-admin/post.php");
|
|
938
|
+
e.fileExists(r) || await e.writeFile(
|
|
939
|
+
r,
|
|
940
|
+
"<?php require_once dirname(__FILE__) . '/b2edit.php';"
|
|
941
|
+
);
|
|
942
|
+
}
|
|
943
|
+
async function ee(e, n) {
|
|
944
|
+
const i = a(n, "b2config.php");
|
|
945
|
+
let t = e.readFileAsText(i);
|
|
946
|
+
const s = t;
|
|
947
|
+
t.includes("pg_wp07_bootstrap") || (t = t.replace(
|
|
948
|
+
"<?php",
|
|
949
|
+
`<?php
|
|
950
|
+
if (!defined('ABSPATH')) define('ABSPATH', dirname(__FILE__) . '/'); /* pg_wp07_bootstrap */
|
|
951
|
+
if (!defined('WPINC')) define('WPINC', 'b2-include');
|
|
952
|
+
if (!defined('WP_CONTENT_DIR')) define('WP_CONTENT_DIR', ABSPATH . 'wp-content');
|
|
953
|
+
if (!defined('DB_ENGINE')) define('DB_ENGINE', 'sqlite');
|
|
954
|
+
if (!isset($table_prefix)) $table_prefix = 'b2';
|
|
955
|
+
error_reporting(E_ALL & ~E_NOTICE & ~8192 & ~2048);
|
|
956
|
+
`
|
|
957
|
+
)), t = t.replace(
|
|
958
|
+
/\$siteurl\s*=\s*'http:\/\/example\.com';[^\n]*/,
|
|
959
|
+
"$siteurl = defined('WP_SITEURL') ? WP_SITEURL : 'http://localhost'; // pg_wp07_siteurl"
|
|
960
|
+
).replace(
|
|
961
|
+
'$blogname = "my weblog";',
|
|
962
|
+
'$blogname = "My WordPress Website";'
|
|
963
|
+
).replace(
|
|
964
|
+
'$blogdescription = "babblings !";',
|
|
965
|
+
'$blogdescription = "Just another WordPress weblog";'
|
|
966
|
+
).replace(
|
|
967
|
+
"$admin_email = 'you@example.com';",
|
|
968
|
+
"$admin_email = 'admin@localhost.com';"
|
|
969
|
+
).replace(
|
|
970
|
+
"$abspath = getenv('DOCUMENT_ROOT') . $relpath . '/';",
|
|
971
|
+
"$abspath = dirname(__FILE__) . '/';"
|
|
972
|
+
), t !== s && await e.writeFile(i, t);
|
|
973
|
+
}
|
|
974
|
+
async function te(e, n) {
|
|
975
|
+
const i = a(n, "blog.header.php");
|
|
976
|
+
let t = e.readFileAsText(i);
|
|
977
|
+
const s = t;
|
|
978
|
+
t = t.replace(
|
|
979
|
+
`$where .= ' AND (post_status = "publish"';`,
|
|
980
|
+
`$where .= " AND (post_status = 'publish'";`
|
|
981
|
+
), t !== s && await e.writeFile(i, t);
|
|
982
|
+
}
|
|
983
|
+
async function ne(e, n) {
|
|
984
|
+
const i = a(n, "b2-include/wp-db.php");
|
|
985
|
+
let t = e.readFileAsText(i);
|
|
986
|
+
const s = t;
|
|
987
|
+
t = ie(t), t = t.replace(
|
|
988
|
+
"$wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);",
|
|
989
|
+
`if (!isset($GLOBALS['wpdb'])) {
|
|
990
|
+
$GLOBALS['wpdb'] = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
|
|
991
|
+
}
|
|
992
|
+
$wpdb = $GLOBALS['wpdb']; /* pg_wp07_preserve_sqlite_loader */`
|
|
993
|
+
), t !== s && await e.writeFile(i, t);
|
|
994
|
+
}
|
|
995
|
+
function ie(e) {
|
|
996
|
+
const n = [];
|
|
997
|
+
if (e.includes("function set_prefix") || n.push(`
|
|
998
|
+
function set_prefix($prefix) {
|
|
999
|
+
$this->prefix = $prefix;
|
|
1000
|
+
$tables = array('posts', 'users', 'categories', 'comments', 'links', 'linkcategories', 'settings', 'options', 'postmeta', 'usermeta', 'terms', 'term_taxonomy', 'term_relationships');
|
|
1001
|
+
foreach ($tables as $table) {
|
|
1002
|
+
$this->$table = $prefix . $table;
|
|
1003
|
+
}
|
|
1004
|
+
return $prefix;
|
|
1005
|
+
}`), e.includes("function timer_start") || n.push(`
|
|
1006
|
+
function timer_start() {
|
|
1007
|
+
$this->time_start = microtime(true);
|
|
1008
|
+
return true;
|
|
1009
|
+
}`), e.includes("function timer_stop") || n.push(`
|
|
1010
|
+
function timer_stop() {
|
|
1011
|
+
return microtime(true) - $this->time_start;
|
|
1012
|
+
}`), e.includes("function init_charset") || n.push(`
|
|
1013
|
+
function init_charset() {
|
|
1014
|
+
if (defined('DB_CHARSET')) $this->charset = DB_CHARSET;
|
|
1015
|
+
if (defined('DB_COLLATE')) $this->collate = DB_COLLATE;
|
|
1016
|
+
}`), e.includes("function bail") || n.push(`
|
|
1017
|
+
function bail($message, $error_code = '500') {
|
|
1018
|
+
die($message);
|
|
1019
|
+
}`), e.includes("function check_connection") || n.push(`
|
|
1020
|
+
function check_connection($allow_bail = true) {
|
|
1021
|
+
return true;
|
|
1022
|
+
}`), n.length === 0) return e;
|
|
1023
|
+
const i = e.match(
|
|
1024
|
+
/^(\s*})\s*\n+(\$wpdb|if\s*\(\s*!\s*isset\(\s*\$GLOBALS\['wpdb'\]\s*\))/m
|
|
1025
|
+
);
|
|
1026
|
+
if (!i || i.index === void 0)
|
|
1027
|
+
throw new Error(
|
|
1028
|
+
"WP 0.7 wpdb polyfill anchor not found; b2-include/wp-db.php layout changed"
|
|
1029
|
+
);
|
|
1030
|
+
const t = `
|
|
1031
|
+
// Polyfills added by WordPress Playground for WP 0.7.
|
|
1032
|
+
` + n.join(`
|
|
1033
|
+
`) + `
|
|
1034
|
+
|
|
1035
|
+
`;
|
|
1036
|
+
return e.substring(0, i.index) + t + e.substring(i.index);
|
|
1037
|
+
}
|
|
1038
|
+
async function se(e, n) {
|
|
1039
|
+
const i = a(
|
|
1040
|
+
n,
|
|
1041
|
+
"b2-include/b2template.functions.php"
|
|
1042
|
+
);
|
|
1043
|
+
let t = e.readFileAsText(i);
|
|
1044
|
+
const s = t;
|
|
1045
|
+
t.includes("pg_wp07_apply_filters") || (t = t.replace(
|
|
1046
|
+
`function apply_filters($tag, $string) {
|
|
1047
|
+
global $b2_filter;
|
|
1048
|
+
if (isset($b2_filter['all'])) {
|
|
1049
|
+
$b2_filter['all'] = (is_string($b2_filter['all'])) ? array($b2_filter['all']) : $b2_filter['all'];
|
|
1050
|
+
$b2_filter[$tag] = array_merge($b2_filter['all'], $b2_filter[$tag]);
|
|
1051
|
+
$b2_filter[$tag] = array_unique($b2_filter[$tag]);
|
|
1052
|
+
}
|
|
1053
|
+
if (isset($b2_filter[$tag])) {
|
|
1054
|
+
$b2_filter[$tags] = (is_string($b2_filter[$tag])) ? array($b2_filter[$tag]) : $b2_filter[$tag];
|
|
1055
|
+
$functions = $b2_filter[$tag];
|
|
1056
|
+
foreach($functions as $function) {
|
|
1057
|
+
$string = $function($string);
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
return $string;
|
|
1061
|
+
}`,
|
|
1062
|
+
`function apply_filters($tag, $string) { /* pg_wp07_apply_filters */
|
|
1063
|
+
global $b2_filter;
|
|
1064
|
+
$functions = array();
|
|
1065
|
+
// WP_SQLite_DB uses apply_filters('query'); b2's all filter texturizes SQL.
|
|
1066
|
+
if ($tag != 'query' && isset($b2_filter['all'])) {
|
|
1067
|
+
$all = is_array($b2_filter['all']) ? $b2_filter['all'] : array($b2_filter['all']);
|
|
1068
|
+
$functions = array_merge($functions, $all);
|
|
1069
|
+
}
|
|
1070
|
+
if (isset($b2_filter[$tag])) {
|
|
1071
|
+
$tag_functions = is_array($b2_filter[$tag]) ? $b2_filter[$tag] : array($b2_filter[$tag]);
|
|
1072
|
+
$functions = array_merge($functions, $tag_functions);
|
|
1073
|
+
}
|
|
1074
|
+
$functions = array_unique($functions);
|
|
1075
|
+
foreach($functions as $function) {
|
|
1076
|
+
if (function_exists($function)) {
|
|
1077
|
+
$string = $function($string);
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
return $string;
|
|
1081
|
+
}`
|
|
1082
|
+
), t !== s && await e.writeFile(i, t));
|
|
1083
|
+
}
|
|
1084
|
+
async function re(e, n) {
|
|
1085
|
+
await ae(e, n), await oe(e, n), await _e(e, n), await le(e, n);
|
|
1086
|
+
}
|
|
1087
|
+
async function ae(e, n) {
|
|
1088
|
+
const i = a(n, "b2login.php");
|
|
1089
|
+
let t = e.readFileAsText(i);
|
|
1090
|
+
const s = t;
|
|
1091
|
+
t.includes("pg_wp07_login_auto_login") || (t = t.replace(
|
|
1092
|
+
"switch($action) {",
|
|
1093
|
+
`${x("pg_wp07_login_auto_login")}
|
|
1094
|
+
switch($action) {`
|
|
1095
|
+
)), t.includes("pg_wp07_logout_guard") || (t = t.replace(
|
|
1096
|
+
` setcookie('wordpressuser');
|
|
1097
|
+
setcookie('wordpresspass');`,
|
|
1098
|
+
` setcookie('wordpressuser', '', time() - 31536000);
|
|
1099
|
+
setcookie('wordpresspass', '', time() - 31536000);
|
|
1100
|
+
setcookie('wordpressblogid', '', time() - 31536000);
|
|
1101
|
+
setcookie('wordpressuser', '', time() - 31536000, '/');
|
|
1102
|
+
setcookie('wordpresspass', '', time() - 31536000, '/');
|
|
1103
|
+
setcookie('wordpressblogid', '', time() - 31536000, '/');
|
|
1104
|
+
setcookie('playground_auto_login_already_logged_out', '1', time() + 172800, '/'); /* pg_wp07_logout_guard */`
|
|
1105
|
+
), t = t.replace(
|
|
1106
|
+
"header('Refresh: 0;url=b2login.php');",
|
|
1107
|
+
"header('Refresh: 0;url=b2login.php?loggedout=1');"
|
|
1108
|
+
).replace(
|
|
1109
|
+
"header('Location: b2login.php');",
|
|
1110
|
+
"header('Location: b2login.php?loggedout=1');"
|
|
1111
|
+
)), t !== s && await e.writeFile(i, t);
|
|
1112
|
+
}
|
|
1113
|
+
async function oe(e, n) {
|
|
1114
|
+
const i = a(n, "wp-admin");
|
|
1115
|
+
if (e.isDir(i))
|
|
1116
|
+
for (const t of e.listFiles(i)) {
|
|
1117
|
+
if (!t.endsWith(".php")) continue;
|
|
1118
|
+
const s = a(i, t), r = e.readFileAsText(s), o = I(r);
|
|
1119
|
+
o !== r && await e.writeFile(s, o);
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
async function _e(e, n) {
|
|
1123
|
+
const i = a(n, "wp-admin/b2menutop.php");
|
|
1124
|
+
let t = e.readFileAsText(i);
|
|
1125
|
+
const s = t;
|
|
1126
|
+
t = t.replace(
|
|
1127
|
+
'file("./b2menutop.txt")',
|
|
1128
|
+
"file(dirname(__FILE__) . '/b2menutop.txt')"
|
|
1129
|
+
).replace(
|
|
1130
|
+
'<a href="http://wordpress.org" rel="external"><span>WordPress</span></a>',
|
|
1131
|
+
'<a href="#" rel="external"><span>WordPress</span></a>'
|
|
1132
|
+
), t !== s && await e.writeFile(i, t);
|
|
1133
|
+
}
|
|
1134
|
+
async function le(e, n) {
|
|
1135
|
+
const i = a(n, "wp-admin/b2verifauth.php");
|
|
1136
|
+
let t = e.readFileAsText(i);
|
|
1137
|
+
const s = t;
|
|
1138
|
+
t.includes("pg_wp07_auto_login") || (t = t.replace(
|
|
1139
|
+
"require_once('../b2config.php');",
|
|
1140
|
+
`require_once('../b2config.php');
|
|
1141
|
+
${x("pg_wp07_auto_login")}`
|
|
1142
|
+
), t !== s && await e.writeFile(i, t));
|
|
1143
|
+
}
|
|
1144
|
+
function x(e) {
|
|
1145
|
+
return `
|
|
1146
|
+
if (isset($_GET['loggedout']) || isset($HTTP_GET_VARS['loggedout'])) {
|
|
1147
|
+
$_COOKIE['playground_auto_login_already_logged_out'] = '1';
|
|
1148
|
+
unset($_COOKIE['wordpressuser']);
|
|
1149
|
+
unset($_COOKIE['wordpresspass']);
|
|
1150
|
+
unset($_COOKIE['wordpressblogid']);
|
|
1151
|
+
unset($HTTP_COOKIE_VARS['wordpressuser']);
|
|
1152
|
+
unset($HTTP_COOKIE_VARS['wordpresspass']);
|
|
1153
|
+
unset($HTTP_COOKIE_VARS['wordpressblogid']);
|
|
1154
|
+
if (!headers_sent()) {
|
|
1155
|
+
setcookie('playground_auto_login_already_logged_out', '1', time() + 172800, '/');
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
if (
|
|
1159
|
+
defined('PLAYGROUND_AUTO_LOGIN_AS_USER') &&
|
|
1160
|
+
empty($_COOKIE['playground_auto_login_already_logged_out']) &&
|
|
1161
|
+
(!isset($action) || $action != 'logout')
|
|
1162
|
+
) {
|
|
1163
|
+
$_pg_wp07_user = PLAYGROUND_AUTO_LOGIN_AS_USER;
|
|
1164
|
+
$_pg_wp07_pass = md5(md5('password'));
|
|
1165
|
+
$_COOKIE['wordpressuser'] = $_pg_wp07_user;
|
|
1166
|
+
$_COOKIE['wordpresspass'] = $_pg_wp07_pass;
|
|
1167
|
+
$_COOKIE['wordpressblogid'] = 1;
|
|
1168
|
+
$HTTP_COOKIE_VARS = $_COOKIE;
|
|
1169
|
+
$GLOBALS['HTTP_COOKIE_VARS'] = $HTTP_COOKIE_VARS;
|
|
1170
|
+
if (!headers_sent()) {
|
|
1171
|
+
$_pg_wp07_exp = time() + 172800;
|
|
1172
|
+
setcookie('wordpressuser', $_pg_wp07_user, $_pg_wp07_exp, '/');
|
|
1173
|
+
setcookie('wordpresspass', $_pg_wp07_pass, $_pg_wp07_exp, '/');
|
|
1174
|
+
setcookie('wordpressblogid', 1, $_pg_wp07_exp, '/');
|
|
1175
|
+
}
|
|
1176
|
+
} /* ${e} */
|
|
1177
|
+
`;
|
|
1178
|
+
}
|
|
1179
|
+
async function ce(e, n) {
|
|
1180
|
+
const i = E(e, n);
|
|
731
1181
|
if (i === null) return;
|
|
732
|
-
const
|
|
733
|
-
if (!Number.isFinite(
|
|
1182
|
+
const t = parseFloat(i);
|
|
1183
|
+
if (!Number.isFinite(t) || t < 5 || t >= 6.2)
|
|
734
1184
|
return;
|
|
735
|
-
const s =
|
|
1185
|
+
const s = a(n, "wp-includes/load.php");
|
|
736
1186
|
if (!e.fileExists(s)) return;
|
|
737
|
-
const r = e.readFileAsText(s),
|
|
1187
|
+
const r = e.readFileAsText(s), o = r.replace(
|
|
738
1188
|
"extension_loaded( 'mysqli' )",
|
|
739
1189
|
"function_exists( 'mysqli_connect' )"
|
|
740
1190
|
);
|
|
741
|
-
|
|
1191
|
+
o !== r && await e.writeFile(s, o);
|
|
742
1192
|
}
|
|
743
|
-
function
|
|
744
|
-
const i =
|
|
1193
|
+
function E(e, n) {
|
|
1194
|
+
const i = a(n, "wp-includes/version.php");
|
|
745
1195
|
if (!e.fileExists(i)) return null;
|
|
746
1196
|
const s = e.readFileAsText(i).match(/\$wp_version\s*=\s*['"]([^'"]+)['"]/);
|
|
747
1197
|
return s ? s[1] : null;
|
|
748
1198
|
}
|
|
749
|
-
const
|
|
750
|
-
async function
|
|
751
|
-
|
|
752
|
-
|
|
1199
|
+
const ue = 22527, w = "E_ALL & ~8192 & ~2048";
|
|
1200
|
+
async function pe(e, n) {
|
|
1201
|
+
if (await j(e, n)) return;
|
|
1202
|
+
await Le(e, n), await Oe(e, n), await be(e, n), await Ue(e, n), await Se(e, n), await We(e, n), await Re(e, n), await Fe(e, n), await he(e, n), await $e(e, n);
|
|
1203
|
+
const i = E(e, n);
|
|
753
1204
|
if (i === null) return;
|
|
754
|
-
const
|
|
755
|
-
Number.isFinite(
|
|
1205
|
+
const t = parseFloat(i);
|
|
1206
|
+
Number.isFinite(t) && (t < 1.2 && (await ye(e, n), await we(e, n)), t < 1.5 && await ge(e, n), 1.5 <= t && t < 2 && await ve(e, n), t < 2 && (await me(e, n), await Pe(e, n)), 2.1 <= t && t < 2.3 && await Ee(e, n), t < 2.5 && await xe(e, n), t < 2.8 && (await Ce(e, n), await qe(e, n)), 2.9 <= t && t < 3.6 && await fe(e, n), 3.3 <= t && t < 3.4 && await Te(e, n), t >= 4.7 && await de(e, n));
|
|
756
1207
|
}
|
|
757
|
-
async function
|
|
758
|
-
const i =
|
|
1208
|
+
async function de(e, n) {
|
|
1209
|
+
const i = a(n, "wp-content/themes");
|
|
759
1210
|
if (e.isDir(i))
|
|
760
|
-
for (const
|
|
761
|
-
const s =
|
|
1211
|
+
for (const t of e.listFiles(i)) {
|
|
1212
|
+
const s = a(i, t, "searchform.php");
|
|
762
1213
|
e.fileExists(s) && e.unlink(s);
|
|
763
1214
|
}
|
|
764
1215
|
}
|
|
765
|
-
async function
|
|
766
|
-
const i =
|
|
1216
|
+
async function fe(e, n) {
|
|
1217
|
+
const i = a(n, "wp-admin/includes/dashboard.php");
|
|
767
1218
|
if (e.fileExists(i)) {
|
|
768
1219
|
let r = e.readFileAsText(i);
|
|
769
1220
|
if (r.includes("function wp_dashboard_primary()") && !r.includes("/* pg_no_rss */")) {
|
|
770
|
-
for (const
|
|
1221
|
+
for (const o of [
|
|
771
1222
|
"wp_dashboard_primary",
|
|
772
1223
|
"wp_dashboard_secondary",
|
|
773
1224
|
"wp_dashboard_plugins"
|
|
774
1225
|
])
|
|
775
1226
|
r = r.replace(
|
|
776
|
-
new RegExp(`function ${
|
|
777
|
-
`function ${
|
|
1227
|
+
new RegExp(`function ${o}\\(\\)\\s*\\{`),
|
|
1228
|
+
`function ${o}() { /* pg_no_rss */ return;`
|
|
778
1229
|
);
|
|
779
1230
|
await e.writeFile(i, r);
|
|
780
1231
|
}
|
|
781
1232
|
}
|
|
782
|
-
const
|
|
783
|
-
if (e.fileExists(
|
|
784
|
-
let r = e.readFileAsText(
|
|
1233
|
+
const t = a(n, "wp-admin/admin.php");
|
|
1234
|
+
if (e.fileExists(t)) {
|
|
1235
|
+
let r = e.readFileAsText(t);
|
|
785
1236
|
r.includes("do_action('admin_init');") && !r.includes("/* pg_admin_init_cleanup */") && (r = r.replace(
|
|
786
1237
|
"do_action('admin_init');",
|
|
787
1238
|
`/* pg_admin_init_cleanup */
|
|
@@ -794,16 +1245,16 @@ if (function_exists('remove_action')) {
|
|
|
794
1245
|
@remove_action('admin_init', 'wp_update_themes');
|
|
795
1246
|
}
|
|
796
1247
|
do_action('admin_init');`
|
|
797
|
-
), await e.writeFile(
|
|
1248
|
+
), await e.writeFile(t, r));
|
|
798
1249
|
}
|
|
799
|
-
const s =
|
|
800
|
-
|
|
1250
|
+
const s = a(
|
|
1251
|
+
n,
|
|
801
1252
|
"wp-admin/includes/update.php"
|
|
802
1253
|
);
|
|
803
1254
|
if (e.fileExists(s)) {
|
|
804
1255
|
let r = e.readFileAsText(s);
|
|
805
1256
|
if (!r.includes("/* pg_admin_no_updates */")) {
|
|
806
|
-
for (const
|
|
1257
|
+
for (const o of [
|
|
807
1258
|
"wp_plugin_update_rows",
|
|
808
1259
|
"wp_plugin_update_row",
|
|
809
1260
|
"wp_theme_update_rows",
|
|
@@ -811,11 +1262,11 @@ do_action('admin_init');`
|
|
|
811
1262
|
"wp_update_plugins",
|
|
812
1263
|
"wp_update_themes"
|
|
813
1264
|
]) {
|
|
814
|
-
const
|
|
815
|
-
`function ${
|
|
1265
|
+
const _ = new RegExp(
|
|
1266
|
+
`function ${o}\\s*\\([^)]*\\)\\s*\\{`
|
|
816
1267
|
);
|
|
817
|
-
|
|
818
|
-
|
|
1268
|
+
_.test(r) && (r = r.replace(
|
|
1269
|
+
_,
|
|
819
1270
|
(l) => l + " /* pg_admin_no_updates */ return;"
|
|
820
1271
|
));
|
|
821
1272
|
}
|
|
@@ -823,177 +1274,177 @@ do_action('admin_init');`
|
|
|
823
1274
|
}
|
|
824
1275
|
}
|
|
825
1276
|
for (const r of [
|
|
826
|
-
|
|
827
|
-
|
|
1277
|
+
a(n, "wp-includes/SimplePie/File.php"),
|
|
1278
|
+
a(n, "wp-includes/class-simplepie.php")
|
|
828
1279
|
]) {
|
|
829
1280
|
if (!e.fileExists(r)) continue;
|
|
830
|
-
let
|
|
831
|
-
|
|
1281
|
+
let o = e.readFileAsText(r);
|
|
1282
|
+
o.includes("function SimplePie_File(") && !o.includes("/* pg_no_fetch */") && (o = o.replace(
|
|
832
1283
|
/function SimplePie_File\([^)]*\)\s*\{/,
|
|
833
|
-
(
|
|
1284
|
+
(_) => _ + `
|
|
834
1285
|
/* pg_no_fetch */
|
|
835
1286
|
$this->error = 'Network requests disabled in Playground';
|
|
836
1287
|
$this->success = false;
|
|
837
1288
|
return;`
|
|
838
|
-
), await e.writeFile(r,
|
|
1289
|
+
), await e.writeFile(r, o));
|
|
839
1290
|
}
|
|
840
1291
|
}
|
|
841
|
-
async function
|
|
1292
|
+
async function $e(e, n) {
|
|
842
1293
|
const i = [
|
|
843
1294
|
["function wp_new_blog_notification", "pg_no_blog_notification"],
|
|
844
1295
|
[
|
|
845
1296
|
"function wp_install_maybe_enable_pretty_permalinks",
|
|
846
1297
|
"pg_no_permalink_check"
|
|
847
1298
|
]
|
|
848
|
-
],
|
|
849
|
-
|
|
850
|
-
|
|
1299
|
+
], t = [
|
|
1300
|
+
a(n, "wp-admin/includes/upgrade.php"),
|
|
1301
|
+
a(n, "wp-admin/upgrade-functions.php")
|
|
851
1302
|
];
|
|
852
|
-
for (const s of
|
|
1303
|
+
for (const s of t) {
|
|
853
1304
|
if (!e.fileExists(s)) continue;
|
|
854
|
-
let r = e.readFileAsText(s),
|
|
855
|
-
for (const [
|
|
1305
|
+
let r = e.readFileAsText(s), o = !1;
|
|
1306
|
+
for (const [_, l] of i) {
|
|
856
1307
|
if (r.includes(`/* ${l} */`)) continue;
|
|
857
|
-
const c = r.indexOf(
|
|
1308
|
+
const c = r.indexOf(_);
|
|
858
1309
|
if (c === -1) continue;
|
|
859
1310
|
const u = r.indexOf("{", c);
|
|
860
|
-
u !== -1 && (r = r.substring(0, u + 1) + ` /* ${l} */ return;` + r.substring(u + 1),
|
|
1311
|
+
u !== -1 && (r = r.substring(0, u + 1) + ` /* ${l} */ return;` + r.substring(u + 1), o = !0);
|
|
861
1312
|
}
|
|
862
|
-
|
|
1313
|
+
o && await e.writeFile(s, r);
|
|
863
1314
|
}
|
|
864
1315
|
}
|
|
865
|
-
async function
|
|
866
|
-
const i =
|
|
1316
|
+
async function he(e, n) {
|
|
1317
|
+
const i = a(n, "wp-load.php");
|
|
867
1318
|
if (!e.fileExists(i)) return;
|
|
868
|
-
const
|
|
869
|
-
if (!
|
|
870
|
-
const s =
|
|
1319
|
+
const t = e.readFileAsText(i);
|
|
1320
|
+
if (!t.includes("error_reporting(") || t.includes("~8192") && t.includes("~2048")) return;
|
|
1321
|
+
const s = t.replace(
|
|
871
1322
|
/error_reporting\(([^)]+)\)/g,
|
|
872
|
-
(r,
|
|
1323
|
+
(r, o) => `error_reporting((${o}) & ~8192 & ~2048)`
|
|
873
1324
|
);
|
|
874
1325
|
await e.writeFile(i, s);
|
|
875
1326
|
}
|
|
876
|
-
async function
|
|
877
|
-
const i =
|
|
1327
|
+
async function ge(e, n) {
|
|
1328
|
+
const i = a(n, "wp-admin/menu.php");
|
|
878
1329
|
if (e.fileExists(i)) {
|
|
879
1330
|
const r = e.readFileAsText(i);
|
|
880
1331
|
if (!r.includes("/* pg_wp10_logo_link */")) {
|
|
881
|
-
const
|
|
882
|
-
if (r.includes(
|
|
883
|
-
const
|
|
884
|
-
|
|
1332
|
+
const o = '<h1 id="wphead"><a href="http://wordpress.org" rel="external">WordPress</a></h1>';
|
|
1333
|
+
if (r.includes(o)) {
|
|
1334
|
+
const _ = r.replace(
|
|
1335
|
+
o,
|
|
885
1336
|
'<h1 id="wphead"><a href="#" rel="external">WordPress</a></h1> <!-- pg_wp10_logo_link -->'
|
|
886
1337
|
);
|
|
887
|
-
|
|
1338
|
+
_ !== r && await e.writeFile(i, _);
|
|
888
1339
|
}
|
|
889
1340
|
}
|
|
890
1341
|
}
|
|
891
|
-
const
|
|
892
|
-
|
|
1342
|
+
const t = a(
|
|
1343
|
+
n,
|
|
893
1344
|
"wp-admin/admin-header.php"
|
|
894
1345
|
);
|
|
895
|
-
if (e.fileExists(
|
|
896
|
-
const r = e.readFileAsText(
|
|
1346
|
+
if (e.fileExists(t)) {
|
|
1347
|
+
const r = e.readFileAsText(t);
|
|
897
1348
|
if (!r.includes("/* pg_wp12_logo_link */")) {
|
|
898
|
-
const
|
|
1349
|
+
const o = '<a href="http://wordpress.org" rel="external"', _ = "</a>", l = r.indexOf(o);
|
|
899
1350
|
if (l !== -1) {
|
|
900
|
-
const c = r.indexOf(
|
|
1351
|
+
const c = r.indexOf(_, l);
|
|
901
1352
|
if (c !== -1) {
|
|
902
|
-
const u = r.substring(0, l) + '<a href="#">WordPress</a><!-- pg_wp12_logo_link -->' + r.substring(c +
|
|
903
|
-
u !== r && await e.writeFile(
|
|
1353
|
+
const u = r.substring(0, l) + '<a href="#">WordPress</a><!-- pg_wp12_logo_link -->' + r.substring(c + _.length);
|
|
1354
|
+
u !== r && await e.writeFile(t, u);
|
|
904
1355
|
}
|
|
905
1356
|
}
|
|
906
1357
|
}
|
|
907
1358
|
}
|
|
908
|
-
const s =
|
|
909
|
-
|
|
1359
|
+
const s = a(
|
|
1360
|
+
n,
|
|
910
1361
|
"wp-admin/admin-footer.php"
|
|
911
1362
|
);
|
|
912
1363
|
if (e.fileExists(s)) {
|
|
913
1364
|
const r = e.readFileAsText(s);
|
|
914
1365
|
if (!r.includes("/* pg_wp10_footer_link */")) {
|
|
915
|
-
const
|
|
1366
|
+
const o = r.replace(
|
|
916
1367
|
'<a href="http://wordpress.org">WordPress</a>',
|
|
917
1368
|
"WordPress<!-- pg_wp10_footer_link -->"
|
|
918
1369
|
).replace(
|
|
919
1370
|
'<a href="http://wordpress.org/">WordPress</a>',
|
|
920
1371
|
"WordPress<!-- pg_wp10_footer_link -->"
|
|
921
1372
|
);
|
|
922
|
-
|
|
1373
|
+
o !== r && await e.writeFile(s, o);
|
|
923
1374
|
}
|
|
924
1375
|
}
|
|
925
1376
|
}
|
|
926
|
-
async function
|
|
927
|
-
const i =
|
|
1377
|
+
async function me(e, n) {
|
|
1378
|
+
const i = a(n, "wp-admin/edit.php");
|
|
928
1379
|
if (!e.fileExists(i)) return;
|
|
929
|
-
const
|
|
930
|
-
if (
|
|
931
|
-
let s =
|
|
1380
|
+
const t = e.readFileAsText(i);
|
|
1381
|
+
if (t.includes("/* pg_wp10_post_title_edit */")) return;
|
|
1382
|
+
let s = t;
|
|
932
1383
|
const r = '<strong><a href="<?php permalink_link(); ?>" rel="permalink"><?php the_title() ?></a></strong>';
|
|
933
1384
|
s.includes(r) && (s = s.replace(
|
|
934
1385
|
r,
|
|
935
1386
|
'<strong><a href="post.php?action=edit&post=<?php echo $id /* pg_wp10_post_title_edit */ ?>"><?php the_title() ?></a></strong>'
|
|
936
1387
|
));
|
|
937
|
-
const
|
|
938
|
-
s.includes(
|
|
939
|
-
|
|
1388
|
+
const o = '<td><a href="<?php the_permalink(); ?>" rel="permalink">';
|
|
1389
|
+
s.includes(o) && (s = s.replace(
|
|
1390
|
+
o,
|
|
940
1391
|
'<td><a href="post.php?action=edit&post=<?php echo $id /* pg_wp10_post_title_edit */ ?>">'
|
|
941
1392
|
));
|
|
942
|
-
const
|
|
1393
|
+
const _ = `<td><?php the_title() ?>
|
|
943
1394
|
<?php if ('private' == $post->post_status) _e(' - <strong>Private</strong>'); ?></td>`;
|
|
944
|
-
s.includes(
|
|
945
|
-
|
|
1395
|
+
s.includes(_) && (s = s.replace(
|
|
1396
|
+
_,
|
|
946
1397
|
`<td><a href="post.php?action=edit&post=<?php echo $id /* pg_wp10_post_title_edit */ ?>"><?php the_title() ?></a>
|
|
947
1398
|
<?php if ('private' == $post->post_status) _e(' - <strong>Private</strong>'); ?></td>`
|
|
948
|
-
)), s !==
|
|
1399
|
+
)), s !== t && await e.writeFile(i, s);
|
|
949
1400
|
}
|
|
950
|
-
async function
|
|
951
|
-
const i =
|
|
1401
|
+
async function Te(e, n) {
|
|
1402
|
+
const i = a(n, "wp-admin/includes/screen.php");
|
|
952
1403
|
if (!e.fileExists(i)) return;
|
|
953
|
-
const
|
|
954
|
-
if (!
|
|
955
|
-
const s =
|
|
1404
|
+
const t = e.readFileAsText(i);
|
|
1405
|
+
if (!t.includes("self::$this->_help_sidebar")) return;
|
|
1406
|
+
const s = t.replace(
|
|
956
1407
|
/self::\$this->_help_sidebar/g,
|
|
957
1408
|
"$this->_help_sidebar"
|
|
958
1409
|
);
|
|
959
|
-
s !==
|
|
1410
|
+
s !== t && await e.writeFile(i, s);
|
|
960
1411
|
}
|
|
961
|
-
async function
|
|
962
|
-
const i =
|
|
1412
|
+
async function Ee(e, n) {
|
|
1413
|
+
const i = a(n, "wp-admin/plugins.php");
|
|
963
1414
|
if (!e.fileExists(i)) return;
|
|
964
|
-
const
|
|
965
|
-
if (
|
|
1415
|
+
const t = e.readFileAsText(i);
|
|
1416
|
+
if (t.includes("/* pg_wp21_active_plugins_array */")) return;
|
|
966
1417
|
const s = "$current = get_option('active_plugins');";
|
|
967
|
-
if (!
|
|
968
|
-
const r =
|
|
1418
|
+
if (!t.includes(s)) return;
|
|
1419
|
+
const r = t.replace(
|
|
969
1420
|
s,
|
|
970
1421
|
s + `
|
|
971
1422
|
if (!is_array($current)) $current = array(); /* pg_wp21_active_plugins_array */`
|
|
972
1423
|
);
|
|
973
|
-
r !==
|
|
1424
|
+
r !== t && await e.writeFile(i, r);
|
|
974
1425
|
}
|
|
975
|
-
async function
|
|
976
|
-
const i =
|
|
1426
|
+
async function we(e, n) {
|
|
1427
|
+
const i = a(n, "wp-login.php");
|
|
977
1428
|
if (!e.fileExists(i)) return;
|
|
978
|
-
const
|
|
979
|
-
if (!
|
|
980
|
-
let r =
|
|
1429
|
+
const t = e.readFileAsText(i), s = "AND user_pass = '$password'";
|
|
1430
|
+
if (!t.includes(s) || t.includes("pg_wp10_plain_or_md5")) return;
|
|
1431
|
+
let r = t.replace(
|
|
981
1432
|
s,
|
|
982
1433
|
"AND (user_pass = '$password' OR user_pass = MD5('$password')) /* pg_wp10_plain_or_md5 */"
|
|
983
1434
|
);
|
|
984
1435
|
r = r.replace(
|
|
985
1436
|
"$login->user_pass == $password",
|
|
986
1437
|
"($login->user_pass == $password || $login->user_pass == md5($password))"
|
|
987
|
-
), r !==
|
|
1438
|
+
), r !== t && await e.writeFile(i, r);
|
|
988
1439
|
}
|
|
989
|
-
async function
|
|
990
|
-
const i =
|
|
1440
|
+
async function Le(e, n) {
|
|
1441
|
+
const i = a(n, "wp-includes");
|
|
991
1442
|
if (!e.isDir(i)) return;
|
|
992
|
-
const
|
|
993
|
-
e.fileExists(
|
|
1443
|
+
const t = a(i, "version.php");
|
|
1444
|
+
e.fileExists(t) || await e.writeFile(t, "<?php $wp_version = '1.0';");
|
|
994
1445
|
}
|
|
995
|
-
async function
|
|
996
|
-
const i =
|
|
1446
|
+
async function ye(e, n) {
|
|
1447
|
+
const i = a(n, "wp-blog-header.php");
|
|
997
1448
|
if (e.fileExists(i)) {
|
|
998
1449
|
const s = e.readFileAsText(i), r = `$where .= ' AND (post_status = "publish"';`;
|
|
999
1450
|
s.includes(r) && await e.writeFile(
|
|
@@ -1004,11 +1455,11 @@ async function re(e, t) {
|
|
|
1004
1455
|
)
|
|
1005
1456
|
);
|
|
1006
1457
|
}
|
|
1007
|
-
const
|
|
1008
|
-
if (e.fileExists(
|
|
1009
|
-
const s = e.readFileAsText(
|
|
1458
|
+
const t = a(n, "wp-includes/vars.php");
|
|
1459
|
+
if (e.fileExists(t)) {
|
|
1460
|
+
const s = e.readFileAsText(t), r = "add_filter('all', 'wptexturize');";
|
|
1010
1461
|
s.includes(r) && await e.writeFile(
|
|
1011
|
-
|
|
1462
|
+
t,
|
|
1012
1463
|
s.replace(
|
|
1013
1464
|
r,
|
|
1014
1465
|
`// ${r} // Disabled by Playground: mangles SQL literals.`
|
|
@@ -1016,8 +1467,8 @@ async function re(e, t) {
|
|
|
1016
1467
|
);
|
|
1017
1468
|
}
|
|
1018
1469
|
}
|
|
1019
|
-
async function
|
|
1020
|
-
const i =
|
|
1470
|
+
async function Oe(e, n) {
|
|
1471
|
+
const i = a(n, "wp-load.php");
|
|
1021
1472
|
e.fileExists(i) || await e.writeFile(
|
|
1022
1473
|
i,
|
|
1023
1474
|
`<?php
|
|
@@ -1028,18 +1479,18 @@ require_once(ABSPATH . 'wp-config.php');
|
|
|
1028
1479
|
`
|
|
1029
1480
|
);
|
|
1030
1481
|
}
|
|
1031
|
-
async function
|
|
1032
|
-
const i =
|
|
1482
|
+
async function be(e, n) {
|
|
1483
|
+
const i = a(n, "wp-settings.php");
|
|
1033
1484
|
if (!e.fileExists(i)) return;
|
|
1034
|
-
const
|
|
1035
|
-
let s =
|
|
1485
|
+
const t = e.readFileAsText(i);
|
|
1486
|
+
let s = t;
|
|
1036
1487
|
s = s.replace(
|
|
1037
1488
|
/if\s*\(\s*!extension_loaded\('mysql'\)\s*\)\s*\n\s*die/,
|
|
1038
1489
|
`if ( false ) // Patched for SQLite
|
|
1039
1490
|
die`
|
|
1040
1491
|
), s = s.replace(
|
|
1041
1492
|
/error_reporting\(([^)]+)\)/g,
|
|
1042
|
-
(r,
|
|
1493
|
+
(r, o) => o.includes("~8192") && o.includes("~2048") ? r : `error_reporting((${o}) & ~8192 & ~2048)`
|
|
1043
1494
|
), s = s.replace(
|
|
1044
1495
|
/set_magic_quotes_runtime\(\s*0\s*\)\s*;/g,
|
|
1045
1496
|
"// set_magic_quotes_runtime(0); // Removed"
|
|
@@ -1050,23 +1501,23 @@ async function oe(e, t) {
|
|
|
1050
1501
|
/define\('WPINC',\s*'wp-includes'\);/,
|
|
1051
1502
|
`define('WPINC', 'wp-includes');
|
|
1052
1503
|
if (!defined('WP_CONTENT_DIR')) define('WP_CONTENT_DIR', ABSPATH . 'wp-content');`
|
|
1053
|
-
)), s = s.replace(/unset\(\s*\$wp_filter\s*,/, "unset("), s =
|
|
1504
|
+
)), s = s.replace(/unset\(\s*\$wp_filter\s*,/, "unset("), s = Ne(s), s = Ae(s), s !== t && await e.writeFile(i, s);
|
|
1054
1505
|
}
|
|
1055
|
-
function
|
|
1056
|
-
const
|
|
1057
|
-
if (
|
|
1058
|
-
const i = e.lastIndexOf("die(",
|
|
1506
|
+
function Ne(e) {
|
|
1507
|
+
const n = e.indexOf("installed WP");
|
|
1508
|
+
if (n === -1) return e;
|
|
1509
|
+
const i = e.lastIndexOf("die(", n);
|
|
1059
1510
|
if (i === -1) return e;
|
|
1060
|
-
let
|
|
1511
|
+
let t = 0;
|
|
1061
1512
|
for (let s = i + 3; s < e.length; s++)
|
|
1062
|
-
if (e[s] === "(")
|
|
1063
|
-
else if (e[s] === ")" && (
|
|
1513
|
+
if (e[s] === "(") t++;
|
|
1514
|
+
else if (e[s] === ")" && (t--, t === 0)) {
|
|
1064
1515
|
let r = s + 1;
|
|
1065
1516
|
return e[r] === ";" && r++, e.substring(0, i) + "true; /* die removed by Playground */" + e.substring(r);
|
|
1066
1517
|
}
|
|
1067
1518
|
return e;
|
|
1068
1519
|
}
|
|
1069
|
-
function
|
|
1520
|
+
function Ae(e) {
|
|
1070
1521
|
return e.replace(
|
|
1071
1522
|
"do_action('init');",
|
|
1072
1523
|
`// Remove hooks that make outbound HTTP requests (crash WASM).
|
|
@@ -1098,43 +1549,43 @@ if (function_exists('add_filter')) {
|
|
|
1098
1549
|
do_action('init');`
|
|
1099
1550
|
);
|
|
1100
1551
|
}
|
|
1101
|
-
async function
|
|
1102
|
-
const i =
|
|
1103
|
-
|
|
1552
|
+
async function Pe(e, n) {
|
|
1553
|
+
const i = a(
|
|
1554
|
+
n,
|
|
1104
1555
|
"wp-includes/functions.php"
|
|
1105
1556
|
);
|
|
1106
1557
|
if (!e.fileExists(i)) return;
|
|
1107
|
-
let
|
|
1108
|
-
|
|
1558
|
+
let t = e.readFileAsText(i), s = !1;
|
|
1559
|
+
t.includes("$all_options->{$option->option_name}") && !t.includes("$all_options = new stdClass") && (t = t.replace(
|
|
1109
1560
|
"foreach ($options as $option) {",
|
|
1110
1561
|
`$all_options = new stdClass;
|
|
1111
1562
|
foreach ($options as $option) {`
|
|
1112
|
-
), s = !0), s && await e.writeFile(i,
|
|
1563
|
+
), s = !0), s && await e.writeFile(i, t);
|
|
1113
1564
|
}
|
|
1114
|
-
async function
|
|
1115
|
-
const i =
|
|
1565
|
+
async function Ue(e, n) {
|
|
1566
|
+
const i = a(n, "wp-admin/install.php");
|
|
1116
1567
|
if (!e.fileExists(i)) return;
|
|
1117
|
-
const
|
|
1118
|
-
let s =
|
|
1119
|
-
const r =
|
|
1120
|
-
s = s.replace(/'\.\.\/(wp-config\.php)'/g, `'${
|
|
1568
|
+
const t = e.readFileAsText(i);
|
|
1569
|
+
let s = t;
|
|
1570
|
+
const r = a(n, "wp-admin");
|
|
1571
|
+
s = s.replace(/'\.\.\/(wp-config\.php)'/g, `'${n}/$1'`).replace(/'\.\.\/(wp-load\.php)'/g, `'${n}/$1'`).replace(/'\.\/(upgrade-functions\.php)'/g, `'${r}/$1'`).replace(/'(upgrade-functions\.php)'/g, `'${r}/$1'`).replace(/'\.\/(includes\/upgrade\.php)'/g, `'${r}/$1'`).replace(/'\.\.\/(wp-includes\/[^']+)'/g, `'${n}/$1'`), s = s.replace(/\$HTTP_GET_VARS/g, "$_GET").replace(/\$HTTP_POST_VARS/g, "$_POST"), s !== t && await e.writeFile(i, s);
|
|
1121
1572
|
}
|
|
1122
|
-
async function
|
|
1123
|
-
const i =
|
|
1573
|
+
async function Se(e, n) {
|
|
1574
|
+
const i = a(n, "wp-includes/wp-db.php");
|
|
1124
1575
|
if (!e.fileExists(i)) return;
|
|
1125
|
-
const
|
|
1126
|
-
let s =
|
|
1576
|
+
const t = e.readFileAsText(i);
|
|
1577
|
+
let s = t;
|
|
1127
1578
|
s.includes("isset($wpdb)") || (s = s.replace(
|
|
1128
1579
|
"$wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);",
|
|
1129
1580
|
"if ( !isset($wpdb) ) { $wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); }"
|
|
1130
1581
|
)), s.includes("db_connect") || (s = s.replace(
|
|
1131
1582
|
/\$this->dbh\s*=\s*@mysql_connect\(\$dbhost\s*,\s*\$dbuser\s*,\s*\$dbpassword(?:\s*,\s*true)?\);/,
|
|
1132
1583
|
'if (method_exists($this, "db_connect")) { $this->dbname = $dbname; $this->db_connect(); } else { $this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword); }'
|
|
1133
|
-
)), s =
|
|
1584
|
+
)), s = Ie(s), s !== t && await e.writeFile(i, s);
|
|
1134
1585
|
}
|
|
1135
|
-
function
|
|
1136
|
-
const
|
|
1137
|
-
if (e.includes("function set_prefix") ||
|
|
1586
|
+
function Ie(e) {
|
|
1587
|
+
const n = [];
|
|
1588
|
+
if (e.includes("function set_prefix") || n.push(`
|
|
1138
1589
|
function set_prefix($prefix) {
|
|
1139
1590
|
$this->prefix = $prefix;
|
|
1140
1591
|
$tables = array('posts', 'users', 'categories', 'post2cat', 'comments', 'link2cat', 'links', 'options', 'postmeta', 'usermeta', 'terms', 'term_taxonomy', 'term_relationships');
|
|
@@ -1142,134 +1593,106 @@ function pe(e) {
|
|
|
1142
1593
|
$this->$t = $prefix . $t;
|
|
1143
1594
|
}
|
|
1144
1595
|
return $prefix;
|
|
1145
|
-
}`), e.includes("function timer_start") ||
|
|
1596
|
+
}`), e.includes("function timer_start") || n.push(`
|
|
1146
1597
|
function timer_start() {
|
|
1147
1598
|
$this->time_start = microtime(true);
|
|
1148
1599
|
return true;
|
|
1149
|
-
}`), e.includes("function timer_stop") ||
|
|
1600
|
+
}`), e.includes("function timer_stop") || n.push(`
|
|
1150
1601
|
function timer_stop() {
|
|
1151
1602
|
return microtime(true) - $this->time_start;
|
|
1152
|
-
}`), e.includes("function init_charset") ||
|
|
1603
|
+
}`), e.includes("function init_charset") || n.push(`
|
|
1153
1604
|
function init_charset() {
|
|
1154
1605
|
if (defined('DB_CHARSET')) $this->charset = DB_CHARSET;
|
|
1155
1606
|
if (defined('DB_COLLATE')) $this->collate = DB_COLLATE;
|
|
1156
|
-
}`), e.includes("function bail") ||
|
|
1607
|
+
}`), e.includes("function bail") || n.push(`
|
|
1157
1608
|
function bail($message, $error_code = '500') {
|
|
1158
1609
|
die($message);
|
|
1159
|
-
}`), e.includes("function check_connection") ||
|
|
1610
|
+
}`), e.includes("function check_connection") || n.push(`
|
|
1160
1611
|
function check_connection($allow_bail = true) {
|
|
1161
1612
|
return true;
|
|
1162
|
-
}`),
|
|
1613
|
+
}`), n.length === 0) return e;
|
|
1163
1614
|
const i = e.match(
|
|
1164
1615
|
/^(\s*})\s*\n+(\$wpdb|\?>\s*$|if\s*\(\s*!\s*isset\(\s*\$wpdb\s*\))/m
|
|
1165
1616
|
);
|
|
1166
1617
|
if (!i || i.index === void 0) return e;
|
|
1167
|
-
const
|
|
1618
|
+
const t = `
|
|
1168
1619
|
// Polyfills added by WordPress Playground.
|
|
1169
|
-
` +
|
|
1620
|
+
` + n.join(`
|
|
1170
1621
|
`) + `
|
|
1171
1622
|
|
|
1172
1623
|
`;
|
|
1173
|
-
return e.substring(0, i.index) +
|
|
1174
|
-
}
|
|
1175
|
-
async function
|
|
1176
|
-
const i = (
|
|
1177
|
-
|
|
1178
|
-
for (
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
let c = "dirname(__FILE__)";
|
|
1183
|
-
for (let u = 0; u < l; u++)
|
|
1184
|
-
c = `dirname(${c})`;
|
|
1185
|
-
return `${c} . '/${o}'`;
|
|
1186
|
-
}, n = _(t, "wp-admin");
|
|
1187
|
-
if (e.isDir(n))
|
|
1188
|
-
for (const a of e.listFiles(n)) {
|
|
1189
|
-
if (!a.endsWith(".php")) continue;
|
|
1190
|
-
const o = _(n, a), l = e.readFileAsText(o), c = l.replace(
|
|
1191
|
-
/((?:require|include)(?:_once)?)\s*\(\s*(['"])(\.\.\/[^'"]+)\2\s*\)/g,
|
|
1192
|
-
(u, d, f, p) => `${d}(${i(p)})`
|
|
1193
|
-
).replace(
|
|
1194
|
-
/((?:require|include)(?:_once)?)\s*\(\s*(['"])(\.\/[^'"]+)\2\s*\)/g,
|
|
1195
|
-
(u, d, f, p) => `${d}(${i(p)})`
|
|
1196
|
-
).replace(
|
|
1197
|
-
/((?:require|include)(?:_once)?)\s*\(\s*(['"])([a-z][\w-]*\.php)\2\s*\)/g,
|
|
1198
|
-
(u, d, f, p) => `${d}(${i(p)})`
|
|
1199
|
-
).replace(
|
|
1200
|
-
/((?:require|include)(?:_once)?)\s+(['"])(\.\.\/[^'"]+)\2/g,
|
|
1201
|
-
(u, d, f, p) => `${d}(${i(p)})`
|
|
1202
|
-
).replace(
|
|
1203
|
-
/((?:require|include)(?:_once)?)\s+(['"])(\.\/[^'"]+)\2/g,
|
|
1204
|
-
(u, d, f, p) => `${d}(${i(p)})`
|
|
1205
|
-
).replace(
|
|
1206
|
-
/((?:require|include)(?:_once)?)\s+(['"])([a-z][\w-]*\.php)\2/g,
|
|
1207
|
-
(u, d, f, p) => `${d}(${i(p)})`
|
|
1208
|
-
).replace(/ABSPATH\s*\.\s*'\/wp-/g, "ABSPATH . 'wp-");
|
|
1209
|
-
c !== l && await e.writeFile(o, c);
|
|
1624
|
+
return e.substring(0, i.index) + t + e.substring(i.index);
|
|
1625
|
+
}
|
|
1626
|
+
async function Re(e, n) {
|
|
1627
|
+
const i = a(n, "wp-admin");
|
|
1628
|
+
if (e.isDir(i))
|
|
1629
|
+
for (const r of e.listFiles(i)) {
|
|
1630
|
+
if (!r.endsWith(".php")) continue;
|
|
1631
|
+
const o = a(i, r), _ = e.readFileAsText(o), l = I(_).replace(/ABSPATH\s*\.\s*'\/wp-/g, "ABSPATH . 'wp-");
|
|
1632
|
+
l !== _ && await e.writeFile(o, l);
|
|
1210
1633
|
}
|
|
1211
|
-
const
|
|
1212
|
-
if (e.fileExists(
|
|
1213
|
-
let
|
|
1214
|
-
|
|
1634
|
+
const t = a(n, "wp-admin/index.php");
|
|
1635
|
+
if (e.fileExists(t)) {
|
|
1636
|
+
let r = e.readFileAsText(t);
|
|
1637
|
+
r.includes("get_settings('siteurl')") && (r = r.replace(
|
|
1215
1638
|
/get_settings\('siteurl'\)\s*\.\s*'\/wp-admin\//g,
|
|
1216
1639
|
"'"
|
|
1217
|
-
), await e.writeFile(
|
|
1640
|
+
), await e.writeFile(t, r));
|
|
1218
1641
|
}
|
|
1219
|
-
const
|
|
1220
|
-
if (e.fileExists(
|
|
1221
|
-
const
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1642
|
+
const s = a(n, "wp-admin/menu.php");
|
|
1643
|
+
if (e.fileExists(s)) {
|
|
1644
|
+
const r = e.readFileAsText(s), o = "file('./menu.txt')";
|
|
1645
|
+
r.includes(o) && await e.writeFile(
|
|
1646
|
+
s,
|
|
1647
|
+
r.replace(o, "file(dirname(__FILE__) . '/menu.txt')")
|
|
1225
1648
|
);
|
|
1226
1649
|
}
|
|
1227
1650
|
}
|
|
1228
|
-
async function
|
|
1229
|
-
const i =
|
|
1230
|
-
|
|
1651
|
+
async function xe(e, n) {
|
|
1652
|
+
const i = a(
|
|
1653
|
+
n,
|
|
1231
1654
|
"wp-admin/admin-functions.php"
|
|
1232
1655
|
);
|
|
1233
1656
|
if (!e.fileExists(i)) return;
|
|
1234
|
-
const
|
|
1235
|
-
if (!
|
|
1657
|
+
const t = e.readFileAsText(i);
|
|
1658
|
+
if (!t.includes("function check_admin_referer()") || !t.includes("$_SERVER['HTTP_REFERER']"))
|
|
1236
1659
|
return;
|
|
1237
|
-
const s =
|
|
1238
|
-
|
|
1660
|
+
const s = ke(
|
|
1661
|
+
t,
|
|
1239
1662
|
"check_admin_referer",
|
|
1240
1663
|
`
|
|
1241
1664
|
do_action('check_admin_referer', '');
|
|
1242
1665
|
`
|
|
1243
1666
|
);
|
|
1244
|
-
s !==
|
|
1667
|
+
s !== t && await e.writeFile(i, s);
|
|
1245
1668
|
}
|
|
1246
|
-
function
|
|
1247
|
-
const
|
|
1669
|
+
function ke(e, n, i) {
|
|
1670
|
+
const t = `function ${n}()`, s = e.indexOf(t);
|
|
1248
1671
|
if (s === -1) return e;
|
|
1249
|
-
const r = e.indexOf("{", s +
|
|
1672
|
+
const r = e.indexOf("{", s + t.length);
|
|
1250
1673
|
if (r === -1) return e;
|
|
1251
|
-
let
|
|
1252
|
-
for (let
|
|
1253
|
-
const l = e[
|
|
1254
|
-
if (l === "{")
|
|
1255
|
-
else if (l === "}" && (
|
|
1256
|
-
return e.substring(0, r + 1) + i + e.substring(
|
|
1674
|
+
let o = 1;
|
|
1675
|
+
for (let _ = r + 1; _ < e.length; _++) {
|
|
1676
|
+
const l = e[_];
|
|
1677
|
+
if (l === "{") o++;
|
|
1678
|
+
else if (l === "}" && (o--, o === 0))
|
|
1679
|
+
return e.substring(0, r + 1) + i + e.substring(_);
|
|
1257
1680
|
}
|
|
1258
1681
|
return e;
|
|
1259
1682
|
}
|
|
1260
|
-
async function
|
|
1261
|
-
const i =
|
|
1683
|
+
async function ve(e, n) {
|
|
1684
|
+
const i = a(n, "wp-admin/index.php");
|
|
1262
1685
|
if (e.fileExists(i)) {
|
|
1263
|
-
const
|
|
1264
|
-
s !==
|
|
1686
|
+
const t = e.readFileAsText(i), s = t.replace(/AND post_date_gmt < '\$today'/, "");
|
|
1687
|
+
s !== t && await e.writeFile(i, s);
|
|
1265
1688
|
}
|
|
1266
|
-
await
|
|
1689
|
+
await De(e, n);
|
|
1267
1690
|
}
|
|
1268
|
-
async function
|
|
1269
|
-
const i =
|
|
1691
|
+
async function De(e, n) {
|
|
1692
|
+
const i = a(n, "wp-includes/rss-functions.php");
|
|
1270
1693
|
if (!e.fileExists(i)) return;
|
|
1271
|
-
let
|
|
1272
|
-
!/^\s*error\s*\(/m.test(
|
|
1694
|
+
let t = e.readFileAsText(i);
|
|
1695
|
+
!/^\s*error\s*\(/m.test(t) || /^function\s+error\s*\(/m.test(t) || (t = t.replace(
|
|
1273
1696
|
/^(<\?php\s*)/,
|
|
1274
1697
|
`$1
|
|
1275
1698
|
if (!function_exists('error')) {
|
|
@@ -1280,22 +1703,22 @@ if (!function_exists('error')) {
|
|
|
1280
1703
|
}
|
|
1281
1704
|
}
|
|
1282
1705
|
`
|
|
1283
|
-
), await e.writeFile(i,
|
|
1706
|
+
), await e.writeFile(i, t));
|
|
1284
1707
|
}
|
|
1285
|
-
async function
|
|
1286
|
-
const i =
|
|
1708
|
+
async function Fe(e, n) {
|
|
1709
|
+
const i = a(n, "wp-login.php");
|
|
1287
1710
|
if (!e.fileExists(i)) return;
|
|
1288
|
-
let
|
|
1711
|
+
let t = e.readFileAsText(i), s = !1;
|
|
1289
1712
|
for (const r of ["log", "pwd"]) {
|
|
1290
|
-
const
|
|
1713
|
+
const o = new RegExp(
|
|
1291
1714
|
`(\\bname=(['"])${r}\\2)(?![^>]*data-1p-ignore)`
|
|
1292
1715
|
);
|
|
1293
|
-
|
|
1716
|
+
o.test(t) && (t = t.replace(o, "$1 data-1p-ignore"), s = !0);
|
|
1294
1717
|
}
|
|
1295
|
-
s && await e.writeFile(i,
|
|
1718
|
+
s && await e.writeFile(i, t);
|
|
1296
1719
|
}
|
|
1297
|
-
async function
|
|
1298
|
-
const i =
|
|
1720
|
+
async function Ce(e, n) {
|
|
1721
|
+
const i = a(n, "wp-admin/admin.php");
|
|
1299
1722
|
if (e.fileExists(i)) {
|
|
1300
1723
|
const s = e.readFileAsText(i);
|
|
1301
1724
|
if (s.includes("auth_redirect()")) {
|
|
@@ -1314,7 +1737,7 @@ if (defined('PLAYGROUND_AUTO_LOGIN_AS_USER')) {
|
|
|
1314
1737
|
$_COOKIE[LOGGED_IN_COOKIE] = wp_generate_auth_cookie($_pg_uid, $_pg_exp, 'logged_in');
|
|
1315
1738
|
}
|
|
1316
1739
|
} else {
|
|
1317
|
-
${
|
|
1740
|
+
${k("PLAYGROUND_AUTO_LOGIN_AS_USER")}
|
|
1318
1741
|
// WP 2.0-2.4: kses_init() runs during do_action('init') inside
|
|
1319
1742
|
// wp-settings.php and caches $current_user as WP_User(0) when
|
|
1320
1743
|
// no cookies were set yet. Reset and re-evaluate so capability
|
|
@@ -1364,16 +1787,16 @@ if (defined('PLAYGROUND_AUTO_LOGIN_AS_USER')) {
|
|
|
1364
1787
|
}
|
|
1365
1788
|
}
|
|
1366
1789
|
}
|
|
1367
|
-
`,
|
|
1790
|
+
`, o = s.replace(
|
|
1368
1791
|
"auth_redirect();",
|
|
1369
1792
|
r + "auth_redirect();"
|
|
1370
1793
|
);
|
|
1371
|
-
|
|
1794
|
+
o !== s && await e.writeFile(i, o);
|
|
1372
1795
|
}
|
|
1373
1796
|
}
|
|
1374
|
-
const
|
|
1375
|
-
if (e.fileExists(
|
|
1376
|
-
const s = e.readFileAsText(
|
|
1797
|
+
const t = a(n, "wp-admin/auth.php");
|
|
1798
|
+
if (e.fileExists(t)) {
|
|
1799
|
+
const s = e.readFileAsText(t);
|
|
1377
1800
|
if (s.includes("$cookiehash") && !s.includes("Playground: bypass auth")) {
|
|
1378
1801
|
const r = `<?php
|
|
1379
1802
|
require_once(ABSPATH . 'wp-config.php');
|
|
@@ -1415,27 +1838,27 @@ if (function_exists('get_userdatabylogin')) {
|
|
|
1415
1838
|
}
|
|
1416
1839
|
}
|
|
1417
1840
|
?>`;
|
|
1418
|
-
r !== s && await e.writeFile(
|
|
1841
|
+
r !== s && await e.writeFile(t, r);
|
|
1419
1842
|
}
|
|
1420
1843
|
}
|
|
1421
1844
|
}
|
|
1422
|
-
async function
|
|
1423
|
-
const i =
|
|
1845
|
+
async function qe(e, n) {
|
|
1846
|
+
const i = a(n, "wp-admin/admin-ajax.php");
|
|
1424
1847
|
if (!e.fileExists(i)) return;
|
|
1425
|
-
let
|
|
1426
|
-
if (!
|
|
1848
|
+
let t = e.readFileAsText(i);
|
|
1849
|
+
if (!t.includes("is_user_logged_in")) return;
|
|
1427
1850
|
const s = `
|
|
1428
1851
|
// Playground: authenticate admin user for AJAX requests on WP < 2.8.
|
|
1429
1852
|
if (defined('PLAYGROUND_AUTO_LOGIN_AS_USER')) {
|
|
1430
|
-
${
|
|
1853
|
+
${k("PLAYGROUND_AUTO_LOGIN_AS_USER")}
|
|
1431
1854
|
}
|
|
1432
1855
|
`;
|
|
1433
|
-
|
|
1856
|
+
t = t.replace(
|
|
1434
1857
|
/if\s*\(\s*!\s*is_user_logged_in\(\)\s*\)/,
|
|
1435
1858
|
s + "if ( !is_user_logged_in() )"
|
|
1436
|
-
), await e.writeFile(i,
|
|
1859
|
+
), await e.writeFile(i, t);
|
|
1437
1860
|
}
|
|
1438
|
-
function
|
|
1861
|
+
function k(e) {
|
|
1439
1862
|
return `
|
|
1440
1863
|
$_pg_user = null;
|
|
1441
1864
|
if (function_exists('wp_generate_auth_cookie')) {
|
|
@@ -1456,50 +1879,50 @@ if (function_exists('wp_generate_auth_cookie')) {
|
|
|
1456
1879
|
}
|
|
1457
1880
|
`;
|
|
1458
1881
|
}
|
|
1459
|
-
async function
|
|
1460
|
-
const i =
|
|
1882
|
+
async function We(e, n) {
|
|
1883
|
+
const i = E(e, n);
|
|
1461
1884
|
if (i === null) return;
|
|
1462
|
-
const
|
|
1463
|
-
if (!Number.isFinite(
|
|
1464
|
-
const s =
|
|
1465
|
-
|
|
1885
|
+
const t = parseFloat(i);
|
|
1886
|
+
if (!Number.isFinite(t) || t >= 3.3) return;
|
|
1887
|
+
const s = a(
|
|
1888
|
+
n,
|
|
1466
1889
|
"wp-admin/includes/schema.php"
|
|
1467
1890
|
);
|
|
1468
1891
|
if (!e.fileExists(s)) return;
|
|
1469
1892
|
const r = e.readFileAsText(s);
|
|
1470
|
-
/\$wp_queries\s*=\s*"CREATE TABLE/.test(r) && !r.includes("function wp_get_db_schema") && await
|
|
1893
|
+
/\$wp_queries\s*=\s*"CREATE TABLE/.test(r) && !r.includes("function wp_get_db_schema") && await Ge(e, n, s, r);
|
|
1471
1894
|
}
|
|
1472
|
-
async function
|
|
1473
|
-
const s =
|
|
1895
|
+
async function Ge(e, n, i, t) {
|
|
1896
|
+
const s = t.match(/\$wp_queries\s*=\s*"CREATE TABLE/);
|
|
1474
1897
|
if (!s || s.index === void 0)
|
|
1475
1898
|
return;
|
|
1476
|
-
const r = s.index,
|
|
1477
|
-
if (
|
|
1899
|
+
const r = s.index, o = '";', _ = t.indexOf(o, r);
|
|
1900
|
+
if (_ === -1)
|
|
1478
1901
|
return;
|
|
1479
|
-
const l =
|
|
1902
|
+
const l = _ + o.length, u = `function wp_get_db_schema( $scope = 'all', $blog_id = null ) {
|
|
1480
1903
|
global $wpdb, $wp_queries, $charset_collate;
|
|
1481
1904
|
$charset_collate = '';
|
|
1482
1905
|
if ( ! empty($wpdb->charset) )
|
|
1483
1906
|
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
|
|
1484
1907
|
if ( ! empty($wpdb->collate) )
|
|
1485
1908
|
$charset_collate .= " COLLATE $wpdb->collate";
|
|
1486
|
-
${
|
|
1909
|
+
${t.substring(r, l)}
|
|
1487
1910
|
return $wp_queries;
|
|
1488
|
-
}`,
|
|
1489
|
-
await e.writeFile(i,
|
|
1490
|
-
const
|
|
1491
|
-
|
|
1911
|
+
}`, f = t.substring(0, r) + u + t.substring(l);
|
|
1912
|
+
await e.writeFile(i, f);
|
|
1913
|
+
const $ = a(
|
|
1914
|
+
n,
|
|
1492
1915
|
"wp-admin/includes/upgrade.php"
|
|
1493
1916
|
);
|
|
1494
|
-
if (e.fileExists(
|
|
1495
|
-
const
|
|
1917
|
+
if (e.fileExists($)) {
|
|
1918
|
+
const L = e.readFileAsText($), y = L.replace(
|
|
1496
1919
|
/(\$alterations\s*=\s*dbDelta\(\s*\$wp_queries\s*\))/g,
|
|
1497
1920
|
"if ( function_exists('wp_get_db_schema') ) { $wp_queries = wp_get_db_schema(); } $1"
|
|
1498
1921
|
);
|
|
1499
|
-
y !==
|
|
1922
|
+
y !== L && await e.writeFile($, y);
|
|
1500
1923
|
}
|
|
1501
1924
|
}
|
|
1502
|
-
function
|
|
1925
|
+
function Me() {
|
|
1503
1926
|
return `<?php
|
|
1504
1927
|
// @playground-managed — Playground-generated db.php.
|
|
1505
1928
|
// WP < 3.0 loads only db.php and skips wp-db.php, so we pull
|
|
@@ -1551,11 +1974,12 @@ if (!function_exists('mysqli_close')) {
|
|
|
1551
1974
|
}
|
|
1552
1975
|
`;
|
|
1553
1976
|
}
|
|
1554
|
-
async function
|
|
1977
|
+
async function Be(e, n) {
|
|
1978
|
+
if (await z(e)) return;
|
|
1555
1979
|
let i = null;
|
|
1556
|
-
const
|
|
1557
|
-
if (e.fileExists(
|
|
1558
|
-
const r = e.readFileAsText(
|
|
1980
|
+
const t = a(e.documentRoot, "wp-includes/version.php");
|
|
1981
|
+
if (e.fileExists(t)) {
|
|
1982
|
+
const r = e.readFileAsText(t).match(/\$wp_version\s*=\s*['"]([^'"]+)['"]/);
|
|
1559
1983
|
r && (i = r[1]);
|
|
1560
1984
|
}
|
|
1561
1985
|
const s = i !== null && parseFloat(i) < 3.5;
|
|
@@ -1564,7 +1988,7 @@ async function Oe(e, t) {
|
|
|
1564
1988
|
code: `<?php
|
|
1565
1989
|
// WP_INSTALLING bypasses WP 1.x's "not installed" die() in wp-settings.php.
|
|
1566
1990
|
define('WP_INSTALLING', true);
|
|
1567
|
-
error_reporting(${
|
|
1991
|
+
error_reporting(${w});
|
|
1568
1992
|
ini_set('display_errors', '0');
|
|
1569
1993
|
ob_start();
|
|
1570
1994
|
$_pg_db_path = getenv('DOCUMENT_ROOT') . '/wp-content/database/.ht.sqlite';
|
|
@@ -1706,11 +2130,11 @@ async function Oe(e, t) {
|
|
|
1706
2130
|
`,
|
|
1707
2131
|
env: {
|
|
1708
2132
|
DOCUMENT_ROOT: e.documentRoot,
|
|
1709
|
-
PLAYGROUND_SITE_URL:
|
|
2133
|
+
PLAYGROUND_SITE_URL: n || ""
|
|
1710
2134
|
}
|
|
1711
2135
|
});
|
|
1712
2136
|
} catch (r) {
|
|
1713
|
-
|
|
2137
|
+
d.warn("Legacy WP post-install fixups failed (non-fatal):", r);
|
|
1714
2138
|
}
|
|
1715
2139
|
if (s)
|
|
1716
2140
|
try {
|
|
@@ -2011,14 +2435,14 @@ async function Oe(e, t) {
|
|
|
2011
2435
|
`,
|
|
2012
2436
|
env: {
|
|
2013
2437
|
DOCUMENT_ROOT: e.documentRoot,
|
|
2014
|
-
PLAYGROUND_SITE_URL:
|
|
2438
|
+
PLAYGROUND_SITE_URL: n || ""
|
|
2015
2439
|
}
|
|
2016
2440
|
});
|
|
2017
2441
|
} catch (r) {
|
|
2018
|
-
|
|
2442
|
+
d.warn("Legacy WP PDO fallback failed (non-fatal):", r);
|
|
2019
2443
|
}
|
|
2020
2444
|
}
|
|
2021
|
-
const
|
|
2445
|
+
const He = `
|
|
2022
2446
|
// Connection stubs — wpdb::__construct bails on a falsy return.
|
|
2023
2447
|
if (!function_exists('mysqli_connect')) {
|
|
2024
2448
|
function mysqli_connect() { return true; }
|
|
@@ -2036,6 +2460,9 @@ if (!function_exists('mysql_select_db')) {
|
|
|
2036
2460
|
if (!function_exists('mysql_set_charset')) {
|
|
2037
2461
|
function mysql_set_charset() { return true; }
|
|
2038
2462
|
}
|
|
2463
|
+
if (!defined('MYSQL_ASSOC')) define('MYSQL_ASSOC', 1);
|
|
2464
|
+
if (!defined('MYSQL_NUM')) define('MYSQL_NUM', 2);
|
|
2465
|
+
if (!defined('MYSQL_BOTH')) define('MYSQL_BOTH', 3);
|
|
2039
2466
|
// Functional mysql_* stubs that delegate to $wpdb (SQLite driver).
|
|
2040
2467
|
$GLOBALS['_mysql_results'] = array();
|
|
2041
2468
|
$GLOBALS['_mysql_result_id'] = 0;
|
|
@@ -2101,6 +2528,23 @@ if (!function_exists('mysql_fetch_row')) {
|
|
|
2101
2528
|
return array_values((array)$row);
|
|
2102
2529
|
}
|
|
2103
2530
|
}
|
|
2531
|
+
if (!function_exists('mysql_fetch_assoc')) {
|
|
2532
|
+
function mysql_fetch_assoc($result) {
|
|
2533
|
+
if (!isset($GLOBALS['_mysql_results'][$result])) return null;
|
|
2534
|
+
$r = &$GLOBALS['_mysql_results'][$result];
|
|
2535
|
+
if ($r['index'] >= count($r['rows'])) return null;
|
|
2536
|
+
return (array)$r['rows'][$r['index']++];
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
if (!function_exists('mysql_fetch_array')) {
|
|
2540
|
+
function mysql_fetch_array($result, $result_type = null) {
|
|
2541
|
+
$row = mysql_fetch_assoc($result);
|
|
2542
|
+
if ($row === null) return null;
|
|
2543
|
+
if ($result_type === MYSQL_ASSOC) return $row;
|
|
2544
|
+
if ($result_type === MYSQL_NUM) return array_values($row);
|
|
2545
|
+
return array_merge(array_values($row), $row);
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2104
2548
|
if (!function_exists('mysql_fetch_object')) {
|
|
2105
2549
|
function mysql_fetch_object($result) {
|
|
2106
2550
|
if (!isset($GLOBALS['_mysql_results'][$result])) return null;
|
|
@@ -2159,28 +2603,28 @@ if (!function_exists('mysql_real_escape_string')) {
|
|
|
2159
2603
|
if (!function_exists('mysql_escape_string')) {
|
|
2160
2604
|
function mysql_escape_string($s) { return addslashes($s); }
|
|
2161
2605
|
}`;
|
|
2162
|
-
async function
|
|
2606
|
+
async function Xe(e, n, i = {}) {
|
|
2163
2607
|
await e.isDir("/tmp/sqlite-database-integration") && await e.rmdir("/tmp/sqlite-database-integration", {
|
|
2164
2608
|
recursive: !0
|
|
2165
|
-
}), await e.mkdir("/tmp/sqlite-database-integration"), await
|
|
2166
|
-
const
|
|
2167
|
-
await e.mv(s,
|
|
2168
|
-
let
|
|
2169
|
-
|
|
2609
|
+
}), await e.mkdir("/tmp/sqlite-database-integration"), await g(e, n, "/tmp/sqlite-database-integration");
|
|
2610
|
+
const t = "/internal/shared/sqlite-database-integration", s = `/tmp/sqlite-database-integration/${(await e.listFiles("/tmp/sqlite-database-integration"))[0]}`;
|
|
2611
|
+
await e.mv(s, t), await Ve(e, t), await e.defineConstant("SQLITE_MAIN_FILE", "1");
|
|
2612
|
+
let o = (await e.readFileAsText(
|
|
2613
|
+
a(t, "db.copy")
|
|
2170
2614
|
)).replace(
|
|
2171
2615
|
"'{SQLITE_IMPLEMENTATION_FOLDER_PATH}'",
|
|
2172
|
-
|
|
2616
|
+
p(t)
|
|
2173
2617
|
).replace(
|
|
2174
2618
|
"'{SQLITE_PLUGIN}'",
|
|
2175
|
-
|
|
2619
|
+
p(a(t, "load.php"))
|
|
2176
2620
|
);
|
|
2177
|
-
|
|
2621
|
+
o = o.replace(
|
|
2178
2622
|
/^add_action\(/gm,
|
|
2179
2623
|
'function_exists("add_action") && add_action('
|
|
2180
2624
|
);
|
|
2181
|
-
const
|
|
2182
|
-
if(file_exists(${
|
|
2183
|
-
$_pg_db_php = @file_get_contents(${
|
|
2625
|
+
const _ = a(await e.documentRoot, "wp-content/db.php"), l = "/internal/shared/mu-plugins/sqlite-database-integration.php", c = `
|
|
2626
|
+
if(file_exists(${p(_)})) {
|
|
2627
|
+
$_pg_db_php = @file_get_contents(${p(_)});
|
|
2184
2628
|
if (strpos($_pg_db_php, '@playground-managed') === false) {
|
|
2185
2629
|
return;
|
|
2186
2630
|
}
|
|
@@ -2188,9 +2632,9 @@ if(file_exists(${$(o)})) {
|
|
|
2188
2632
|
}
|
|
2189
2633
|
`;
|
|
2190
2634
|
await e.writeFile(l, `<?php
|
|
2191
|
-
${c}?>` +
|
|
2635
|
+
${c}?>` + o), await e.writeFile(
|
|
2192
2636
|
"/internal/shared/preload/0-sqlite.php",
|
|
2193
|
-
|
|
2637
|
+
Ye(c, l)
|
|
2194
2638
|
), await e.writeFile(
|
|
2195
2639
|
"/internal/shared/mu-plugins/sqlite-test.php",
|
|
2196
2640
|
`<?php
|
|
@@ -2202,19 +2646,19 @@ ${c}?>` + a), await e.writeFile(
|
|
|
2202
2646
|
`
|
|
2203
2647
|
);
|
|
2204
2648
|
}
|
|
2205
|
-
async function
|
|
2206
|
-
const i =
|
|
2207
|
-
|
|
2649
|
+
async function Ve(e, n) {
|
|
2650
|
+
const i = a(
|
|
2651
|
+
n,
|
|
2208
2652
|
"wp-includes/database/sqlite/class-wp-pdo-mysql-on-sqlite.php"
|
|
2209
2653
|
);
|
|
2210
2654
|
if (!await e.fileExists(i)) return;
|
|
2211
|
-
const
|
|
2655
|
+
const t = await e.readFileAsText(i), s = t.replace(
|
|
2212
2656
|
/\$active_sql_modes\s*=\s*array\s*\([^)]*\)\s*;/,
|
|
2213
2657
|
"$active_sql_modes = array();"
|
|
2214
2658
|
);
|
|
2215
|
-
s !==
|
|
2659
|
+
s !== t && await e.writeFile(i, s);
|
|
2216
2660
|
}
|
|
2217
|
-
function
|
|
2661
|
+
function Ye(e, n) {
|
|
2218
2662
|
return `<?php
|
|
2219
2663
|
${e}?>
|
|
2220
2664
|
<?php
|
|
@@ -2247,11 +2691,11 @@ if (
|
|
|
2247
2691
|
}
|
|
2248
2692
|
?>
|
|
2249
2693
|
<?php
|
|
2250
|
-
${
|
|
2694
|
+
${S(
|
|
2251
2695
|
// WP < 3.0's wpdb does mysql_connect() inline so the SQLite
|
|
2252
2696
|
// plugin's db_connect() never runs; reinitialize_sqlite()
|
|
2253
2697
|
// swaps the dbh in place after the integration is loaded.
|
|
2254
|
-
`require_once ${
|
|
2698
|
+
`require_once ${p(n)};
|
|
2255
2699
|
if (
|
|
2256
2700
|
isset($GLOBALS['wpdb']) &&
|
|
2257
2701
|
method_exists($GLOBALS['wpdb'], 'reinitialize_sqlite')
|
|
@@ -2259,18 +2703,18 @@ ${v(
|
|
|
2259
2703
|
$GLOBALS['wpdb']->reinitialize_sqlite();
|
|
2260
2704
|
}`
|
|
2261
2705
|
)}
|
|
2262
|
-
${
|
|
2706
|
+
${He}
|
|
2263
2707
|
if (PHP_MAJOR_VERSION < 7) {
|
|
2264
2708
|
// E_DEPRECATED (8192) / E_STRICT (2048) are PHP 5.3+ symbols;
|
|
2265
2709
|
// LEGACY_WP_ERROR_REPORTING_PHP_EXPR uses numeric literals.
|
|
2266
|
-
$level = ${
|
|
2710
|
+
$level = ${w};
|
|
2267
2711
|
error_reporting($level);
|
|
2268
2712
|
ini_set('error_reporting', $level);
|
|
2269
2713
|
}
|
|
2270
2714
|
|
|
2271
2715
|
`;
|
|
2272
2716
|
}
|
|
2273
|
-
const
|
|
2717
|
+
const v = `<?php
|
|
2274
2718
|
|
|
2275
2719
|
/**
|
|
2276
2720
|
* Transforms the "wp-config.php" file.
|
|
@@ -2742,32 +3186,32 @@ class WP_Config_Transformer {
|
|
|
2742
3186
|
}
|
|
2743
3187
|
}
|
|
2744
3188
|
`;
|
|
2745
|
-
async function
|
|
2746
|
-
const i =
|
|
2747
|
-
!e.fileExists(i) && e.fileExists(
|
|
3189
|
+
async function Ke(e, n) {
|
|
3190
|
+
const i = a(n, "wp-config.php");
|
|
3191
|
+
!e.fileExists(i) && e.fileExists(a(n, "wp-config-sample.php")) && await e.writeFile(
|
|
2748
3192
|
i,
|
|
2749
3193
|
await e.readFileAsBuffer(
|
|
2750
|
-
|
|
3194
|
+
a(n, "wp-config-sample.php")
|
|
2751
3195
|
)
|
|
2752
|
-
), e.fileExists(i) && await
|
|
3196
|
+
), e.fileExists(i) && await Qe(e, i, {
|
|
2753
3197
|
DB_NAME: "wordpress"
|
|
2754
3198
|
});
|
|
2755
3199
|
}
|
|
2756
|
-
async function
|
|
2757
|
-
const
|
|
3200
|
+
async function Lt(e, n, i) {
|
|
3201
|
+
const t = P({ wpConfigPath: n, constants: i });
|
|
2758
3202
|
if ((await e.run({
|
|
2759
|
-
code: `${
|
|
2760
|
-
$wp_config_path = ${
|
|
3203
|
+
code: `${v}
|
|
3204
|
+
$wp_config_path = ${t.wpConfigPath};
|
|
2761
3205
|
$transformer = WP_Config_Transformer::from_file($wp_config_path);
|
|
2762
|
-
$transformer->define_constants(${
|
|
3206
|
+
$transformer->define_constants(${t.constants});
|
|
2763
3207
|
$transformer->to_file($wp_config_path);
|
|
2764
3208
|
`
|
|
2765
3209
|
})).errors.length > 0)
|
|
2766
3210
|
throw new Error("Failed to rewrite constants in wp-config.php.");
|
|
2767
3211
|
}
|
|
2768
|
-
async function
|
|
2769
|
-
const
|
|
2770
|
-
code: `${
|
|
3212
|
+
async function Qe(e, n, i) {
|
|
3213
|
+
const t = Object.keys(i), s = P({ wpConfigPath: n, constantNames: t }), r = await e.run({
|
|
3214
|
+
code: `${v}
|
|
2771
3215
|
$transformer = WP_Config_Transformer::from_file(${s.wpConfigPath});
|
|
2772
3216
|
$missing = [];
|
|
2773
3217
|
foreach (${s.constantNames} as $name) {
|
|
@@ -2780,42 +3224,42 @@ async function xe(e, t, i) {
|
|
|
2780
3224
|
});
|
|
2781
3225
|
if (r.errors.length > 0)
|
|
2782
3226
|
throw new Error("Failed to check wp-config.php for constants.");
|
|
2783
|
-
let
|
|
3227
|
+
let o;
|
|
2784
3228
|
try {
|
|
2785
|
-
|
|
3229
|
+
o = JSON.parse(r.text);
|
|
2786
3230
|
} catch {
|
|
2787
3231
|
throw new Error(
|
|
2788
3232
|
`Failed to parse wp-config.php constant check output: ${r.text}`
|
|
2789
3233
|
);
|
|
2790
3234
|
}
|
|
2791
|
-
for (const
|
|
2792
|
-
await e.defineConstant(
|
|
3235
|
+
for (const _ of o)
|
|
3236
|
+
await e.defineConstant(_, i[_]);
|
|
2793
3237
|
}
|
|
2794
|
-
async function
|
|
2795
|
-
usesSqlite:
|
|
3238
|
+
async function T(e, {
|
|
3239
|
+
usesSqlite: n,
|
|
2796
3240
|
hasCustomDatabasePath: i
|
|
2797
3241
|
}) {
|
|
2798
|
-
const
|
|
2799
|
-
if (
|
|
3242
|
+
const t = await e.getPrimaryPhp();
|
|
3243
|
+
if (t.isFile("/internal/shared/preload/0-sqlite.php"))
|
|
2800
3244
|
return;
|
|
2801
|
-
const s =
|
|
3245
|
+
const s = a(
|
|
2802
3246
|
e.documentRoot,
|
|
2803
3247
|
"wp-content/mu-plugins/sqlite-database-integration"
|
|
2804
3248
|
);
|
|
2805
|
-
if (!
|
|
3249
|
+
if (!t.isDir(s) && !n && !i && !je(t))
|
|
2806
3250
|
throw new Error("Error connecting to the MySQL database.");
|
|
2807
3251
|
}
|
|
2808
|
-
function
|
|
2809
|
-
const
|
|
2810
|
-
if (!e.isFile(
|
|
2811
|
-
const i = e.readFileAsText(
|
|
3252
|
+
function je(e) {
|
|
3253
|
+
const n = a(e.documentRoot, "wp-config.php");
|
|
3254
|
+
if (!e.isFile(n)) return !1;
|
|
3255
|
+
const i = e.readFileAsText(n), t = i.match(
|
|
2812
3256
|
/define\s*\(\s*['"]DB_NAME['"]\s*,\s*['"]([^'"]*)['"]/
|
|
2813
3257
|
), s = i.match(
|
|
2814
3258
|
/define\s*\(\s*['"]DB_USER['"]\s*,\s*['"]([^'"]*)['"]/
|
|
2815
3259
|
);
|
|
2816
|
-
return !
|
|
3260
|
+
return !t || !s ? !1 : t[1] !== "database_name_here" && s[1] !== "username_here";
|
|
2817
3261
|
}
|
|
2818
|
-
const
|
|
3262
|
+
const D = [
|
|
2819
3263
|
"fsockopen",
|
|
2820
3264
|
"pfsockopen",
|
|
2821
3265
|
"curl_init",
|
|
@@ -2823,77 +3267,77 @@ const R = [
|
|
|
2823
3267
|
"curl_multi_exec",
|
|
2824
3268
|
"mail"
|
|
2825
3269
|
];
|
|
2826
|
-
function
|
|
2827
|
-
var r,
|
|
2828
|
-
if (!
|
|
2829
|
-
const i = (((r =
|
|
3270
|
+
function ze(e, n) {
|
|
3271
|
+
var r, o;
|
|
3272
|
+
if (!m(n.phpVersion)) return;
|
|
3273
|
+
const i = (((r = n.phpIniEntries) == null ? void 0 : r.disable_functions) ?? "").split(",").map((_) => _.trim()).filter((_) => _), s = {
|
|
2830
3274
|
disable_functions: Array.from(
|
|
2831
|
-
/* @__PURE__ */ new Set([...i, ...
|
|
3275
|
+
/* @__PURE__ */ new Set([...i, ...D])
|
|
2832
3276
|
).join(","),
|
|
2833
3277
|
allow_url_fopen: "0"
|
|
2834
3278
|
};
|
|
2835
|
-
(
|
|
3279
|
+
(o = n.phpIniEntries) != null && o["date.timezone"] || (s["date.timezone"] = "UTC"), N(e, s);
|
|
2836
3280
|
}
|
|
2837
|
-
async function
|
|
2838
|
-
var
|
|
3281
|
+
async function Ze(e, n) {
|
|
3282
|
+
var o, _;
|
|
2839
3283
|
const i = await e.getPrimaryPhp();
|
|
2840
|
-
if ((
|
|
2841
|
-
for (const l in
|
|
2842
|
-
i.defineConstant(l,
|
|
2843
|
-
i.defineConstant("WP_HOME",
|
|
2844
|
-
let
|
|
2845
|
-
|
|
3284
|
+
if ((o = n.hooks) != null && o.beforeWordPressFiles && await n.hooks.beforeWordPressFiles(i), n.wordPressZip && await q(i, await n.wordPressZip), n.constants)
|
|
3285
|
+
for (const l in n.constants)
|
|
3286
|
+
i.defineConstant(l, n.constants[l]);
|
|
3287
|
+
i.defineConstant("WP_HOME", n.siteUrl), i.defineConstant("WP_SITEURL", n.siteUrl), await Je(i, e.documentRoot), await pe(i, e.documentRoot), (_ = n.hooks) != null && _.beforeDatabaseSetup && await n.hooks.beforeDatabaseSetup(i);
|
|
3288
|
+
let t = !1;
|
|
3289
|
+
n.sqliteIntegrationPluginZip && (t = !0, await C(
|
|
2846
3290
|
i,
|
|
2847
|
-
await
|
|
2848
|
-
{ phpVersion:
|
|
2849
|
-
), await
|
|
2850
|
-
const s =
|
|
3291
|
+
await n.sqliteIntegrationPluginZip,
|
|
3292
|
+
{ phpVersion: n.phpVersion }
|
|
3293
|
+
), await et(i, e.documentRoot));
|
|
3294
|
+
const s = n.wordpressInstallMode ?? "download-and-install", r = !!n.dataSqlPath;
|
|
2851
3295
|
return (s === "download-and-install" || s === "install-from-existing-files" || // Legacy PHP: isWordPressInstalled() can trigger a WASM trap
|
|
2852
3296
|
// (not a PHP exception) on old WordPress (< 3.0) and corrupt
|
|
2853
3297
|
// the runtime beyond recovery. Always run the installer; it
|
|
2854
3298
|
// is idempotent and its post-install fixups short-circuit
|
|
2855
3299
|
// cheaply when the schema already exists.
|
|
2856
|
-
s === "install-from-existing-files-if-needed") && (await
|
|
2857
|
-
usesSqlite:
|
|
3300
|
+
s === "install-from-existing-files-if-needed") && (await T(e, {
|
|
3301
|
+
usesSqlite: t,
|
|
2858
3302
|
hasCustomDatabasePath: r
|
|
2859
|
-
}), await
|
|
3303
|
+
}), await tt(i, e)), e;
|
|
2860
3304
|
}
|
|
2861
|
-
async function
|
|
2862
|
-
const i =
|
|
2863
|
-
!e.fileExists(i) && e.fileExists(
|
|
3305
|
+
async function Je(e, n) {
|
|
3306
|
+
const i = a(n, "wp-config.php"), t = a(n, "wp-config-sample.php");
|
|
3307
|
+
!e.fileExists(i) && e.fileExists(t) && await e.writeFile(
|
|
2864
3308
|
i,
|
|
2865
|
-
await e.readFileAsBuffer(
|
|
3309
|
+
await e.readFileAsBuffer(t)
|
|
2866
3310
|
);
|
|
2867
3311
|
}
|
|
2868
|
-
async function
|
|
2869
|
-
const i =
|
|
2870
|
-
e.isDir(i) && !e.fileExists(
|
|
3312
|
+
async function et(e, n) {
|
|
3313
|
+
const i = a(n, "wp-content"), t = a(i, "db.php");
|
|
3314
|
+
e.isDir(i) && !e.fileExists(t) && await e.writeFile(t, Me());
|
|
2871
3315
|
}
|
|
2872
|
-
async function
|
|
3316
|
+
async function tt(e, n) {
|
|
2873
3317
|
try {
|
|
2874
|
-
await
|
|
3318
|
+
await nt(e);
|
|
2875
3319
|
} catch (i) {
|
|
2876
|
-
|
|
3320
|
+
d.warn("Legacy PHP WordPress installation error:", i);
|
|
2877
3321
|
}
|
|
2878
|
-
await
|
|
2879
|
-
}
|
|
2880
|
-
async function
|
|
2881
|
-
var r,
|
|
2882
|
-
const
|
|
2883
|
-
if (
|
|
2884
|
-
const
|
|
2885
|
-
if (
|
|
3322
|
+
await Be(e, n.absoluteUrl);
|
|
3323
|
+
}
|
|
3324
|
+
async function nt(e) {
|
|
3325
|
+
var r, o, _, l, c, u;
|
|
3326
|
+
const n = rt(e, e.documentRoot);
|
|
3327
|
+
if (n !== null) {
|
|
3328
|
+
const f = parseFloat(n);
|
|
3329
|
+
if (f < 2.1)
|
|
2886
3330
|
return;
|
|
2887
|
-
if (
|
|
2888
|
-
await
|
|
3331
|
+
if (f <= 3) {
|
|
3332
|
+
await st(e);
|
|
2889
3333
|
return;
|
|
2890
3334
|
}
|
|
2891
3335
|
}
|
|
2892
3336
|
const i = {
|
|
2893
|
-
disable_functions:
|
|
3337
|
+
disable_functions: D.join(","),
|
|
2894
3338
|
allow_url_fopen: "0",
|
|
2895
|
-
error_reporting: String(
|
|
2896
|
-
},
|
|
3339
|
+
error_reporting: String(ue)
|
|
3340
|
+
}, t = await A(
|
|
2897
3341
|
e,
|
|
2898
3342
|
i,
|
|
2899
3343
|
async () => await e.request({
|
|
@@ -2912,16 +3356,16 @@ async function Ce(e) {
|
|
|
2912
3356
|
}
|
|
2913
3357
|
})
|
|
2914
3358
|
);
|
|
2915
|
-
if (!(((r =
|
|
3359
|
+
if (!(((r = t.text) == null ? void 0 : r.includes("Success")) || ((o = t.text) == null ? void 0 : o.includes("successful")) || ((_ = t.text) == null ? void 0 : _.includes("Finished")) || ((l = t.text) == null ? void 0 : l.includes("Already Installed")) || ((c = t.text) == null ? void 0 : c.includes("already have WordPress installed")) || !1))
|
|
2916
3360
|
throw new Error(
|
|
2917
|
-
`Failed to install WordPress – installer responded with "${(u =
|
|
3361
|
+
`Failed to install WordPress – installer responded with "${(u = t.text) == null ? void 0 : u.substring(
|
|
2918
3362
|
0,
|
|
2919
3363
|
100
|
|
2920
3364
|
)}"`
|
|
2921
3365
|
);
|
|
2922
|
-
await
|
|
3366
|
+
await it(e);
|
|
2923
3367
|
}
|
|
2924
|
-
async function
|
|
3368
|
+
async function it(e) {
|
|
2925
3369
|
try {
|
|
2926
3370
|
(await e.run({
|
|
2927
3371
|
code: `<?php
|
|
@@ -2947,21 +3391,21 @@ async function qe(e) {
|
|
|
2947
3391
|
echo $check === $nice_permalinks ? '1' : '0';
|
|
2948
3392
|
`,
|
|
2949
3393
|
env: { DOCUMENT_ROOT: e.documentRoot }
|
|
2950
|
-
})).text !== "1" &&
|
|
3394
|
+
})).text !== "1" && d.warn(
|
|
2951
3395
|
"Failed to default to pretty permalinks after WP install."
|
|
2952
3396
|
);
|
|
2953
3397
|
} catch {
|
|
2954
|
-
|
|
3398
|
+
d.warn(
|
|
2955
3399
|
"Failed to set pretty permalinks after WP install (non-fatal)."
|
|
2956
3400
|
);
|
|
2957
3401
|
}
|
|
2958
3402
|
}
|
|
2959
|
-
async function
|
|
3403
|
+
async function st(e) {
|
|
2960
3404
|
try {
|
|
2961
3405
|
await e.run({
|
|
2962
3406
|
code: `<?php
|
|
2963
3407
|
define('WP_INSTALLING', true);
|
|
2964
|
-
error_reporting(${
|
|
3408
|
+
error_reporting(${w});
|
|
2965
3409
|
ini_set('display_errors', '0');
|
|
2966
3410
|
ob_start();
|
|
2967
3411
|
require getenv('DOCUMENT_ROOT') . '/wp-load.php';
|
|
@@ -2983,85 +3427,85 @@ async function We(e) {
|
|
|
2983
3427
|
`,
|
|
2984
3428
|
env: { DOCUMENT_ROOT: e.documentRoot }
|
|
2985
3429
|
});
|
|
2986
|
-
} catch (
|
|
2987
|
-
|
|
3430
|
+
} catch (n) {
|
|
3431
|
+
d.warn("runDbDeltaOnly failed (non-fatal):", n);
|
|
2988
3432
|
}
|
|
2989
3433
|
}
|
|
2990
|
-
function
|
|
2991
|
-
const i =
|
|
3434
|
+
function rt(e, n) {
|
|
3435
|
+
const i = a(n, "wp-includes/version.php");
|
|
2992
3436
|
if (!e.fileExists(i)) return null;
|
|
2993
3437
|
const s = e.readFileAsText(i).match(/\$wp_version\s*=\s*['"]([^'"]+)['"]/);
|
|
2994
3438
|
return s ? s[1] : null;
|
|
2995
3439
|
}
|
|
2996
|
-
async function
|
|
2997
|
-
const
|
|
2998
|
-
return await
|
|
3440
|
+
async function yt(e) {
|
|
3441
|
+
const n = await ot(e);
|
|
3442
|
+
return await at(n, e), n;
|
|
2999
3443
|
}
|
|
3000
|
-
async function
|
|
3001
|
-
var
|
|
3002
|
-
if (
|
|
3003
|
-
return
|
|
3444
|
+
async function at(e, n) {
|
|
3445
|
+
var o, _;
|
|
3446
|
+
if (m(n.phpVersion))
|
|
3447
|
+
return Ze(e, n);
|
|
3004
3448
|
const i = await e.getPrimaryPhp();
|
|
3005
|
-
if ((
|
|
3006
|
-
for (const l in
|
|
3007
|
-
i.defineConstant(l,
|
|
3008
|
-
|
|
3009
|
-
let
|
|
3010
|
-
|
|
3449
|
+
if ((o = n.hooks) != null && o.beforeWordPressFiles && await n.hooks.beforeWordPressFiles(i), n.wordPressZip && await q(i, await n.wordPressZip), n.constants)
|
|
3450
|
+
for (const l in n.constants)
|
|
3451
|
+
i.defineConstant(l, n.constants[l]);
|
|
3452
|
+
n.dataSqlPath && (i.defineConstant("DB_DIR", B(n.dataSqlPath)), i.defineConstant("DB_FILE", H(n.dataSqlPath))), i.defineConstant("WP_HOME", n.siteUrl), i.defineConstant("WP_SITEURL", n.siteUrl), await Ke(i, e.documentRoot), (_ = n.hooks) != null && _.beforeDatabaseSetup && await n.hooks.beforeDatabaseSetup(i);
|
|
3453
|
+
let t = !1;
|
|
3454
|
+
n.sqliteIntegrationPluginZip && (t = !0, await C(
|
|
3011
3455
|
i,
|
|
3012
|
-
await
|
|
3013
|
-
{ phpVersion:
|
|
3014
|
-
), await
|
|
3015
|
-
const s =
|
|
3456
|
+
await n.sqliteIntegrationPluginZip,
|
|
3457
|
+
{ phpVersion: n.phpVersion }
|
|
3458
|
+
), await ce(i, e.documentRoot));
|
|
3459
|
+
const s = n.wordpressInstallMode ?? "download-and-install", r = !!n.dataSqlPath;
|
|
3016
3460
|
if (["download-and-install", "install-from-existing-files"].includes(
|
|
3017
3461
|
s
|
|
3018
3462
|
)) {
|
|
3019
|
-
await
|
|
3020
|
-
usesSqlite:
|
|
3463
|
+
await T(e, {
|
|
3464
|
+
usesSqlite: t,
|
|
3021
3465
|
hasCustomDatabasePath: r
|
|
3022
3466
|
});
|
|
3023
3467
|
try {
|
|
3024
|
-
await
|
|
3468
|
+
await b(i);
|
|
3025
3469
|
} catch (l) {
|
|
3026
|
-
throw r || await
|
|
3470
|
+
throw r || await h(e), l;
|
|
3027
3471
|
}
|
|
3028
|
-
r || await
|
|
3472
|
+
r || await h(e);
|
|
3029
3473
|
} else if (s === "install-from-existing-files-if-needed") {
|
|
3030
|
-
if (await
|
|
3031
|
-
usesSqlite:
|
|
3474
|
+
if (await T(e, {
|
|
3475
|
+
usesSqlite: t,
|
|
3032
3476
|
hasCustomDatabasePath: r
|
|
3033
|
-
}), !await
|
|
3477
|
+
}), !await F(i))
|
|
3034
3478
|
try {
|
|
3035
|
-
await
|
|
3479
|
+
await b(i);
|
|
3036
3480
|
} catch (l) {
|
|
3037
|
-
throw r || await
|
|
3481
|
+
throw r || await h(e), l;
|
|
3038
3482
|
}
|
|
3039
|
-
r || await
|
|
3483
|
+
r || await h(e);
|
|
3040
3484
|
}
|
|
3041
3485
|
return e;
|
|
3042
3486
|
}
|
|
3043
|
-
async function
|
|
3044
|
-
const
|
|
3045
|
-
if (await
|
|
3487
|
+
async function h(e) {
|
|
3488
|
+
const n = await e.getPrimaryPhp();
|
|
3489
|
+
if (await lt(n))
|
|
3046
3490
|
return;
|
|
3047
|
-
if (
|
|
3491
|
+
if (n.isFile("/internal/shared/preload/0-sqlite.php"))
|
|
3048
3492
|
throw new Error("Error connecting to the SQLite database.");
|
|
3049
|
-
const
|
|
3493
|
+
const t = a(
|
|
3050
3494
|
e.documentRoot,
|
|
3051
3495
|
"wp-content/mu-plugins/sqlite-database-integration"
|
|
3052
3496
|
);
|
|
3053
|
-
throw
|
|
3497
|
+
throw n.isDir(t) ? new Error("Error connecting to the SQLite database.") : new Error("Error connecting to the MySQL database.");
|
|
3054
3498
|
}
|
|
3055
|
-
async function
|
|
3056
|
-
const
|
|
3499
|
+
async function ot(e) {
|
|
3500
|
+
const n = e.spawnHandler ?? W;
|
|
3057
3501
|
async function i(s, r = !1) {
|
|
3058
|
-
const
|
|
3059
|
-
if (e.sapiName &&
|
|
3502
|
+
const o = await e.createPhpRuntime(r), _ = new M(o);
|
|
3503
|
+
if (e.sapiName && _.setSapiName(e.sapiName), s && (_.requestHandler = s), e.phpIniEntries && N(_, e.phpIniEntries), ze(_, {
|
|
3060
3504
|
phpVersion: e.phpVersion,
|
|
3061
3505
|
phpIniEntries: e.phpIniEntries
|
|
3062
|
-
}),
|
|
3506
|
+
}), _.defineConstant("WP_SQLITE_AST_DRIVER", !0), e.constants)
|
|
3063
3507
|
for (const l in e.constants)
|
|
3064
|
-
|
|
3508
|
+
_.defineConstant(l, e.constants[l]);
|
|
3065
3509
|
return r && /**
|
|
3066
3510
|
* Only the first PHP instance of the first worker created
|
|
3067
3511
|
* during WordPress boot writes these files – otherwise we'll keep
|
|
@@ -3072,28 +3516,28 @@ async function He(e) {
|
|
|
3072
3516
|
* mechanism. It works, because secondary workers are only booted
|
|
3073
3517
|
* once the primary worker has fully booted.
|
|
3074
3518
|
*/
|
|
3075
|
-
!
|
|
3519
|
+
!_.isFile("/internal/.boot-files-written") && (await pt(_, {
|
|
3076
3520
|
phpVersion: e.phpVersion
|
|
3077
|
-
}), await
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
), await
|
|
3521
|
+
}), await O(_, "/", e.createFiles || {}), await dt(
|
|
3522
|
+
_,
|
|
3523
|
+
a(new URL(e.siteUrl).pathname, "phpinfo.php")
|
|
3524
|
+
), await O(_, "/internal", {
|
|
3081
3525
|
".boot-files-written": ""
|
|
3082
|
-
})),
|
|
3083
|
-
|
|
3526
|
+
})), n && await _.setSpawnHandler(
|
|
3527
|
+
n(
|
|
3084
3528
|
s ? () => s.instanceManager.acquirePHPInstance() : void 0
|
|
3085
3529
|
)
|
|
3086
|
-
),
|
|
3530
|
+
), _.enableRuntimeRotation({
|
|
3087
3531
|
recreateRuntime: e.createPhpRuntime,
|
|
3088
3532
|
maxRequests: 400
|
|
3089
|
-
}), e.onPHPInstanceCreated && await e.onPHPInstanceCreated(
|
|
3533
|
+
}), e.onPHPInstanceCreated && await e.onPHPInstanceCreated(_, { isPrimary: r }), _;
|
|
3090
3534
|
}
|
|
3091
|
-
const
|
|
3535
|
+
const t = new G({
|
|
3092
3536
|
documentRoot: e.documentRoot || "/wordpress",
|
|
3093
3537
|
absoluteUrl: e.siteUrl,
|
|
3094
|
-
rewriteRules:
|
|
3538
|
+
rewriteRules: ut,
|
|
3095
3539
|
pathAliases: e.pathAliases,
|
|
3096
|
-
getFileNotFoundAction: e.getFileNotFoundAction ??
|
|
3540
|
+
getFileNotFoundAction: e.getFileNotFoundAction ?? _t,
|
|
3097
3541
|
cookieStore: e.cookieStore,
|
|
3098
3542
|
/**
|
|
3099
3543
|
* If maxPhpInstances is 1, the PHPRequestHandler constructor needs
|
|
@@ -3106,12 +3550,12 @@ async function He(e) {
|
|
|
3106
3550
|
* a PHP factory function. Internally, it creates a PHPProcessManager that
|
|
3107
3551
|
* maintains a pool of reusable PHP instances.
|
|
3108
3552
|
*/
|
|
3109
|
-
phpFactory: e.maxPhpInstances !== 1 ? async ({ isPrimary: s }) => i(
|
|
3553
|
+
phpFactory: e.maxPhpInstances !== 1 ? async ({ isPrimary: s }) => i(t, s) : void 0,
|
|
3110
3554
|
maxPhpInstances: e.maxPhpInstances
|
|
3111
3555
|
});
|
|
3112
|
-
return
|
|
3556
|
+
return t;
|
|
3113
3557
|
}
|
|
3114
|
-
async function
|
|
3558
|
+
async function F(e) {
|
|
3115
3559
|
return (await e.run({
|
|
3116
3560
|
code: `<?php
|
|
3117
3561
|
ob_start();
|
|
@@ -3130,9 +3574,9 @@ async function k(e) {
|
|
|
3130
3574
|
}
|
|
3131
3575
|
})).text === "1";
|
|
3132
3576
|
}
|
|
3133
|
-
async function
|
|
3134
|
-
var
|
|
3135
|
-
const
|
|
3577
|
+
async function b(e) {
|
|
3578
|
+
var t;
|
|
3579
|
+
const n = await A(
|
|
3136
3580
|
e,
|
|
3137
3581
|
{
|
|
3138
3582
|
disable_functions: "fsockopen",
|
|
@@ -3155,9 +3599,9 @@ async function O(e) {
|
|
|
3155
3599
|
}
|
|
3156
3600
|
})
|
|
3157
3601
|
);
|
|
3158
|
-
if (!await
|
|
3602
|
+
if (!await F(e))
|
|
3159
3603
|
throw new Error(
|
|
3160
|
-
`Failed to install WordPress – installer responded with "${(
|
|
3604
|
+
`Failed to install WordPress – installer responded with "${(t = n.text) == null ? void 0 : t.substring(
|
|
3161
3605
|
0,
|
|
3162
3606
|
100
|
|
3163
3607
|
)}"`
|
|
@@ -3187,15 +3631,15 @@ async function O(e) {
|
|
|
3187
3631
|
env: {
|
|
3188
3632
|
DOCUMENT_ROOT: e.documentRoot
|
|
3189
3633
|
}
|
|
3190
|
-
})).text !== "1" &&
|
|
3634
|
+
})).text !== "1" && d.warn("Failed to default to pretty permalinks after WP install.");
|
|
3191
3635
|
}
|
|
3192
|
-
function
|
|
3636
|
+
function _t(e) {
|
|
3193
3637
|
return {
|
|
3194
3638
|
type: "internal-redirect",
|
|
3195
3639
|
uri: "/index.php"
|
|
3196
3640
|
};
|
|
3197
3641
|
}
|
|
3198
|
-
async function
|
|
3642
|
+
async function lt(e) {
|
|
3199
3643
|
return (await e.run({
|
|
3200
3644
|
code: `<?php
|
|
3201
3645
|
ob_start();
|
|
@@ -3214,10 +3658,10 @@ async function Ve(e) {
|
|
|
3214
3658
|
}
|
|
3215
3659
|
})).text === "1";
|
|
3216
3660
|
}
|
|
3217
|
-
async function
|
|
3218
|
-
const { php:
|
|
3661
|
+
async function Ot(e) {
|
|
3662
|
+
const { php: n, reap: i } = await e.instanceManager.acquirePHPInstance();
|
|
3219
3663
|
try {
|
|
3220
|
-
const s = (await
|
|
3664
|
+
const s = (await n.run({
|
|
3221
3665
|
code: `<?php
|
|
3222
3666
|
require '${e.documentRoot}/wp-includes/version.php';
|
|
3223
3667
|
echo $wp_version;
|
|
@@ -3225,20 +3669,20 @@ async function at(e) {
|
|
|
3225
3669
|
})).text;
|
|
3226
3670
|
if (!s)
|
|
3227
3671
|
throw new Error("Unable to read loaded WordPress version.");
|
|
3228
|
-
return
|
|
3672
|
+
return ct(s);
|
|
3229
3673
|
} finally {
|
|
3230
3674
|
i();
|
|
3231
3675
|
}
|
|
3232
3676
|
}
|
|
3233
|
-
function
|
|
3677
|
+
function ct(e) {
|
|
3234
3678
|
if (/-(alpha|beta|RC)\d*-\d+$/.test(e))
|
|
3235
3679
|
return "trunk";
|
|
3236
3680
|
if (/-(beta|RC)\d*$/.test(e))
|
|
3237
3681
|
return "beta";
|
|
3238
|
-
const
|
|
3239
|
-
return
|
|
3682
|
+
const t = e.match(/^(\d+\.\d+)(?:\.\d+)?$/);
|
|
3683
|
+
return t !== null ? t[1] : e;
|
|
3240
3684
|
}
|
|
3241
|
-
const
|
|
3685
|
+
const ut = [
|
|
3242
3686
|
/**
|
|
3243
3687
|
* Substitutes the multisite WordPress rewrite rule:
|
|
3244
3688
|
*
|
|
@@ -3254,9 +3698,9 @@ const Ye = [
|
|
|
3254
3698
|
replacement: "$2"
|
|
3255
3699
|
}
|
|
3256
3700
|
];
|
|
3257
|
-
async function
|
|
3258
|
-
if (
|
|
3259
|
-
return
|
|
3701
|
+
async function pt(e, n = {}) {
|
|
3702
|
+
if (m(n.phpVersion))
|
|
3703
|
+
return Y(e);
|
|
3260
3704
|
await e.mkdir("/internal/shared/mu-plugins"), await e.writeFile(
|
|
3261
3705
|
"/internal/shared/preload/env.php",
|
|
3262
3706
|
`<?php
|
|
@@ -3444,7 +3888,7 @@ async function Ke(e, t = {}) {
|
|
|
3444
3888
|
return $interval;
|
|
3445
3889
|
});
|
|
3446
3890
|
`
|
|
3447
|
-
), await
|
|
3891
|
+
), await U(e), await e.writeFile(
|
|
3448
3892
|
"/internal/shared/preload/error-handler.php",
|
|
3449
3893
|
`<?php
|
|
3450
3894
|
(function() {
|
|
@@ -3497,13 +3941,13 @@ async function Ke(e, t = {}) {
|
|
|
3497
3941
|
})();`
|
|
3498
3942
|
);
|
|
3499
3943
|
}
|
|
3500
|
-
async function
|
|
3944
|
+
async function dt(e, n = "/phpinfo.php") {
|
|
3501
3945
|
await e.writeFile(
|
|
3502
3946
|
"/internal/shared/preload/phpinfo.php",
|
|
3503
3947
|
`<?php
|
|
3504
3948
|
// Render PHPInfo if the requested page is /phpinfo.php
|
|
3505
|
-
if ( isset($_SERVER['REQUEST_URI']) && ${
|
|
3506
|
-
|
|
3949
|
+
if ( isset($_SERVER['REQUEST_URI']) && ${p(
|
|
3950
|
+
n
|
|
3507
3951
|
)} === $_SERVER['REQUEST_URI'] ) {
|
|
3508
3952
|
phpinfo();
|
|
3509
3953
|
exit;
|
|
@@ -3511,43 +3955,43 @@ async function Qe(e, t = "/phpinfo.php") {
|
|
|
3511
3955
|
`
|
|
3512
3956
|
);
|
|
3513
3957
|
}
|
|
3514
|
-
async function
|
|
3515
|
-
if (
|
|
3516
|
-
return
|
|
3958
|
+
async function C(e, n, i = {}) {
|
|
3959
|
+
if (m(i.phpVersion))
|
|
3960
|
+
return Xe(e, n, i);
|
|
3517
3961
|
await e.isDir("/tmp/sqlite-database-integration") && await e.rmdir("/tmp/sqlite-database-integration", {
|
|
3518
3962
|
recursive: !0
|
|
3519
|
-
}), await e.mkdir("/tmp/sqlite-database-integration"), await
|
|
3520
|
-
const
|
|
3521
|
-
await e.mv(s,
|
|
3522
|
-
const r =
|
|
3523
|
-
|
|
3963
|
+
}), await e.mkdir("/tmp/sqlite-database-integration"), await g(e, n, "/tmp/sqlite-database-integration");
|
|
3964
|
+
const t = "/internal/shared/sqlite-database-integration", s = `/tmp/sqlite-database-integration/${(await e.listFiles("/tmp/sqlite-database-integration"))[0]}`;
|
|
3965
|
+
await e.mv(s, t);
|
|
3966
|
+
const r = a(
|
|
3967
|
+
t,
|
|
3524
3968
|
"wp-includes/sqlite/class-wp-sqlite-db.php"
|
|
3525
3969
|
);
|
|
3526
3970
|
if (await e.fileExists(r)) {
|
|
3527
|
-
const
|
|
3971
|
+
const f = await e.readFileAsText(r), $ = f.replace(
|
|
3528
3972
|
"private $allow_unsafe_unquoted_parameters",
|
|
3529
3973
|
"protected $allow_unsafe_unquoted_parameters"
|
|
3530
3974
|
);
|
|
3531
|
-
|
|
3975
|
+
$ !== f && await e.writeFile(r, $);
|
|
3532
3976
|
}
|
|
3533
3977
|
await e.defineConstant("SQLITE_MAIN_FILE", "1");
|
|
3534
|
-
const
|
|
3535
|
-
|
|
3978
|
+
const _ = (await e.readFileAsText(
|
|
3979
|
+
a(t, "db.copy")
|
|
3536
3980
|
)).replace(
|
|
3537
3981
|
"'{SQLITE_IMPLEMENTATION_FOLDER_PATH}'",
|
|
3538
|
-
|
|
3982
|
+
p(t)
|
|
3539
3983
|
).replace(
|
|
3540
3984
|
"'{SQLITE_PLUGIN}'",
|
|
3541
|
-
|
|
3542
|
-
), l =
|
|
3985
|
+
p(a(t, "load.php"))
|
|
3986
|
+
), l = a(await e.documentRoot, "wp-content/db.php"), c = `<?php
|
|
3543
3987
|
// Do not preload this if WordPress comes with a custom db.php file.
|
|
3544
|
-
if(file_exists(${
|
|
3988
|
+
if(file_exists(${p(l)})) {
|
|
3545
3989
|
return;
|
|
3546
3990
|
}
|
|
3547
3991
|
?>`, u = "/internal/shared/mu-plugins/sqlite-database-integration.php";
|
|
3548
|
-
await e.writeFile(u, c +
|
|
3992
|
+
await e.writeFile(u, c + _), await e.writeFile(
|
|
3549
3993
|
"/internal/shared/preload/0-sqlite.php",
|
|
3550
|
-
|
|
3994
|
+
ft(c, u)
|
|
3551
3995
|
), await e.writeFile(
|
|
3552
3996
|
"/internal/shared/mu-plugins/sqlite-test.php",
|
|
3553
3997
|
`<?php
|
|
@@ -3559,104 +4003,104 @@ async function I(e, t, i = {}) {
|
|
|
3559
4003
|
`
|
|
3560
4004
|
);
|
|
3561
4005
|
}
|
|
3562
|
-
function
|
|
4006
|
+
function ft(e, n) {
|
|
3563
4007
|
return e + `<?php
|
|
3564
4008
|
|
|
3565
|
-
${
|
|
4009
|
+
${S(`require_once ${p(n)};`)}
|
|
3566
4010
|
if(!function_exists('mysqli_connect')) {
|
|
3567
4011
|
function mysqli_connect() {}
|
|
3568
4012
|
}
|
|
3569
4013
|
|
|
3570
4014
|
`;
|
|
3571
4015
|
}
|
|
3572
|
-
async function
|
|
3573
|
-
e.mkdir("/tmp/unzipped-wordpress"), await
|
|
4016
|
+
async function q(e, n) {
|
|
4017
|
+
e.mkdir("/tmp/unzipped-wordpress"), await g(e, n, "/tmp/unzipped-wordpress"), e.fileExists("/tmp/unzipped-wordpress/wordpress.zip") && await g(
|
|
3574
4018
|
e,
|
|
3575
4019
|
"/tmp/unzipped-wordpress/wordpress.zip",
|
|
3576
4020
|
"/tmp/unzipped-wordpress"
|
|
3577
4021
|
);
|
|
3578
4022
|
let i = e.fileExists("/tmp/unzipped-wordpress/wordpress") ? "/tmp/unzipped-wordpress/wordpress" : e.fileExists("/tmp/unzipped-wordpress/build") ? "/tmp/unzipped-wordpress/build" : "/tmp/unzipped-wordpress";
|
|
3579
|
-
if (!e.fileExists(
|
|
4023
|
+
if (!e.fileExists(a(i, "wp-config-sample.php"))) {
|
|
3580
4024
|
const s = e.listFiles(i);
|
|
3581
4025
|
if (s.length) {
|
|
3582
4026
|
const r = s[0];
|
|
3583
4027
|
e.fileExists(
|
|
3584
|
-
|
|
3585
|
-
) && (i =
|
|
4028
|
+
a(i, r, "wp-config-sample.php")
|
|
4029
|
+
) && (i = a(i, r));
|
|
3586
4030
|
}
|
|
3587
4031
|
}
|
|
3588
|
-
const
|
|
3589
|
-
if (
|
|
3590
|
-
for (const
|
|
3591
|
-
const l =
|
|
3592
|
-
|
|
4032
|
+
const t = (s, r, o) => {
|
|
4033
|
+
if (o.isDir(s) && o.isDir(r))
|
|
4034
|
+
for (const _ of o.listFiles(s)) {
|
|
4035
|
+
const l = a(s, _), c = a(r, _);
|
|
4036
|
+
t(l, c, o);
|
|
3593
4037
|
}
|
|
3594
4038
|
else {
|
|
3595
|
-
if (
|
|
3596
|
-
const
|
|
4039
|
+
if (o.fileExists(r)) {
|
|
4040
|
+
const _ = s.replace(
|
|
3597
4041
|
/^\/tmp\/unzipped-wordpress\//,
|
|
3598
4042
|
"/"
|
|
3599
4043
|
);
|
|
3600
|
-
|
|
3601
|
-
`Cannot unzip WordPress files at ${r}: ${
|
|
4044
|
+
d.warn(
|
|
4045
|
+
`Cannot unzip WordPress files at ${r}: ${_} already exists.`
|
|
3602
4046
|
);
|
|
3603
4047
|
return;
|
|
3604
4048
|
}
|
|
3605
|
-
|
|
4049
|
+
o.mv(s, r);
|
|
3606
4050
|
}
|
|
3607
4051
|
};
|
|
3608
|
-
|
|
3609
|
-
|
|
4052
|
+
t(i, e.documentRoot, e), e.fileExists(i) && e.rmdir(i, { recursive: !0 }), !e.fileExists(a(e.documentRoot, "wp-config.php")) && e.fileExists(a(e.documentRoot, "wp-config-sample.php")) && e.writeFile(
|
|
4053
|
+
a(e.documentRoot, "wp-config.php"),
|
|
3610
4054
|
e.readFileAsText(
|
|
3611
|
-
|
|
4055
|
+
a(e.documentRoot, "/wp-config-sample.php")
|
|
3612
4056
|
)
|
|
3613
4057
|
);
|
|
3614
4058
|
}
|
|
3615
|
-
const
|
|
3616
|
-
async function
|
|
4059
|
+
const $t = X(fetch), ht = "https://github.com/WordPress/WordPress/archive/refs/heads/master.zip";
|
|
4060
|
+
async function bt(e = "latest") {
|
|
3617
4061
|
if (e === null)
|
|
3618
4062
|
e = "latest";
|
|
3619
4063
|
else if (e.startsWith("https://") || e.startsWith("http://")) {
|
|
3620
|
-
const
|
|
4064
|
+
const t = await crypto.subtle.digest(
|
|
3621
4065
|
"SHA-1",
|
|
3622
4066
|
new TextEncoder().encode(e)
|
|
3623
|
-
), s = Array.from(new Uint8Array(
|
|
4067
|
+
), s = Array.from(new Uint8Array(t)).map((r) => r.toString(16).padStart(2, "0")).join("");
|
|
3624
4068
|
return {
|
|
3625
4069
|
releaseUrl: e,
|
|
3626
4070
|
version: "custom-" + s.substring(0, 8),
|
|
3627
4071
|
source: "inferred"
|
|
3628
4072
|
};
|
|
3629
4073
|
} else if (e === "trunk" || e === "nightly") {
|
|
3630
|
-
const
|
|
4074
|
+
const t = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
3631
4075
|
return {
|
|
3632
|
-
releaseUrl: `${
|
|
4076
|
+
releaseUrl: `${ht}?ts=${t}`,
|
|
3633
4077
|
version: "trunk",
|
|
3634
4078
|
source: "inferred"
|
|
3635
4079
|
};
|
|
3636
4080
|
}
|
|
3637
|
-
let i = await (await
|
|
4081
|
+
let i = await (await $t(
|
|
3638
4082
|
"https://api.wordpress.org/core/version-check/1.7/?channel=beta"
|
|
3639
4083
|
)).json();
|
|
3640
4084
|
i = i.offers.filter(
|
|
3641
|
-
(
|
|
4085
|
+
(t) => t.response === "autoupdate"
|
|
3642
4086
|
);
|
|
3643
|
-
for (const
|
|
3644
|
-
if (e === "beta" && (
|
|
4087
|
+
for (const t of i) {
|
|
4088
|
+
if (e === "beta" && (t.version.includes("beta") || t.version.includes("RC")))
|
|
3645
4089
|
return {
|
|
3646
|
-
releaseUrl:
|
|
3647
|
-
version:
|
|
4090
|
+
releaseUrl: t.download,
|
|
4091
|
+
version: t.version,
|
|
3648
4092
|
source: "api"
|
|
3649
4093
|
};
|
|
3650
|
-
if (e === "latest" && !
|
|
4094
|
+
if (e === "latest" && !t.version.includes("beta") && !t.version.includes("RC"))
|
|
3651
4095
|
return {
|
|
3652
|
-
releaseUrl:
|
|
3653
|
-
version:
|
|
4096
|
+
releaseUrl: t.download,
|
|
4097
|
+
version: t.version,
|
|
3654
4098
|
source: "api"
|
|
3655
4099
|
};
|
|
3656
|
-
if (
|
|
4100
|
+
if (t.version.substring(0, e.length) === e)
|
|
3657
4101
|
return {
|
|
3658
|
-
releaseUrl:
|
|
3659
|
-
version:
|
|
4102
|
+
releaseUrl: t.download,
|
|
4103
|
+
version: t.version,
|
|
3660
4104
|
source: "api"
|
|
3661
4105
|
};
|
|
3662
4106
|
}
|
|
@@ -3667,19 +4111,19 @@ async function ot(e = "latest") {
|
|
|
3667
4111
|
};
|
|
3668
4112
|
}
|
|
3669
4113
|
export {
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
4114
|
+
ot as bootRequestHandler,
|
|
4115
|
+
at as bootWordPress,
|
|
4116
|
+
yt as bootWordPressAndRequestHandler,
|
|
4117
|
+
Lt as defineWpConfigConstants,
|
|
4118
|
+
Ke as ensureWpConfig,
|
|
4119
|
+
_t as getFileNotFoundActionForWordPress,
|
|
4120
|
+
Ot as getLoadedWordPressVersion,
|
|
4121
|
+
dt as preloadPhpInfoRoute,
|
|
4122
|
+
C as preloadSqliteIntegration,
|
|
4123
|
+
bt as resolveWordPressRelease,
|
|
4124
|
+
pt as setupPlatformLevelMuPlugins,
|
|
4125
|
+
q as unzipWordPress,
|
|
4126
|
+
ct as versionStringToLoadedWordPressVersion,
|
|
4127
|
+
ut as wordPressRewriteRules
|
|
3684
4128
|
};
|
|
3685
4129
|
//# sourceMappingURL=index.js.map
|