Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion bin/createReleaseEntry
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ if (isset($opts['r'])) {
$release = strtr($version, '.', '_') . '.php';
file_put_contents(RELEASES_ABS . $release, "<?php
\$_SERVER['BASE_PAGE'] = 'releases/$release';
include_once __DIR__ . '/../include/prepend.inc';
require_once __DIR__ . '/../../include/prepend.inc';
site_header('PHP $version Release Announcement');
?>
<h1>PHP $version Release Announcement</h1>
Expand Down
4 changes: 3 additions & 1 deletion include/do-download.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion include/errors.inc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

use phpweb\I18n\Languages;
use phpweb\ProjectGlobals;

// A 'good looking' 404 error message page
function error_404(): void
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 4 additions & 2 deletions include/get-download.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php
// Try to make this page non-cached
use phpweb\ProjectGlobals;

header_nocache();

// No file to download
Expand All @@ -18,7 +20,7 @@ $site_config = [
// Find out what is the exact file requested
$file = false;
foreach ($possible_files as $name) {
if (@file_exists($_SERVER['DOCUMENT_ROOT'] . '/distributions/' . $name)) {
if (@file_exists(ProjectGlobals::getPublicRoot() . '/distributions/' . $name)) {
$file = $name;
break;
}
Expand All @@ -41,7 +43,7 @@ if ($file === false) {
EOT;
} else {
// Set local file name
$local_file = $_SERVER['DOCUMENT_ROOT'] . '/distributions/' . $file;
$local_file = ProjectGlobals::getPublicRoot() . '/distributions/' . $file;
// Try to get filesize to display
$size = @filesize($local_file);
}
Expand Down
5 changes: 4 additions & 1 deletion include/header.inc
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

use phpweb\ProjectGlobals;

$css_files = [
'/fonts/Fira/fira.css',
'/fonts/Font-Awesome/css/fontello.css',
Expand Down Expand Up @@ -39,7 +42,7 @@ if ($config["cache"]) {
if (is_numeric($config["cache"])) {
$timestamp = $config["cache"];
} else {
$timestamp = filemtime($_SERVER["DOCUMENT_ROOT"] . "/" . $_SERVER["BASE_PAGE"]);
$timestamp = filemtime(ProjectGlobals::getPublicRoot() . "/" . $_SERVER["BASE_PAGE"]);
}
$tsstring = gmdate("D, d M Y H:i:s ", $timestamp) . "GMT";

Expand Down
11 changes: 6 additions & 5 deletions include/layout.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use phpweb\I18n\Languages;
use phpweb\Navigation\NavItem;
use phpweb\News\NewsHandler;
use phpweb\ProjectGlobals;

$_SERVER['STATIC_ROOT'] = $MYSITE;
$_SERVER['MYSITE'] = $MYSITE;
Expand Down Expand Up @@ -95,7 +96,7 @@ function make_image($file, $alt = false, $align = false, $extras = false,
$webdir = $_SERVER['MYSITE'] . ($dir[0] == '/' ? '' : '/') . $dir;

// Get width and height values if possible
if ($addsize && ($size = @getimagesize($_SERVER['DOCUMENT_ROOT'] . "$dir/$file"))) {
if ($addsize && ($size = @getimagesize(ProjectGlobals::getPublicRoot() . "$dir/$file"))) {
$sizeparams = ' ' . trim($size[3]);
} else {
$sizeparams = '';
Expand Down Expand Up @@ -564,12 +565,12 @@ function get_news_changes()
}

function doc_toc($lang): void {
$file = __DIR__ . "/../manual/$lang/toc/index.inc";
$file = ProjectGlobals::getPublicRoot() . "/manual/$lang/toc/index.inc";
if (!file_exists($file)) {
$lang = "en"; // Fallback on English if the translation doesn't exist
$file = __DIR__ . "/../manual/en/toc/index.inc";
$file = ProjectGlobals::getPublicRoot() . "/manual/en/toc/index.inc";
}
require __DIR__ . "/../manual/$lang/toc/index.inc";
require ProjectGlobals::getPublicRoot() . "/manual/$lang/toc/index.inc";

echo "<dl>\n";
doc_toc_list($lang, $TOC, "getting-started");
Expand Down Expand Up @@ -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) {
Expand Down
22 changes: 12 additions & 10 deletions include/manual-lookup.inc
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

// We need this for error reporting
include_once __DIR__ . '/errors.inc';
use phpweb\ProjectGlobals;

require_once __DIR__ . '/errors.inc';

// Try to find some variations of keyword with $prefix in the $lang manual
function tryprefix($lang, $keyword, $prefix)
Expand All @@ -14,35 +16,35 @@ function tryprefix($lang, $keyword, $prefix)

// Try the keyword with the prefix
$try = "/manual/{$lang}/{$prefix}{$keyword}.php";
if (@file_exists($_SERVER['DOCUMENT_ROOT'] . $try)) { return $try; }
if (@file_exists(ProjectGlobals::getPublicRoot() . $try)) { return $try; }

// Drop out spaces, and try that keyword (if different)
$nosp = str_replace(" ", "", $keyword);
if ($nosp != $keyword) {
$try = "/manual/{$lang}/{$prefix}{$nosp}.php";
if (@file_exists($_SERVER['DOCUMENT_ROOT'] . $try)) { return $try; }
if (@file_exists(ProjectGlobals::getPublicRoot() . $try)) { return $try; }
}

// Replace spaces with hyphens, and try that (if different)
$dasp = str_replace(" ", "-", $keyword);
if ($dasp != $keyword) {
$try = "/manual/{$lang}/{$prefix}{$dasp}.php";
if (@file_exists($_SERVER['DOCUMENT_ROOT'] . $try)) { return $try; }
if (@file_exists(ProjectGlobals::getPublicRoot() . $try)) { return $try; }
}

// Remove hyphens (and underscores), and try that (if different)
$noul = str_replace("-", "", $keyword);
if ($noul != $keyword) {
$try = "/manual/{$lang}/{$prefix}{$noul}.php";
if (@file_exists($_SERVER['DOCUMENT_ROOT'] . $try)) { return $try; }
if (@file_exists(ProjectGlobals::getPublicRoot() . $try)) { return $try; }
}

// urldecode() (%5C == \) Replace namespace sperators, and try that (if different)
$keyword = urldecode($keyword);
$noul = str_replace("\\", "-", $keyword);
if ($noul != $keyword) {
$try = "/manual/{$lang}/{$prefix}{$noul}.php";
if (@file_exists($_SERVER['DOCUMENT_ROOT'] . $try)) { return $try; }
if (@file_exists(ProjectGlobals::getPublicRoot() . $try)) { return $try; }
}

// Replace first - with a dot and try that (for mysqli_ type entries)
Expand All @@ -53,7 +55,7 @@ function tryprefix($lang, $keyword, $prefix)
$keyword[$pos] = '.';

$try = "/manual/{$lang}/{$prefix}{$keyword}.php";
if (@file_exists($_SERVER['DOCUMENT_ROOT'] . $try)) { return $try; }
if (@file_exists(ProjectGlobals::getPublicRoot() . $try)) { return $try; }
}
}

Expand Down Expand Up @@ -108,9 +110,9 @@ function find_manual_page($lang, $keyword)
$dbh = false;
if (class_exists('PDO')) {
if (in_array('sqlite', PDO::getAvailableDrivers(), true)) {
if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/backend/manual-lookup.sqlite')) {
if (file_exists(ProjectGlobals::getProjectRoot() . '/backend/manual-lookup.sqlite')) {
try {
$dbh = new PDO( 'sqlite:' . $_SERVER['DOCUMENT_ROOT'] . '/backend/manual-lookup.sqlite', '', '', [PDO::ATTR_PERSISTENT => 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);
}
Expand Down Expand Up @@ -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];
}
}
Expand Down
13 changes: 7 additions & 6 deletions include/shared-manual.inc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ $PGI = []; $SIDEBAR_DATA = '';
// =============================================================================

use phpweb\I18n\Languages;
use phpweb\ProjectGlobals;
use phpweb\UserNotes\Sorter;
use phpweb\UserNotes\UserNote;

Expand All @@ -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') {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions manual/index.php

This file was deleted.

File renamed without changes.
6 changes: 5 additions & 1 deletion .router.php → public/.router.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<?php

use phpweb\ProjectGlobals;

require_once __DIR__ . '/../src/ProjectGlobals.php';

$_SERVER["SERVER_ADDR"] = $_SERVER["HTTP_HOST"];

$filename = $_SERVER["PATH_INFO"] ?? $_SERVER["SCRIPT_NAME"];

if (!file_exists($_SERVER["DOCUMENT_ROOT"] . $filename)) {
if (!file_exists(ProjectGlobals::getPublicRoot() . $filename)) {
require_once __DIR__ . '/error.php';

return;
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions ChangeLog-4.php → public/ChangeLog-4.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
$_SERVER['BASE_PAGE'] = 'ChangeLog-4.php';
include_once __DIR__ . '/include/prepend.inc';
include_once __DIR__ . '/include/changelogs.inc';
require_once __DIR__ . '/../include/prepend.inc';
require_once __DIR__ . '/../include/changelogs.inc';

$MINOR_VERSIONS = ['4.4', '4.3', '4.2', '4.1', '4.0'];
changelog_header(4, $MINOR_VERSIONS);
Expand Down
6 changes: 3 additions & 3 deletions ChangeLog-5.php → public/ChangeLog-5.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
$_SERVER['BASE_PAGE'] = 'ChangeLog-5.php';
include_once __DIR__ . '/include/prepend.inc';
include_once __DIR__ . '/include/changelogs.inc';
require_once __DIR__ . '/../include/prepend.inc';
require_once __DIR__ . '/../include/changelogs.inc';

$MINOR_VERSIONS = ['5.6', '5.5', '5.4', '5.3', '5.2', '5.1', '5.0'];
changelog_header(5, $MINOR_VERSIONS);
Expand All @@ -12,7 +12,7 @@
<b><?php release_date('10-Jan-2019'); ?></b>
<ul><li>GD:
<ul>
<li><?php bugfix(77269); ?> (efree() on uninitialized Heap data in imagescale leads to
<li><?php bugfix(77269); ?> (efree() on uninitialized Heap data in imagescale leads to
use-after-free). (CVE-2016-10166)</li>
<li><?php bugfix(77270); ?> (imagecolormatch Out Of Bounds Write on Heap). (CVE-2019-6977)</li>
</ul></li>
Expand Down
4 changes: 2 additions & 2 deletions ChangeLog-7.php → public/ChangeLog-7.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
$_SERVER['BASE_PAGE'] = 'ChangeLog-7.php';
include_once __DIR__ . '/include/prepend.inc';
include_once __DIR__ . '/include/changelogs.inc';
require_once __DIR__ . '/../include/prepend.inc';
require_once __DIR__ . '/../include/changelogs.inc';

$MINOR_VERSIONS = ['7.4', '7.3', '7.2', '7.1', '7.0'];
changelog_header(7, $MINOR_VERSIONS);
Expand Down
4 changes: 2 additions & 2 deletions ChangeLog-8.php → public/ChangeLog-8.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
$_SERVER['BASE_PAGE'] = 'ChangeLog-8.php';
include_once __DIR__ . '/include/prepend.inc';
include_once __DIR__ . '/include/changelogs.inc';
require_once __DIR__ . '/../include/prepend.inc';
require_once __DIR__ . '/../include/changelogs.inc';

$MINOR_VERSIONS = ['8.5', '8.4', '8.3', '8.2', '8.1', '8.0'];
changelog_header(8, $MINOR_VERSIONS);
Expand Down
2 changes: 1 addition & 1 deletion archive/1998.php → public/archive/1998.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
$_SERVER['BASE_PAGE'] = 'archive/1998.php';
include_once __DIR__ . '/../include/prepend.inc';
require_once __DIR__ . '/../../include/prepend.inc';
news_archive_sidebar();
site_header("News Archive - 1998", ["cache" => true]);
?>
Expand Down
2 changes: 1 addition & 1 deletion archive/1999.php → public/archive/1999.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
$_SERVER['BASE_PAGE'] = 'archive/1999.php';
include_once __DIR__ . '/../include/prepend.inc';
require_once __DIR__ . '/../../include/prepend.inc';
news_archive_sidebar();
site_header("News Archive - 1999", ["cache" => true]);
?>
Expand Down
4 changes: 2 additions & 2 deletions archive/2000.php → public/archive/2000.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
$_SERVER['BASE_PAGE'] = 'archive/2000.php';
include_once __DIR__ . '/../include/prepend.inc';
require_once __DIR__ . '/../../include/prepend.inc';
news_archive_sidebar();
site_header("News Archive - 2000", ["cache" => true]);
?>
Expand All @@ -19,7 +19,7 @@
This release includes improvements for a large number of defects
and numerous enhancements in the PHP core, the language implementation and
extensions. <a href="/downloads.php">Download</a>,
<a href="ChangeLog-4.php#4.0.4">ChangeLog</a>.
<a href="../ChangeLog-4.php#4.0.4">ChangeLog</a>.
</p>

<hr>
Expand Down
2 changes: 1 addition & 1 deletion archive/2001.php → public/archive/2001.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
$_SERVER['BASE_PAGE'] = 'archive/2001.php';
include_once __DIR__ . '/../include/prepend.inc';
require_once __DIR__ . '/../../include/prepend.inc';
news_archive_sidebar();
site_header("News Archive - 2001", ["cache" => true]);
?>
Expand Down
Loading