diff --git a/README.md b/README.md index 6c2c806e52..2566481b53 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ git clone https://github.com/php/web-php.git Change into `web-php`: ``` -cd web-php +cd web-php/public ``` Start the built-in web server: diff --git a/bin/createReleaseEntry b/bin/createReleaseEntry index a9dcf1e658..ca51982fe6 100755 --- a/bin/createReleaseEntry +++ b/bin/createReleaseEntry @@ -57,7 +57,7 @@ if (isset($opts['r'])) { $release = strtr($version, '.', '_') . '.php'; file_put_contents(RELEASES_ABS . $release, "

PHP $version Release Announcement

diff --git a/include/do-download.inc b/include/do-download.inc index b31f763b2c..06bb2b9798 100644 --- a/include/do-download.inc +++ b/include/do-download.inc @@ -6,6 +6,8 @@ we would like to know about (PHP binary or source). */ +use phpweb\ProjectGlobals; + function get_actual_download_file($file) { // Could be a normal download or a manual download file @@ -14,7 +16,7 @@ function get_actual_download_file($file) // Find out what is the exact file requested $found = false; foreach ($possible_files as $name => $log) { - if (@file_exists($_SERVER['DOCUMENT_ROOT'] . '/distributions/' . $name)) { + if (@file_exists(ProjectGlobals::getPublicRoot() . '/distributions/' . $name)) { $found = $name; break; } diff --git a/include/errors.inc b/include/errors.inc index 6bc9cf6c74..b21a75d780 100644 --- a/include/errors.inc +++ b/include/errors.inc @@ -6,6 +6,7 @@ */ use phpweb\I18n\Languages; +use phpweb\ProjectGlobals; // A 'good looking' 404 error message page function error_404(): void @@ -578,7 +579,7 @@ function is_known_snippet(string $term): ?string { */ function get_legacy_manual_urls(string $uri): array { - $filename = $_SERVER["DOCUMENT_ROOT"] . "/manual/legacyurls.json"; + $filename = ProjectGlobals::getPublicRoot() . "/manual/legacyurls.json"; $pages_ids = json_decode(file_get_contents($filename), true); $page_id = preg_replace_callback('/^manual\/[a-z_A-Z]+\/(.*?)(\.php)?$/', function (array $matches): string { if (count($matches) < 2) { diff --git a/include/get-download.inc b/include/get-download.inc index 2aeb1aa896..78abe3cb59 100644 --- a/include/get-download.inc +++ b/include/get-download.inc @@ -1,5 +1,7 @@ \n"; doc_toc_list($lang, $TOC, "getting-started"); @@ -611,7 +612,7 @@ function doc_toc($lang): void { } function doc_toc_list($lang, $index, $file): void { - include __DIR__ . "/../manual/$lang/toc/$file.inc"; + include ProjectGlobals::getPublicRoot() . "/manual/$lang/toc/$file.inc"; doc_toc_title($lang, $index, $file); foreach ($TOC as $entry) { diff --git a/include/manual-lookup.inc b/include/manual-lookup.inc index 9d3ff4d141..f12c9a3ce5 100644 --- a/include/manual-lookup.inc +++ b/include/manual-lookup.inc @@ -1,7 +1,9 @@ true, PDO::ATTR_EMULATE_PREPARES => true] ); + $dbh = new PDO( 'sqlite:' . ProjectGlobals::getProjectRoot() . '/backend/manual-lookup.sqlite', '', '', [PDO::ATTR_PERSISTENT => true, PDO::ATTR_EMULATE_PREPARES => true] ); } catch (PDOException $e) { return find_manual_page_slow($lang, $keyword); } @@ -204,7 +206,7 @@ function find_manual_page($lang, $keyword) // But does the file really exist? // @todo consider redirecting here, instead of including content within the 404 // @todo considering the file path is generated from the manual build, we can probably remove this file_exists() check - if (file_exists($_SERVER["DOCUMENT_ROOT"] . $r[0])) { + if (file_exists(ProjectGlobals::getPublicRoot() . $r[0])) { return $r[0]; } } diff --git a/include/shared-manual.inc b/include/shared-manual.inc index 821b2704ba..2d88477b1b 100644 --- a/include/shared-manual.inc +++ b/include/shared-manual.inc @@ -23,6 +23,7 @@ $PGI = []; $SIDEBAR_DATA = ''; // ============================================================================= use phpweb\I18n\Languages; +use phpweb\ProjectGlobals; use phpweb\UserNotes\Sorter; use phpweb\UserNotes\UserNote; @@ -35,7 +36,7 @@ function manual_notes($notes):void { global $LANG; // Get needed values - list($filename) = $GLOBALS['PGI']['this']; + [$filename] = $GLOBALS['PGI']['this']; // Drop file extension from the name if (substr($filename, -4) == '.php') { @@ -96,7 +97,7 @@ END_USERNOTE_HEADER; function manual_notes_load(string $id): array { $hash = substr(md5($id), 0, 16); - $notes_file = $_SERVER['DOCUMENT_ROOT'] . "/backend/notes/" . + $notes_file = ProjectGlobals::getPublicRoot() . "/backend/notes/" . substr($hash, 0, 2) . "/$hash"; // Open the note file for reading and get the data (12KB) @@ -140,7 +141,7 @@ function manual_note_display(UserNote $note, $voteOption = true): void // Vote User Notes Div if ($voteOption) { - list($redir_filename) = $GLOBALS['PGI']['this']; + [$redir_filename] = $GLOBALS['PGI']['this']; if (substr($redir_filename, -4) == '.php') { $redir_filename = substr($redir_filename, 0, -4); } @@ -286,9 +287,9 @@ function manual_setup($setup): void { $_SERVER['BASE_HREF'] = $MYSITE . $_SERVER['BASE_PAGE']; $timestamps = [ - filemtime($_SERVER["DOCUMENT_ROOT"] . "/" . $_SERVER["BASE_PAGE"]), - filemtime($_SERVER["DOCUMENT_ROOT"] . "/include/prepend.inc"), - filemtime($_SERVER["DOCUMENT_ROOT"] . "/styles/theme-base.css"), + filemtime(ProjectGlobals::getPublicRoot() . "/" . $_SERVER["BASE_PAGE"]), + filemtime(ProjectGlobals::getProjectRoot() . "/include/prepend.inc"), + filemtime(ProjectGlobals::getPublicRoot() . "/styles/theme-base.css"), ]; // Load user note for this page diff --git a/manual/index.php b/manual/index.php deleted file mode 100644 index 1a3a03c3ac..0000000000 --- a/manual/index.php +++ /dev/null @@ -1,4 +0,0 @@ -