mirror of
https://github.com/joomla/joomla-cms.git
synced 2024-06-29 00:23:41 +00:00
[5.0] Allow Joomla be served from a public* folder (#40509)
--------- Signed-off-by: Dimitris Grammatikogiannis <dg@dgrammatiko.dev> Co-authored-by: Harald Leithner <leithner@itronic.at>
This commit is contained in:
parent
aa5b197986
commit
12a1274d58
|
@ -22,9 +22,13 @@ if (!defined('_JDEFINES')) {
|
|||
require_once JPATH_BASE . '/includes/defines.php';
|
||||
}
|
||||
|
||||
if (!defined('JPATH_PUBLIC')) {
|
||||
define('JPATH_PUBLIC', JPATH_ROOT);
|
||||
}
|
||||
|
||||
// Check for presence of vendor dependencies not included in the git repository
|
||||
if (!file_exists(JPATH_LIBRARIES . '/vendor/autoload.php') || !is_dir(JPATH_ROOT . '/media/vendor')) {
|
||||
echo file_get_contents(JPATH_ROOT . '/templates/system/build_incomplete.html');
|
||||
if (!file_exists(JPATH_LIBRARIES . '/vendor/autoload.php') || !is_dir(JPATH_PUBLIC . '/media/vendor')) {
|
||||
echo file_get_contents(JPATH_BASE . '/templates/system/build_incomplete.html');
|
||||
|
||||
exit;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ array_pop($parts);
|
|||
// Defines
|
||||
define('JPATH_ROOT', implode(DIRECTORY_SEPARATOR, $parts));
|
||||
define('JPATH_SITE', JPATH_ROOT);
|
||||
define('JPATH_PUBLIC', JPATH_ROOT);
|
||||
define('JPATH_CONFIGURATION', JPATH_ROOT);
|
||||
define('JPATH_ADMINISTRATOR', JPATH_ROOT . DIRECTORY_SEPARATOR . 'administrator');
|
||||
define('JPATH_LIBRARIES', JPATH_ROOT . DIRECTORY_SEPARATOR . 'libraries');
|
||||
|
|
|
@ -22,7 +22,11 @@ if (
|
|||
|| (file_exists(JPATH_INSTALLATION . '/index.php') && (false === (new Version())->isInDevelopmentState()))
|
||||
) {
|
||||
if (file_exists(JPATH_INSTALLATION . '/index.php')) {
|
||||
header('Location: ../installation/index.php');
|
||||
if (JPATH_ROOT === JPATH_PUBLIC) {
|
||||
header('Location: ../installation/index.php');
|
||||
} else {
|
||||
echo 'Installation from a public folder is not supported, revert your Server configuration to point at the Joomla\'s root folder to continue.';
|
||||
}
|
||||
|
||||
exit();
|
||||
} else {
|
||||
|
|
|
@ -17,7 +17,7 @@ if (version_compare(PHP_VERSION, JOOMLA_MINIMUM_PHP, '<')) {
|
|||
str_replace(
|
||||
'{{phpversion}}',
|
||||
JOOMLA_MINIMUM_PHP,
|
||||
file_get_contents(dirname(__FILE__) . '/../templates/system/incompatible.html')
|
||||
file_get_contents(dirname(dirname(__FILE__)) . '/includes/incompatible.html')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,10 @@ if (!defined('_JDEFINES')) {
|
|||
require_once JPATH_BASE . '/includes/defines.php';
|
||||
}
|
||||
|
||||
if (!defined('JPATH_PUBLIC')) {
|
||||
define('JPATH_PUBLIC', JPATH_ROOT);
|
||||
}
|
||||
|
||||
require_once JPATH_BASE . '/includes/framework.php';
|
||||
|
||||
// Set profiler start time and memory usage and mark afterLoad in the profiler.
|
||||
|
|
|
@ -16,6 +16,7 @@ array_pop($parts);
|
|||
// Defines.
|
||||
define('JPATH_ROOT', implode(DIRECTORY_SEPARATOR, $parts));
|
||||
define('JPATH_SITE', JPATH_ROOT);
|
||||
define('JPATH_PUBLIC', JPATH_ROOT);
|
||||
define('JPATH_CONFIGURATION', JPATH_ROOT);
|
||||
define('JPATH_ADMINISTRATOR', JPATH_ROOT . DIRECTORY_SEPARATOR . 'administrator');
|
||||
define('JPATH_LIBRARIES', JPATH_ROOT . DIRECTORY_SEPARATOR . 'libraries');
|
||||
|
|
|
@ -147,14 +147,12 @@ module.exports.createErrorPages = async (options) => {
|
|||
await mkdir(dirname(`${RootPath}${options.settings.errorPages[name].destFile}`), { recursive: true, mode: 0o755 });
|
||||
}
|
||||
|
||||
await writeFile(
|
||||
`${RootPath}${options.settings.errorPages[name].destFile}`,
|
||||
template,
|
||||
{ encoding: 'utf8', mode: 0o644 },
|
||||
);
|
||||
options.settings.errorPages[name].destFile.forEach(async (folder) => {
|
||||
await writeFile(`${RootPath}${folder}`, template, { encoding: 'utf8', mode: 0o644 });
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(`✅ Created the file: ${options.settings.errorPages[name].destFile}`);
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(`✅ Created the file: ${folder}`);
|
||||
});
|
||||
};
|
||||
|
||||
Object.keys(options.settings.errorPages).forEach((name) => processPages.push(processPage(name)));
|
||||
|
|
|
@ -798,7 +798,7 @@
|
|||
"text": "It looks like you are trying to run Joomla! from our git repository. To do so requires you complete a couple of extra steps first.",
|
||||
"link": "J4.x:Setting_Up_Your_Local_Environment",
|
||||
"linkText": "More Details",
|
||||
"destFile": "/templates/system/build_incomplete.html"
|
||||
"destFile": ["/templates/system/build_incomplete.html"]
|
||||
},
|
||||
"unsupported": {
|
||||
"title": "Joomla: unsupported PHP version",
|
||||
|
@ -806,7 +806,7 @@
|
|||
"text": "Your host needs to use PHP version {{phpversion}} or newer to run this version of Joomla!",
|
||||
"link": "J4.x:Unsupported_PHP_Version",
|
||||
"linkText": "Help me resolve this",
|
||||
"destFile": "/templates/system/incompatible.html"
|
||||
"destFile": ["/templates/system/incompatible.html", "/includes/incompatible.html"]
|
||||
},
|
||||
"noxml": {
|
||||
"title": "Joomla: Missing PHP-XML library",
|
||||
|
@ -814,7 +814,7 @@
|
|||
"text": "Your host needs to use PHP with support for the XML library to run this version of Joomla!",
|
||||
"link": "J4.x:Missing_XML_Library",
|
||||
"linkText": "Help me resolve this",
|
||||
"destFile": "/media/system/html/noxml.html"
|
||||
"destFile": ["/media/system/html/noxml.html"]
|
||||
},
|
||||
"fatal": {
|
||||
"title": "An Error Occurred: {{statusText}}",
|
||||
|
@ -822,7 +822,7 @@
|
|||
"text": "The server returned a \"{{statusCode_statusText}}\"",
|
||||
"link": "J4.x:FatalError",
|
||||
"linkText": "Help me resolve this",
|
||||
"destFile": "/templates/system/fatal-error.html"
|
||||
"destFile": ["/templates/system/fatal-error.html"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,10 @@ if (!file_exists(JPATH_LIBRARIES . '/vendor/autoload.php') || !is_dir(JPATH_ROOT
|
|||
exit;
|
||||
}
|
||||
|
||||
if (!defined('JPATH_PUBLIC')) {
|
||||
define('JPATH_PUBLIC', JPATH_ROOT);
|
||||
}
|
||||
|
||||
// Check if installed
|
||||
if (
|
||||
!file_exists(JPATH_CONFIGURATION . '/configuration.php')
|
||||
|
|
|
@ -22,9 +22,13 @@ if (!defined('_JDEFINES')) {
|
|||
require_once JPATH_BASE . '/includes/defines.php';
|
||||
}
|
||||
|
||||
if (!defined('JPATH_PUBLIC')) {
|
||||
define('JPATH_PUBLIC', JPATH_ROOT);
|
||||
}
|
||||
|
||||
// Check for presence of vendor dependencies not included in the git repository
|
||||
if (!file_exists(JPATH_LIBRARIES . '/vendor/autoload.php') || !is_dir(JPATH_ROOT . '/media/vendor')) {
|
||||
echo file_get_contents(JPATH_ROOT . '/templates/system/build_incomplete.html');
|
||||
if (!file_exists(JPATH_LIBRARIES . '/vendor/autoload.php') || !is_dir(JPATH_PUBLIC . '/media/vendor')) {
|
||||
echo file_get_contents(JPATH_BASE . '/templates/system/build_incomplete.html');
|
||||
|
||||
exit;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ $parts = explode(DIRECTORY_SEPARATOR, JPATH_BASE);
|
|||
define('JPATH_ROOT', implode(DIRECTORY_SEPARATOR, $parts));
|
||||
define('JPATH_SITE', JPATH_ROOT);
|
||||
define('JPATH_CONFIGURATION', JPATH_ROOT);
|
||||
define('JPATH_PUBLIC', JPATH_ROOT);
|
||||
define('JPATH_ADMINISTRATOR', JPATH_ROOT . DIRECTORY_SEPARATOR . 'administrator');
|
||||
define('JPATH_LIBRARIES', JPATH_ROOT . DIRECTORY_SEPARATOR . 'libraries');
|
||||
define('JPATH_PLUGINS', JPATH_ROOT . DIRECTORY_SEPARATOR . 'plugins');
|
||||
|
|
|
@ -22,7 +22,11 @@ if (
|
|||
|| (file_exists(JPATH_INSTALLATION . '/index.php') && (false === (new Version())->isInDevelopmentState()))
|
||||
) {
|
||||
if (file_exists(JPATH_INSTALLATION . '/index.php')) {
|
||||
header('Location: ' . substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], 'index.php')) . 'installation/index.php');
|
||||
if (JPATH_ROOT === JPATH_PUBLIC) {
|
||||
header('Location: ' . substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], 'index.php')) . 'installation/index.php');
|
||||
} else {
|
||||
echo 'Installation from a public folder is not supported, revert your Server configuration to point at the Joomla\'s root folder to continue.';
|
||||
}
|
||||
|
||||
exit;
|
||||
} else {
|
||||
|
|
38
includes/incompatible.html
Normal file
38
includes/incompatible.html
Normal file
File diff suppressed because one or more lines are too long
|
@ -17,7 +17,7 @@ if (version_compare(PHP_VERSION, JOOMLA_MINIMUM_PHP, '<')) {
|
|||
str_replace(
|
||||
'{{phpversion}}',
|
||||
JOOMLA_MINIMUM_PHP,
|
||||
file_get_contents(dirname(__FILE__) . '/templates/system/incompatible.html')
|
||||
file_get_contents(dirname(__FILE__) . '/includes/incompatible.html')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ array_pop($parts);
|
|||
// Defines
|
||||
define('JPATH_ROOT', implode(DIRECTORY_SEPARATOR, $parts));
|
||||
define('JPATH_SITE', JPATH_ROOT);
|
||||
define('JPATH_PUBLIC', JPATH_ROOT);
|
||||
define('JPATH_CONFIGURATION', JPATH_ROOT);
|
||||
define('JPATH_ADMINISTRATOR', JPATH_ROOT . DIRECTORY_SEPARATOR . 'administrator');
|
||||
define('JPATH_LIBRARIES', JPATH_ROOT . DIRECTORY_SEPARATOR . 'libraries');
|
||||
|
|
|
@ -401,7 +401,7 @@ abstract class HTMLHelper
|
|||
|
||||
if ($template->inheritable || !empty($template->parent)) {
|
||||
$client = $app->isClient('administrator') === true ? 'administrator' : 'site';
|
||||
$templaPath = JPATH_ROOT . "/media/templates/$client";
|
||||
$templaPath = JPATH_PUBLIC . "/media/templates/$client";
|
||||
}
|
||||
|
||||
// For each potential files
|
||||
|
@ -441,7 +441,7 @@ abstract class HTMLHelper
|
|||
list($element, $file) = explode('/', $file, 2);
|
||||
|
||||
// Try to deal with plugins group in the media folder
|
||||
$found = static::addFileToBuffer(JPATH_ROOT . "/media/$extension/$element/$folder/$file", $ext, $debugMode);
|
||||
$found = static::addFileToBuffer(JPATH_PUBLIC . "/media/$extension/$element/$folder/$file", $ext, $debugMode);
|
||||
|
||||
if (!empty($found)) {
|
||||
$includes[] = $found;
|
||||
|
@ -450,7 +450,7 @@ abstract class HTMLHelper
|
|||
}
|
||||
|
||||
// Try to deal with classical file in a media subfolder called element
|
||||
$found = static::addFileToBuffer(JPATH_ROOT . "/media/$extension/$folder/$element/$file", $ext, $debugMode);
|
||||
$found = static::addFileToBuffer(JPATH_PUBLIC . "/media/$extension/$folder/$element/$file", $ext, $debugMode);
|
||||
|
||||
if (!empty($found)) {
|
||||
$includes[] = $found;
|
||||
|
@ -477,7 +477,7 @@ abstract class HTMLHelper
|
|||
}
|
||||
} else {
|
||||
// Try to deal with system files in the media folder
|
||||
$found = static::addFileToBuffer(JPATH_ROOT . "/media/system/$folder/$element/$file", $ext, $debugMode);
|
||||
$found = static::addFileToBuffer(JPATH_PUBLIC . "/media/system/$folder/$element/$file", $ext, $debugMode);
|
||||
|
||||
if (!empty($found)) {
|
||||
$includes[] = $found;
|
||||
|
@ -487,7 +487,7 @@ abstract class HTMLHelper
|
|||
}
|
||||
} else {
|
||||
// Try to deal with files in the extension's media folder
|
||||
$found = static::addFileToBuffer(JPATH_ROOT . "/media/$extension/$folder/$file", $ext, $debugMode);
|
||||
$found = static::addFileToBuffer(JPATH_PUBLIC . "/media/$extension/$folder/$file", $ext, $debugMode);
|
||||
|
||||
if (!empty($found)) {
|
||||
$includes[] = $found;
|
||||
|
@ -524,7 +524,7 @@ abstract class HTMLHelper
|
|||
}
|
||||
|
||||
// Try to deal with system files in the media folder
|
||||
$found = static::addFileToBuffer(JPATH_ROOT . "/media/system/$folder/$file", $ext, $debugMode);
|
||||
$found = static::addFileToBuffer(JPATH_PUBLIC . "/media/system/$folder/$file", $ext, $debugMode);
|
||||
|
||||
if (!empty($found)) {
|
||||
$includes[] = $found;
|
||||
|
@ -534,7 +534,7 @@ abstract class HTMLHelper
|
|||
}
|
||||
} else {
|
||||
// Try to deal with system files in the media folder
|
||||
$found = static::addFileToBuffer(JPATH_ROOT . "/media/system/$folder/$file", $ext, $debugMode);
|
||||
$found = static::addFileToBuffer(JPATH_PUBLIC . "/media/system/$folder/$file", $ext, $debugMode);
|
||||
|
||||
if (!empty($found)) {
|
||||
$includes[] = $found;
|
||||
|
@ -558,7 +558,7 @@ abstract class HTMLHelper
|
|||
* This MD5SUM file must represent the signature of the folder content
|
||||
*/
|
||||
foreach ($files as $file) {
|
||||
$path = JPATH_ROOT . "/$file";
|
||||
$path = JPATH_PUBLIC . '/' . $file;
|
||||
|
||||
$found = static::addFileToBuffer($path, $ext, $debugMode);
|
||||
|
||||
|
@ -1209,7 +1209,7 @@ abstract class HTMLHelper
|
|||
*/
|
||||
protected static function convertToRelativePath($path)
|
||||
{
|
||||
$relativeFilePath = Uri::root(true) . str_replace(JPATH_ROOT, '', $path);
|
||||
$relativeFilePath = Uri::root(true) . str_replace(JPATH_PUBLIC, '', $path);
|
||||
|
||||
// On windows devices we need to replace "\" with "/" otherwise some browsers will not load the asset
|
||||
return str_replace(DIRECTORY_SEPARATOR, '/', $relativeFilePath);
|
||||
|
|
|
@ -35,6 +35,10 @@ if (!defined('JPATH_ROOT')) {
|
|||
define('JPATH_ROOT', JPATH_BASE);
|
||||
}
|
||||
|
||||
if (!defined('JPATH_PUBLIC')) {
|
||||
define('JPATH_PUBLIC', JPATH_ROOT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 4.4.0 will be removed in 6.0
|
||||
**/
|
||||
|
|
Loading…
Reference in New Issue
Block a user