Skip to content

Commit

Permalink
Introduced pub/ folder structure for webserver home folder mapping (O…
Browse files Browse the repository at this point in the history
…penMage#1210)

Co-authored-by: Fabrizio Balliano <fabrizio.balliano@gmail.com>
Co-authored-by: Colin Mollenhour <colin@mollenhour.com>
  • Loading branch information
3 people committed May 24, 2023
1 parent 90fefd7 commit e3c88f1
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 4 deletions.
6 changes: 6 additions & 0 deletions dev/openmage/apache/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM ghcr.io/colinmollenhour/docker-openmage-dev:8.2-apache

ENV APACHE_DOCUMENT_ROOT /var/www/html/pub/default

RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
2 changes: 1 addition & 1 deletion dev/openmage/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.7"

services:
apache:
image: ghcr.io/colinmollenhour/docker-openmage-dev:8.2-apache
build: apache
hostname: ${HOST_NAME:-openmage-7f000001.nip.io}
ports:
- "${HOST_PORT:-80}:80"
Expand Down
6 changes: 3 additions & 3 deletions errors/processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ public function __construct()
$this->_root = is_dir($this->_indexDir.'app');

$this->_prepareConfig();
if (isset($_GET['skin'])) {
$this->_setSkin($_GET['skin']);
if (isset($_SERVER['MAGE_ERRORS_SKIN']) || isset($_GET['skin'])) {
$this->_setSkin($_SERVER['MAGE_ERRORS_SKIN'] ?? $_GET['skin']);
}
}

Expand Down Expand Up @@ -208,7 +208,7 @@ public function getBaseUrl(bool $param = false): string
*/
protected function _getClientIp(): string
{
return $_SERVER['REMOTE_ADDR'] ?? 'undefined';
return $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['REMOTE_ADDR'] ?? 'undefined';
}

protected function _getIndexDir(): string
Expand Down
1 change: 1 addition & 0 deletions pub/default/.htaccess
5 changes: 5 additions & 0 deletions pub/default/api.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

chdir(dirname(__DIR__, 2));

require 'api.php';
1 change: 1 addition & 0 deletions pub/default/errors
Binary file added pub/default/favicon.ico
Binary file not shown.
5 changes: 5 additions & 0 deletions pub/default/get.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

chdir(dirname(__DIR__, 2));

require 'get.php';
25 changes: 25 additions & 0 deletions pub/default/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
//
// This file is the entrypoint for the default OpenMage store.
// Create a separate subdirectory of pub/ to add more virtual hosts for different stores
// with different root directories and assign the run code and run type variables below as appropriate.
//

chdir(dirname(__DIR__, 2));

/* Store or website code */
if (empty($_SERVER['MAGE_RUN_CODE'])) {
$_SERVER['MAGE_RUN_CODE'] = '';
}

/* Run store or run website */
if (empty($_SERVER['MAGE_RUN_TYPE'])) {
$_SERVER['MAGE_RUN_TYPE'] = 'store';
}

/* Errors pages skin */
if (empty($_SERVER['MAGE_ERRORS_SKIN'])) {
$_SERVER['MAGE_ERRORS_SKIN'] = 'default';
}

require 'index.php';
9 changes: 9 additions & 0 deletions pub/default/install.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

chdir(dirname(__DIR__, 2));

if (file_exists('app/etc/local.xml')) {
require 'errors/404.php';
} else {
require 'install.php';
}
1 change: 1 addition & 0 deletions pub/default/js
1 change: 1 addition & 0 deletions pub/default/media
1 change: 1 addition & 0 deletions pub/default/skin

0 comments on commit e3c88f1

Please sign in to comment.