mirror of
https://github.com/laravel/valet.git
synced 2026-02-04 08:10:07 +01:00
Apply fixes from StyleCI
This commit is contained in:
committed by
StyleCI Bot
parent
3a5d12e24d
commit
101abeae0e
@@ -48,10 +48,10 @@ public function isStaticFile($sitePath, $siteName, $uri)
|
||||
*/
|
||||
public function frontControllerPath($sitePath, $siteName, $uri)
|
||||
{
|
||||
$_SERVER['PHP_SELF'] = $uri;
|
||||
$_SERVER['PHP_SELF'] = $uri;
|
||||
$_SERVER['SERVER_ADDR'] = '127.0.0.1';
|
||||
$_SERVER['SERVER_NAME'] = $_SERVER['HTTP_HOST'];
|
||||
|
||||
|
||||
$dynamicCandidates = [
|
||||
$this->asActualFile($sitePath, $uri),
|
||||
$this->asPhpIndexFileInDirectory($sitePath, $uri),
|
||||
@@ -63,14 +63,15 @@ public function frontControllerPath($sitePath, $siteName, $uri)
|
||||
$_SERVER['SCRIPT_FILENAME'] = $candidate;
|
||||
$_SERVER['SCRIPT_NAME'] = str_replace($sitePath, '', $candidate);
|
||||
$_SERVER['DOCUMENT_ROOT'] = $sitePath;
|
||||
|
||||
return $candidate;
|
||||
}
|
||||
}
|
||||
|
||||
$fixedCandidatesAndDocroots = [
|
||||
$this->asRootPhpIndexFile($sitePath) => $sitePath,
|
||||
$this->asPublicPhpIndexFile($sitePath) => $sitePath . '/public',
|
||||
$this->asPublicHtmlIndexFile($sitePath) => $sitePath . '/public',
|
||||
$this->asPublicPhpIndexFile($sitePath) => $sitePath.'/public',
|
||||
$this->asPublicHtmlIndexFile($sitePath) => $sitePath.'/public',
|
||||
];
|
||||
|
||||
foreach ($fixedCandidatesAndDocroots as $candidate => $docroot) {
|
||||
@@ -78,6 +79,7 @@ public function frontControllerPath($sitePath, $siteName, $uri)
|
||||
$_SERVER['SCRIPT_FILENAME'] = $candidate;
|
||||
$_SERVER['SCRIPT_NAME'] = '/index.php';
|
||||
$_SERVER['DOCUMENT_ROOT'] = $docroot;
|
||||
|
||||
return $candidate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@ public function frontControllerPath($sitePath, $siteName, $uri)
|
||||
? $sitePath.'/web'.$this->forceTrailingSlash($uri).'/index.php'
|
||||
: $sitePath.'/web'.$uri;
|
||||
}
|
||||
|
||||
if($uri !== '/' && file_exists($sitePath.'/web'.$uri)) {
|
||||
|
||||
if ($uri !== '/' && file_exists($sitePath.'/web'.$uri)) {
|
||||
return $sitePath.'/web'.$uri;
|
||||
}
|
||||
|
||||
@@ -66,13 +66,14 @@ public function frontControllerPath($sitePath, $siteName, $uri)
|
||||
/**
|
||||
* Redirect to uri with trailing slash.
|
||||
*
|
||||
* @param string $uri
|
||||
* @param string $uri
|
||||
* @return string
|
||||
*/
|
||||
private function forceTrailingSlash($uri)
|
||||
{
|
||||
if (substr($uri, -1 * strlen('/wp/wp-admin')) == '/wp/wp-admin') {
|
||||
header('Location: '.$uri.'/'); die;
|
||||
header('Location: '.$uri.'/');
|
||||
exit;
|
||||
}
|
||||
|
||||
return $uri;
|
||||
|
||||
@@ -2,28 +2,28 @@
|
||||
|
||||
class Concrete5ValetDriver extends BasicValetDriver
|
||||
{
|
||||
|
||||
/**
|
||||
* If a concrete directory exists, it's probably c5
|
||||
* @param string $sitePath
|
||||
* @param string $siteName
|
||||
* @param string $uri
|
||||
* If a concrete directory exists, it's probably c5.
|
||||
*
|
||||
* @param string $sitePath
|
||||
* @param string $siteName
|
||||
* @param string $uri
|
||||
* @return bool
|
||||
*/
|
||||
public function serves($sitePath, $siteName, $uri)
|
||||
{
|
||||
return file_exists($sitePath . "/concrete/config/install/base");
|
||||
return file_exists($sitePath.'/concrete/config/install/base');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sitePath
|
||||
* @param string $siteName
|
||||
* @param string $uri
|
||||
* @param string $sitePath
|
||||
* @param string $siteName
|
||||
* @param string $uri
|
||||
* @return string
|
||||
*/
|
||||
public function frontControllerPath($sitePath, $siteName, $uri)
|
||||
{
|
||||
if (!getenv('CONCRETE5_ENV')) {
|
||||
if (! getenv('CONCRETE5_ENV')) {
|
||||
putenv('CONCRETE5_ENV=valet');
|
||||
}
|
||||
|
||||
@@ -35,14 +35,13 @@ public function frontControllerPath($sitePath, $siteName, $uri)
|
||||
$_SERVER['SCRIPT_FILENAME'] = $sitePath.$filename;
|
||||
$_SERVER['SCRIPT_NAME'] = $filename;
|
||||
|
||||
return $sitePath . $filename;
|
||||
return $sitePath.$filename;
|
||||
}
|
||||
}
|
||||
|
||||
$_SERVER['SCRIPT_FILENAME'] = $sitePath . '/index.php';
|
||||
$_SERVER['SCRIPT_FILENAME'] = $sitePath.'/index.php';
|
||||
$_SERVER['SCRIPT_NAME'] = '/index.php';
|
||||
|
||||
return $sitePath . '/index.php';
|
||||
return $sitePath.'/index.php';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@ public function serves($sitePath, $siteName, $uri)
|
||||
{
|
||||
$sitePath = $this->addSubdirectory($sitePath);
|
||||
|
||||
/**
|
||||
* /misc/drupal.js = Drupal 7
|
||||
* /core/lib/Drupal.php = Drupal 8
|
||||
*/
|
||||
if (file_exists($sitePath.'/misc/drupal.js') ||
|
||||
/**
|
||||
* /misc/drupal.js = Drupal 7
|
||||
* /core/lib/Drupal.php = Drupal 8.
|
||||
*/
|
||||
if (file_exists($sitePath.'/misc/drupal.js') ||
|
||||
file_exists($sitePath.'/core/lib/Drupal.php')) {
|
||||
return true;
|
||||
}
|
||||
@@ -57,8 +57,8 @@ public function frontControllerPath($sitePath, $siteName, $uri)
|
||||
{
|
||||
$sitePath = $this->addSubdirectory($sitePath);
|
||||
|
||||
if (!isset($_GET['q']) && !empty($uri) && $uri !== '/' && strpos($uri, '/jsonapi/') === false) {
|
||||
$_GET['q'] = $uri;
|
||||
if (! isset($_GET['q']) && ! empty($uri) && $uri !== '/' && strpos($uri, '/jsonapi/') === false) {
|
||||
$_GET['q'] = $uri;
|
||||
}
|
||||
|
||||
$matches = [];
|
||||
@@ -67,6 +67,7 @@ public function frontControllerPath($sitePath, $siteName, $uri)
|
||||
if (file_exists($sitePath.$filename) && ! is_dir($sitePath.$filename)) {
|
||||
$_SERVER['SCRIPT_FILENAME'] = $sitePath.$filename;
|
||||
$_SERVER['SCRIPT_NAME'] = $filename;
|
||||
|
||||
return $sitePath.$filename;
|
||||
}
|
||||
}
|
||||
@@ -74,6 +75,7 @@ public function frontControllerPath($sitePath, $siteName, $uri)
|
||||
// Fallback
|
||||
$_SERVER['SCRIPT_FILENAME'] = $sitePath.'/index.php';
|
||||
$_SERVER['SCRIPT_NAME'] = '/index.php';
|
||||
|
||||
return $sitePath.'/index.php';
|
||||
}
|
||||
|
||||
@@ -91,7 +93,7 @@ public function addSubdirectory($sitePath)
|
||||
});
|
||||
|
||||
// If paths are found, return the first one.
|
||||
if (!empty($foundPaths)) {
|
||||
if (! empty($foundPaths)) {
|
||||
return array_shift($foundPaths);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public function isStaticFile($sitePath, $siteName, $uri)
|
||||
return $staticFilePath;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -58,7 +58,7 @@ public function frontControllerPath($sitePath, $siteName, $uri)
|
||||
if (isset($_SERVER['HTTP_X_ORIGINAL_HOST'], $_SERVER['HTTP_X_FORWARDED_HOST'])) {
|
||||
$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
|
||||
}
|
||||
|
||||
|
||||
return $sitePath.'/public/index.php';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
|
||||
class Magento2ValetDriver extends ValetDriver
|
||||
{
|
||||
|
||||
/**
|
||||
* Holds the MAGE_MODE from app/etc/config.php or $ENV
|
||||
* Holds the MAGE_MODE from app/etc/config.php or $ENV.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
@@ -13,22 +12,22 @@ class Magento2ValetDriver extends ValetDriver
|
||||
/**
|
||||
* Determine if the driver serves the request.
|
||||
*
|
||||
* @param string $sitePath
|
||||
* @param string $siteName
|
||||
* @param string $uri
|
||||
* @return boolean
|
||||
* @param string $sitePath
|
||||
* @param string $siteName
|
||||
* @param string $uri
|
||||
* @return bool
|
||||
*/
|
||||
public function serves($sitePath, $siteName, $uri)
|
||||
{
|
||||
return file_exists($sitePath . '/bin/magento') && file_exists($sitePath . '/pub/index.php');
|
||||
return file_exists($sitePath.'/bin/magento') && file_exists($sitePath.'/pub/index.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the incoming request is for a static file.
|
||||
*
|
||||
* @param string $sitePath
|
||||
* @param string $siteName
|
||||
* @param string $uri
|
||||
* @param string $sitePath
|
||||
* @param string $siteName
|
||||
* @param string $uri
|
||||
* @return string|false
|
||||
*/
|
||||
public function isStaticFile($sitePath, $siteName, $uri)
|
||||
@@ -43,7 +42,7 @@ public function isStaticFile($sitePath, $siteName, $uri)
|
||||
$pub = 'pub/';
|
||||
}
|
||||
|
||||
if (!$this->isPubDirectory($sitePath, $route, $pub)) {
|
||||
if (! $this->isPubDirectory($sitePath, $route, $pub)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -52,21 +51,21 @@ public function isStaticFile($sitePath, $siteName, $uri)
|
||||
$magentoPackagePubDir .= '/pub';
|
||||
}
|
||||
|
||||
$file = $magentoPackagePubDir . '/' . $route;
|
||||
$file = $magentoPackagePubDir.'/'.$route;
|
||||
|
||||
if (file_exists($file)) {
|
||||
return $magentoPackagePubDir . $uri;
|
||||
return $magentoPackagePubDir.$uri;
|
||||
}
|
||||
|
||||
if (strpos($route, $pub . 'static/') === 0) {
|
||||
$route = preg_replace('#' . $pub . 'static/#', '', $route, 1);
|
||||
if (strpos($route, $pub.'static/') === 0) {
|
||||
$route = preg_replace('#'.$pub.'static/#', '', $route, 1);
|
||||
$_GET['resource'] = $route;
|
||||
include $magentoPackagePubDir . '/' . $pub . 'static.php';
|
||||
include $magentoPackagePubDir.'/'.$pub.'static.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
if (strpos($route, $pub . 'media/') === 0) {
|
||||
include $magentoPackagePubDir . '/' . $pub . 'get.php';
|
||||
if (strpos($route, $pub.'media/') === 0) {
|
||||
include $magentoPackagePubDir.'/'.$pub.'get.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -75,9 +74,9 @@ public function isStaticFile($sitePath, $siteName, $uri)
|
||||
|
||||
/**
|
||||
* Rewrite URLs that look like "versions12345/" to remove
|
||||
* the versions12345/ part
|
||||
* the versions12345/ part.
|
||||
*
|
||||
* @param string $route
|
||||
* @param string $route
|
||||
*/
|
||||
private function handleForVersions($route)
|
||||
{
|
||||
@@ -85,9 +84,9 @@ private function handleForVersions($route)
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the current MAGE_MODE
|
||||
* Determine the current MAGE_MODE.
|
||||
*
|
||||
* @param string $sitePath
|
||||
* @param string $sitePath
|
||||
*/
|
||||
private function checkMageMode($sitePath)
|
||||
{
|
||||
@@ -95,13 +94,14 @@ private function checkMageMode($sitePath)
|
||||
// We have already figure out mode, no need to check it again
|
||||
return;
|
||||
}
|
||||
if (!file_exists($sitePath . '/index.php')) {
|
||||
if (! file_exists($sitePath.'/index.php')) {
|
||||
$this->mageMode = 'production'; // Can't use developer mode without index.php in project root
|
||||
|
||||
return;
|
||||
}
|
||||
$mageConfig = [];
|
||||
if (file_exists($sitePath . '/app/etc/env.php')) {
|
||||
$mageConfig = require $sitePath . '/app/etc/env.php';
|
||||
if (file_exists($sitePath.'/app/etc/env.php')) {
|
||||
$mageConfig = require $sitePath.'/app/etc/env.php';
|
||||
}
|
||||
if (array_key_exists('MAGE_MODE', $mageConfig)) {
|
||||
$this->mageMode = $mageConfig['MAGE_MODE'];
|
||||
@@ -112,31 +112,32 @@ private function checkMageMode($sitePath)
|
||||
* Checks to see if route is referencing any directory inside pub. This is a dynamic check so that if any new
|
||||
* directories are added to pub this driver will not need to be updated.
|
||||
*
|
||||
* @param string $sitePath
|
||||
* @param string $route
|
||||
* @param string $pub
|
||||
* @param string $sitePath
|
||||
* @param string $route
|
||||
* @param string $pub
|
||||
* @return bool
|
||||
*/
|
||||
private function isPubDirectory($sitePath, $route, $pub = '')
|
||||
{
|
||||
$sitePath .= '/pub/';
|
||||
$dirs = glob($sitePath . '*', GLOB_ONLYDIR);
|
||||
$dirs = glob($sitePath.'*', GLOB_ONLYDIR);
|
||||
|
||||
$dirs = str_replace($sitePath, '', $dirs);
|
||||
foreach ($dirs as $dir) {
|
||||
if (strpos($route, $pub . $dir . '/') === 0) {
|
||||
if (strpos($route, $pub.$dir.'/') === 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fully resolved path to the application's front controller.
|
||||
*
|
||||
* @param string $sitePath
|
||||
* @param string $siteName
|
||||
* @param string $uri
|
||||
* @param string $sitePath
|
||||
* @param string $siteName
|
||||
* @param string $uri
|
||||
* @return string
|
||||
*/
|
||||
public function frontControllerPath($sitePath, $siteName, $uri)
|
||||
@@ -145,9 +146,11 @@ public function frontControllerPath($sitePath, $siteName, $uri)
|
||||
|
||||
if ('developer' === $this->mageMode) {
|
||||
$_SERVER['DOCUMENT_ROOT'] = $sitePath;
|
||||
return $sitePath . '/index.php';
|
||||
|
||||
return $sitePath.'/index.php';
|
||||
}
|
||||
$_SERVER['DOCUMENT_ROOT'] = $sitePath . '/pub';
|
||||
return $sitePath . '/pub/index.php';
|
||||
$_SERVER['DOCUMENT_ROOT'] = $sitePath.'/pub';
|
||||
|
||||
return $sitePath.'/pub/index.php';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ public function isStaticFile($sitePath, $siteName, $uri)
|
||||
if ($this->isActualFile($staticFilePath = $sitePath.'/Web'.$uri)) {
|
||||
return $staticFilePath;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -45,6 +46,7 @@ public function frontControllerPath($sitePath, $siteName, $uri)
|
||||
putenv('FLOW_REWRITEURLS=1');
|
||||
$_SERVER['SCRIPT_FILENAME'] = $sitePath.'/Web/index.php';
|
||||
$_SERVER['SCRIPT_NAME'] = '/index.php';
|
||||
|
||||
return $sitePath.'/Web/index.php';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,26 +69,26 @@ public function frontControllerPath($sitePath, $siteName, $uri)
|
||||
$sitePathPrefix = ($isAboveWebroot) ? $sitePath.'/public' : $sitePath;
|
||||
|
||||
if ($locale = $this->getUriLocale($uri)) {
|
||||
if ($this->isActualFile($localeIndexPath = $sitePathPrefix . '/' . $locale . '/index.php')) {
|
||||
if ($this->isActualFile($localeIndexPath = $sitePathPrefix.'/'.$locale.'/index.php')) {
|
||||
// Force trailing slashes on locale roots.
|
||||
if ($uri === '/' . $locale) {
|
||||
header('Location: ' . $uri . '/');
|
||||
die;
|
||||
if ($uri === '/'.$locale) {
|
||||
header('Location: '.$uri.'/');
|
||||
exit;
|
||||
}
|
||||
|
||||
$indexPath = $localeIndexPath;
|
||||
$scriptName = '/' . $locale . '/index.php';
|
||||
$scriptName = '/'.$locale.'/index.php';
|
||||
}
|
||||
}
|
||||
|
||||
$_SERVER['SCRIPT_NAME'] = $scriptName;
|
||||
$_SERVER['SCRIPT_FILENAME'] = $sitePathPrefix . $scriptName;
|
||||
$_SERVER['SCRIPT_FILENAME'] = $sitePathPrefix.$scriptName;
|
||||
|
||||
return $indexPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the locale from this URI
|
||||
* Get the locale from this URI.
|
||||
*
|
||||
* @param string $uri
|
||||
* @return string|null
|
||||
@@ -106,7 +106,7 @@ public function getUriLocale($uri)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of possible locales used in the first segment of a URI
|
||||
* Get the list of possible locales used in the first segment of a URI.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -131,9 +131,9 @@ public function getLocales()
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path to a statically cached page
|
||||
* Get the path to a statically cached page.
|
||||
*
|
||||
* @param string $sitePath
|
||||
* @param string $sitePath
|
||||
* @return string
|
||||
*/
|
||||
protected function getStaticPath($sitePath)
|
||||
@@ -141,6 +141,6 @@ protected function getStaticPath($sitePath)
|
||||
$parts = parse_url($_SERVER['REQUEST_URI']);
|
||||
$query = isset($parts['query']) ? $parts['query'] : '';
|
||||
|
||||
return $sitePath . '/static' . $parts['path'] . '_' . $query . '.html';
|
||||
return $sitePath.'/static'.$parts['path'].'_'.$query.'.html';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,7 @@ public function serves($sitePath, $siteName, $uri)
|
||||
{
|
||||
return (file_exists($sitePath.'/web/app_dev.php') || file_exists($sitePath.'/web/app.php')) &&
|
||||
(file_exists($sitePath.'/app/AppKernel.php')) || (file_exists($sitePath.'/public/index.php')) &&
|
||||
(file_exists($sitePath.'/src/Kernel.php'))
|
||||
;
|
||||
(file_exists($sitePath.'/src/Kernel.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,6 +57,7 @@ public function frontControllerPath($sitePath, $siteName, $uri)
|
||||
}
|
||||
|
||||
$_SERVER['SCRIPT_FILENAME'] = $frontControllerPath;
|
||||
|
||||
return $frontControllerPath;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class Typo3ValetDriver extends ValetDriver
|
||||
| Document Root Subdirectory
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This subdirectory contains the public server resources, such as the
|
||||
| This subdirectory contains the public server resources, such as the
|
||||
| index.php, the typo3 and fileadmin system directories. Change it
|
||||
| to '', if you don't use a subdirectory but valet link directly.
|
||||
|
|
||||
@@ -48,7 +48,8 @@ class Typo3ValetDriver extends ValetDriver
|
||||
*/
|
||||
public function serves($sitePath, $siteName, $uri)
|
||||
{
|
||||
$typo3Dir = $sitePath . $this->documentRoot . '/typo3';
|
||||
$typo3Dir = $sitePath.$this->documentRoot.'/typo3';
|
||||
|
||||
return file_exists($typo3Dir) && is_dir($typo3Dir);
|
||||
}
|
||||
|
||||
@@ -66,17 +67,15 @@ public function isStaticFile($sitePath, $siteName, $uri)
|
||||
{
|
||||
// May the file contains a cache busting version string like filename.12345678.css
|
||||
// If that is the case, the file cannot be found on disk, so remove the version
|
||||
// identifier before retrying below.
|
||||
if (!$this->isActualFile($filePath = $sitePath . $this->documentRoot . $uri))
|
||||
{
|
||||
$uri = preg_replace("@^(.+)\.(\d+)\.(js|css|png|jpg|gif|gzip)$@", "$1.$3", $uri);
|
||||
// identifier before retrying below.
|
||||
if (! $this->isActualFile($filePath = $sitePath.$this->documentRoot.$uri)) {
|
||||
$uri = preg_replace("@^(.+)\.(\d+)\.(js|css|png|jpg|gif|gzip)$@", '$1.$3', $uri);
|
||||
}
|
||||
|
||||
// Now that any possible version string is cleared from the filename, the resulting
|
||||
// URI should be a valid file on disc. So assemble the absolut file name with the
|
||||
// same schema as above and if it exists, authorize access and return its path.
|
||||
if ($this->isActualFile($filePath = $sitePath . $this->documentRoot . $uri))
|
||||
{
|
||||
if ($this->isActualFile($filePath = $sitePath.$this->documentRoot.$uri)) {
|
||||
return $this->isAccessAuthorized($uri) ? $filePath : false;
|
||||
}
|
||||
|
||||
@@ -87,18 +86,17 @@ public function isStaticFile($sitePath, $siteName, $uri)
|
||||
/**
|
||||
* Determines if the given URI is blacklisted so that access is prevented.
|
||||
*
|
||||
* @param string $uri
|
||||
* @return boolean
|
||||
* @param string $uri
|
||||
* @return bool
|
||||
*/
|
||||
private function isAccessAuthorized($uri)
|
||||
{
|
||||
foreach ($this->forbiddenUriPatterns as $forbiddenUriPattern)
|
||||
{
|
||||
if (preg_match("@$forbiddenUriPattern@", $uri))
|
||||
{
|
||||
foreach ($this->forbiddenUriPatterns as $forbiddenUriPattern) {
|
||||
if (preg_match("@$forbiddenUriPattern@", $uri)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -121,24 +119,18 @@ public function frontControllerPath($sitePath, $siteName, $uri)
|
||||
$uri = rtrim($uri, '/');
|
||||
|
||||
// try to find the responsible script file for the requested folder / script URI
|
||||
if (file_exists($absoluteFilePath = $sitePath . $this->documentRoot . $uri))
|
||||
{
|
||||
if (is_dir($absoluteFilePath))
|
||||
{
|
||||
if (file_exists($absoluteFilePath . '/index.php'))
|
||||
{
|
||||
if (file_exists($absoluteFilePath = $sitePath.$this->documentRoot.$uri)) {
|
||||
if (is_dir($absoluteFilePath)) {
|
||||
if (file_exists($absoluteFilePath.'/index.php')) {
|
||||
// this folder can be served by index.php
|
||||
return $this->serveScript($sitePath, $siteName, $uri . '/index.php');
|
||||
return $this->serveScript($sitePath, $siteName, $uri.'/index.php');
|
||||
}
|
||||
|
||||
if (file_exists($absoluteFilePath . '/index.html'))
|
||||
{
|
||||
if (file_exists($absoluteFilePath.'/index.html')) {
|
||||
// this folder can be served by index.html
|
||||
return $absoluteFilePath . '/index.html';
|
||||
return $absoluteFilePath.'/index.html';
|
||||
}
|
||||
}
|
||||
else if (pathinfo($absoluteFilePath, PATHINFO_EXTENSION) === 'php')
|
||||
{
|
||||
} elseif (pathinfo($absoluteFilePath, PATHINFO_EXTENSION) === 'php') {
|
||||
// this file can be served directly
|
||||
return $this->serveScript($sitePath, $siteName, $uri);
|
||||
}
|
||||
@@ -153,20 +145,18 @@ public function frontControllerPath($sitePath, $siteName, $uri)
|
||||
* sysext install script. domain.dev/typo3 will be redirected to /typo3/, because
|
||||
* the generated JavaScript URIs on the login screen would be broken on /typo3.
|
||||
*
|
||||
* @param string $uri
|
||||
* @param string $uri
|
||||
*/
|
||||
private function handleRedirectBackendShorthandUris($uri)
|
||||
{
|
||||
if (rtrim($uri, '/') === '/typo3/install')
|
||||
{
|
||||
if (rtrim($uri, '/') === '/typo3/install') {
|
||||
header('Location: /typo3/sysext/install/Start/Install.php');
|
||||
die();
|
||||
exit();
|
||||
}
|
||||
|
||||
if ($uri === '/typo3')
|
||||
{
|
||||
if ($uri === '/typo3') {
|
||||
header('Location: /typo3/');
|
||||
die();
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,10 +172,10 @@ private function handleRedirectBackendShorthandUris($uri)
|
||||
*/
|
||||
private function serveScript($sitePath, $siteName, $uri)
|
||||
{
|
||||
$docroot = $sitePath . $this->documentRoot;
|
||||
$abspath = $docroot . $uri;
|
||||
$docroot = $sitePath.$this->documentRoot;
|
||||
$abspath = $docroot.$uri;
|
||||
|
||||
$_SERVER['SERVER_NAME'] = $siteName . '.dev';
|
||||
$_SERVER['SERVER_NAME'] = $siteName.'.dev';
|
||||
$_SERVER['DOCUMENT_ROOT'] = $docroot;
|
||||
$_SERVER['DOCUMENT_URI'] = $uri;
|
||||
$_SERVER['SCRIPT_FILENAME'] = $abspath;
|
||||
|
||||
@@ -166,7 +166,7 @@ public function serveStaticFile($staticFilePath, $sitePath, $siteName, $uri)
|
||||
header('Content-Type: text/html');
|
||||
header_remove('Content-Type');
|
||||
|
||||
header('X-Accel-Redirect: /' . VALET_STATIC_PREFIX . $staticFilePath);
|
||||
header('X-Accel-Redirect: /'.VALET_STATIC_PREFIX.$staticFilePath);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,7 +182,7 @@ protected function isActualFile($path)
|
||||
|
||||
/**
|
||||
* Load server environment variables if available.
|
||||
* Processes any '*' entries first, and then adds site-specific entries
|
||||
* Processes any '*' entries first, and then adds site-specific entries.
|
||||
*
|
||||
* @param string $sitePath
|
||||
* @param string $siteName
|
||||
@@ -190,9 +190,9 @@ protected function isActualFile($path)
|
||||
*/
|
||||
public function loadServerEnvironmentVariables($sitePath, $siteName)
|
||||
{
|
||||
$varFilePath = $sitePath . '/.valet-env.php';
|
||||
$varFilePath = $sitePath.'/.valet-env.php';
|
||||
if (! file_exists($varFilePath)) {
|
||||
$varFilePath = VALET_HOME_PATH . '/.valet-env.php';
|
||||
$varFilePath = VALET_HOME_PATH.'/.valet-env.php';
|
||||
}
|
||||
if (! file_exists($varFilePath)) {
|
||||
return;
|
||||
@@ -207,11 +207,12 @@ public function loadServerEnvironmentVariables($sitePath, $siteName)
|
||||
}
|
||||
|
||||
foreach ($variablesToSet as $key => $value) {
|
||||
if (! is_string($key)) continue;
|
||||
if (! is_string($key)) {
|
||||
continue;
|
||||
}
|
||||
$_SERVER[$key] = $value;
|
||||
$_ENV[$key] = $value;
|
||||
putenv($key . '=' . $value);
|
||||
putenv($key.'='.$value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public function serves($sitePath, $siteName, $uri)
|
||||
*/
|
||||
public function frontControllerPath($sitePath, $siteName, $uri)
|
||||
{
|
||||
$_SERVER['PHP_SELF'] = $uri;
|
||||
$_SERVER['PHP_SELF'] = $uri;
|
||||
$_SERVER['SERVER_ADDR'] = '127.0.0.1';
|
||||
$_SERVER['SERVER_NAME'] = $_SERVER['HTTP_HOST'];
|
||||
|
||||
@@ -37,13 +37,14 @@ public function frontControllerPath($sitePath, $siteName, $uri)
|
||||
/**
|
||||
* Redirect to uri with trailing slash.
|
||||
*
|
||||
* @param string $uri
|
||||
* @param string $uri
|
||||
* @return string
|
||||
*/
|
||||
private function forceTrailingSlash($uri)
|
||||
{
|
||||
if (substr($uri, -1 * strlen('/wp-admin')) == '/wp-admin') {
|
||||
header('Location: '.$uri.'/'); die;
|
||||
header('Location: '.$uri.'/');
|
||||
exit;
|
||||
}
|
||||
|
||||
return $uri;
|
||||
|
||||
Reference in New Issue
Block a user