From f43b075ec23fbe144b41ebbe8a75ee517455e67b Mon Sep 17 00:00:00 2001 From: Colin Tucker Date: Tue, 12 Jun 2018 11:50:09 +1000 Subject: [PATCH] Updated for new 'public folder' structure. --- .gitignore | 16 +--- .htaccess | 58 +------------ app/_config.php | 10 +++ app/_config/theme.yml | 1 + app/code/Page.php | 73 ----------------- app/code/PageController.php | 63 -------------- app/src/Page.php | 77 ++++++++++++++++++ app/src/PageController.php | 67 +++++++++++++++ assets/.htaccess | 31 ------- composer.json | 36 ++++---- deploy.php | 4 +- public/.htaccess | 56 +++++++++++++ public/assets/.gitignore | 7 ++ public/assets/.htaccess | 35 ++++++++ .../assets}/Uploads/silverware-logo.png | Bin {assets => public/assets}/web.config | 0 favicon.ico => public/favicon.ico | Bin index.php => public/index.php | 11 ++- web.config => public/web.config | 1 - 19 files changed, 291 insertions(+), 255 deletions(-) delete mode 100644 app/code/Page.php delete mode 100644 app/code/PageController.php create mode 100644 app/src/Page.php create mode 100644 app/src/PageController.php delete mode 100644 assets/.htaccess create mode 100644 public/.htaccess create mode 100644 public/assets/.gitignore create mode 100644 public/assets/.htaccess rename {assets => public/assets}/Uploads/silverware-logo.png (100%) rename {assets => public/assets}/web.config (100%) rename favicon.ico => public/favicon.ico (100%) rename index.php => public/index.php (59%) rename web.config => public/web.config (94%) diff --git a/.gitignore b/.gitignore index efcd1a0..761f564 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ Thumbs.db ### Folder Config ### +.directory .DS_Store Desktop.ini @@ -16,7 +17,7 @@ Desktop.ini /vendor ### Node.js Packages ### -/**/node_modules +node_modules/ ### Sass Cache ### .sass-cache @@ -27,21 +28,12 @@ Desktop.ini ### Environment Config ### .env -_ss_environment.php ### SilverStripe Cache ### -/silverstripe-cache - -### SilverStripe Assets ### -/assets/* -/assets/Uploads/* -!/assets/.htaccess -!/assets/web.config -!/assets/Uploads/ -!/assets/Uploads/silverware-logo.png +silverstripe-cache/ ### SilverStripe Resources ### -/resources +resources/ ### SilverStripe Themes ### /themes/silverware-theme diff --git a/.htaccess b/.htaccess index c7e7297..adbd7c8 100644 --- a/.htaccess +++ b/.htaccess @@ -1,56 +1,2 @@ -### SILVERSTRIPE START ### - -# Deny access to templates (but allow from localhost) - - Order deny,allow - Deny from all - Allow from 127.0.0.1 - - -# Deny access to IIS configuration - - Order deny,allow - Deny from all - - -# Deny access to YAML configuration files which might include sensitive information - - Order allow,deny - Deny from all - - -# Route errors to static pages automatically generated by SilverStripe -ErrorDocument 404 /assets/error-404.html -ErrorDocument 500 /assets/error-500.html - - - - # Turn off index.php handling requests to the homepage fixes issue in apache >=2.4 - - DirectoryIndex disabled - DirectorySlash On - - - SetEnv HTTP_MOD_REWRITE On - RewriteEngine On - - # Enable HTTP Basic authentication workaround for PHP running in CGI mode - RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] - - # Deny access to potentially sensitive files and folders - RewriteRule ^vendor(/|$) - [F,L,NC] - RewriteRule ^\.env - [F,L,NC] - RewriteRule silverstripe-cache(/|$) - [F,L,NC] - RewriteRule composer\.(json|lock) - [F,L,NC] - RewriteRule (error|silverstripe|debug)\.log - [F,L,NC] - - # Process through SilverStripe if no file with the requested name exists. - # Pass through the original path as a query parameter, and retain the existing parameters. - # Try finding framework in the vendor folder first - RewriteCond %{REQUEST_URI} ^(.*)$ - RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule .* index.php - - - -### SILVERSTRIPE END ### +RewriteEngine On +RewriteRule ^(.*)$ public/$1 diff --git a/app/_config.php b/app/_config.php index 778d97d..2598348 100644 --- a/app/_config.php +++ b/app/_config.php @@ -15,6 +15,9 @@ * @link {project-link} */ +use SilverStripe\Security\Member; +use SilverStripe\Security\PasswordValidator; + // Define Application Constants: if (!defined('APP_DIR')) { @@ -24,3 +27,10 @@ if (!defined('APP_PATH')) { define('APP_PATH', realpath(__DIR__)); } + +// Define Member Password Validator: + +$validator = new PasswordValidator(); +$validator->setMinLength(8); +$validator->setHistoricCount(6); +Member::set_password_validator($validator); diff --git a/app/_config/theme.yml b/app/_config/theme.yml index 23ce2c0..94bc30a 100644 --- a/app/_config/theme.yml +++ b/app/_config/theme.yml @@ -6,5 +6,6 @@ Name: app-theme SilverStripe\View\SSViewer: themes: + - '$public' - 'silverware-theme' - '$default' diff --git a/app/code/Page.php b/app/code/Page.php deleted file mode 100644 index 42cd06a..0000000 --- a/app/code/Page.php +++ /dev/null @@ -1,73 +0,0 @@ -=5.6.0 - * - * For full copyright and license information, please view the - * LICENSE.md file that was distributed with this source code. - * - * @package {app-namespace} - * @author {author-name} <{author-email}> - * @copyright {year} {author-company} - * @license {license-link} {license-name} - * @link {project-link} - */ - -use SilverStripe\CMS\Model\SiteTree; - -/** - * An extension of the site tree class for the standard SilverStripe page. - * - * As SilverStripe relies on having a global Page class available, this class is - * intentionally defined without a namespace in order to keep SilverStripe happy. - * - * @package {app-namespace} - * @author {author-name} <{author-email}> - * @copyright {year} {author-company} - * @license {license-link} {license-name} - * @link {project-link} - */ -class Page extends SiteTree -{ - /** - * Human-readable singular name. - * - * @var string - * @config - */ - private static $singular_name = 'Page'; - - /** - * Human-readable plural name. - * - * @var string - * @config - */ - private static $plural_name = 'Pages'; - - /** - * Description of this object. - * - * @var string - * @config - */ - private static $description = 'Standard content page'; - - /** - * Icon file for this page type. - * - * @var string - * @config - */ - private static $icon = 'app/admin/client/dist/images/icons/Page.png'; - - /** - * Defines the table name to use for this object. - * - * @var string - * @config - */ - private static $table_name = 'Page'; -} diff --git a/app/code/PageController.php b/app/code/PageController.php deleted file mode 100644 index 921a7e4..0000000 --- a/app/code/PageController.php +++ /dev/null @@ -1,63 +0,0 @@ -=5.6.0 - * - * For full copyright and license information, please view the - * LICENSE.md file that was distributed with this source code. - * - * @package {app-namespace} - * @author {author-name} <{author-email}> - * @copyright {year} {author-company} - * @license {license-link} {license-name} - * @link {project-link} - */ - -use SilverStripe\CMS\Controllers\ContentController; - -/** - * An extension of the content controller class for the standard SilverStripe page controller. - * - * As SilverStripe relies on having a global PageController class available, this class is - * intentionally defined without a namespace in order to keep SilverStripe happy. - * - * @package {app-namespace} - * @author {author-name} <{author-email}> - * @copyright {year} {author-company} - * @license {license-link} {license-name} - * @link {project-link} - */ -class PageController extends ContentController -{ - /** - * Defines the URL routes handled by this controller. - * - * @var array - * @config - */ - private static $url_handlers = [ - - ]; - - /** - * Defines the actions permitted for this controller. - * - * @var array - * @config - */ - private static $allowed_actions = [ - - ]; - - /** - * Performs initialisation before any action is called on the receiver. - * - * @return void - */ - protected function init() - { - parent::init(); - } -} diff --git a/app/src/Page.php b/app/src/Page.php new file mode 100644 index 0000000..ec5af71 --- /dev/null +++ b/app/src/Page.php @@ -0,0 +1,77 @@ +=5.6.0 + * + * For full copyright and license information, please view the + * LICENSE.md file that was distributed with this source code. + * + * @package {app-namespace} + * @author {author-name} <{author-email}> + * @copyright {year} {author-company} + * @license {license-link} {license-name} + * @link {project-link} + */ + +namespace { + + use SilverStripe\CMS\Model\SiteTree; + + /** + * An extension of the site tree class for the standard SilverStripe page. + * + * As SilverStripe relies on having a global Page class available, this class is + * intentionally defined without a namespace in order to keep SilverStripe happy. + * + * @package {app-namespace} + * @author {author-name} <{author-email}> + * @copyright {year} {author-company} + * @license {license-link} {license-name} + * @link {project-link} + */ + class Page extends SiteTree + { + /** + * Human-readable singular name. + * + * @var string + * @config + */ + private static $singular_name = 'Page'; + + /** + * Human-readable plural name. + * + * @var string + * @config + */ + private static $plural_name = 'Pages'; + + /** + * Description of this object. + * + * @var string + * @config + */ + private static $description = 'Standard content page'; + + /** + * Icon file for this page type. + * + * @var string + * @config + */ + private static $icon = 'app/admin/client/dist/images/icons/Page.png'; + + /** + * Defines the table name to use for this object. + * + * @var string + * @config + */ + private static $table_name = 'Page'; + } + +} diff --git a/app/src/PageController.php b/app/src/PageController.php new file mode 100644 index 0000000..5ab9314 --- /dev/null +++ b/app/src/PageController.php @@ -0,0 +1,67 @@ +=5.6.0 + * + * For full copyright and license information, please view the + * LICENSE.md file that was distributed with this source code. + * + * @package {app-namespace} + * @author {author-name} <{author-email}> + * @copyright {year} {author-company} + * @license {license-link} {license-name} + * @link {project-link} + */ + +namespace { + + use SilverStripe\CMS\Controllers\ContentController; + + /** + * An extension of the content controller class for the standard SilverStripe page controller. + * + * As SilverStripe relies on having a global PageController class available, this class is + * intentionally defined without a namespace in order to keep SilverStripe happy. + * + * @package {app-namespace} + * @author {author-name} <{author-email}> + * @copyright {year} {author-company} + * @license {license-link} {license-name} + * @link {project-link} + */ + class PageController extends ContentController + { + /** + * Defines the URL routes handled by this controller. + * + * @var array + * @config + */ + private static $url_handlers = [ + + ]; + + /** + * Defines the actions permitted for this controller. + * + * @var array + * @config + */ + private static $allowed_actions = [ + + ]; + + /** + * Performs initialisation before any action is called on the receiver. + * + * @return void + */ + protected function init() + { + parent::init(); + } + } + +} diff --git a/assets/.htaccess b/assets/.htaccess deleted file mode 100644 index 780dc7e..0000000 --- a/assets/.htaccess +++ /dev/null @@ -1,31 +0,0 @@ -# -# Whitelist appropriate assets files. -# This file is automatically generated via File.allowed_extensions configuration -# See AssetAdapter::renderTemplate() for reference. -# - - - - SetEnv HTTP_MOD_REWRITE On - - - # Enable rewriting - RewriteEngine On - - # Disable PHP handler - RewriteCond %{REQUEST_URI} .(?i:php|phtml|php3|php4|php5|inc)$ - RewriteRule .* - [F] - - # Allow error pages - RewriteCond %{REQUEST_FILENAME} -f - RewriteRule error[^\\/]*\.html$ - [L] - - # Block invalid file extensions - RewriteCond %{REQUEST_URI} !\.(?i:ace|arc|arj|asf|au|avi|bmp|bz2|cab|cda|css|csv|dmg|doc|docx|dotx|dotm|flv|gif|gpx|gz|hqx|ico|jar|jpeg|jpg|js|kml|m4a|m4v|mid|midi|mkv|mov|mp3|mp4|mpa|mpeg|mpg|ogg|ogv|pages|pcx|pdf|png|pps|ppt|pptx|potx|potm|ra|ram|rm|rtf|sit|sitx|tar|tgz|tif|tiff|txt|wav|webm|wma|wmv|xls|xlsx|xltx|xltm|zip|zipx)$ - RewriteRule .* - [F] - - # Non existant files passed to requesthandler - RewriteCond %{REQUEST_URI} ^(.*)$ - RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule .* ../framework/main.php?url=%1 [QSA] - diff --git a/composer.json b/composer.json index b640b13..754223e 100644 --- a/composer.json +++ b/composer.json @@ -18,29 +18,29 @@ ], "require": { "php": ">=5.6.0", - "silverstripe/admin": "^1.0", - "silverstripe/asset-admin": "^1.0", - "silverstripe/assets": "^1.0", - "silverstripe/campaign-admin": "^1.0", - "silverstripe/cms": "^4.0", + "silverstripe/admin": "^1.1", + "silverstripe/asset-admin": "^1.1", + "silverstripe/assets": "^1.1", + "silverstripe/campaign-admin": "^1.1", + "silverstripe/cms": "^4.1", "silverstripe/config": "^1.0", - "silverstripe/errorpage": "^1.0", - "silverstripe/framework": "^4.0", - "silverstripe/graphql": "^1.0", - "silverstripe/reports": "^4.0", - "silverstripe/siteconfig": "^4.0", - "silverstripe/versioned": "^1.0", - "silverware/admin": "^1.2", + "silverstripe/errorpage": "^1.1", + "silverstripe/framework": "^4.1", + "silverstripe/graphql": "^1.1", + "silverstripe/reports": "^4.1", + "silverstripe/siteconfig": "^4.1", + "silverstripe/versioned": "^1.1", + "silverware/admin": "^1.3", "silverware/calendar": "^1.0", "silverware/colorpicker": "^1.0", "silverware/countries": "^1.0", "silverware/font-icons": "^1.1", "silverware/model-filters": "^1.0", - "silverware/navigation": "^1.5", + "silverware/navigation": "^1.6", "silverware/open-graph": "^1.0", - "silverware/silverware": "^1.5", + "silverware/silverware": "^1.8", "silverware/spam-guard": "^1.0", - "silverware/theme": "^1.2", + "silverware/theme": "^1.6", "silverware/validator": "^1.1" }, "require-dev": { @@ -62,7 +62,11 @@ "extra": { "branch-alias": { "dev-master": "1.0.x-dev" - } + }, + "expose": [ + "app/admin/client/dist", + "app/client/dist" + ] }, "minimum-stability": "dev", "prefer-stable": true diff --git a/deploy.php b/deploy.php index 5a3de3a..1ce2661 100644 --- a/deploy.php +++ b/deploy.php @@ -47,13 +47,13 @@ // Define Shared Dirs: set('shared_dirs', [ - 'assets' + 'public/assets' ]); // Define Writable Dirs: set('writable_dirs', [ - 'assets' + 'public/assets' ]); // Define Helper Tasks: diff --git a/public/.htaccess b/public/.htaccess new file mode 100644 index 0000000..c7e7297 --- /dev/null +++ b/public/.htaccess @@ -0,0 +1,56 @@ +### SILVERSTRIPE START ### + +# Deny access to templates (but allow from localhost) + + Order deny,allow + Deny from all + Allow from 127.0.0.1 + + +# Deny access to IIS configuration + + Order deny,allow + Deny from all + + +# Deny access to YAML configuration files which might include sensitive information + + Order allow,deny + Deny from all + + +# Route errors to static pages automatically generated by SilverStripe +ErrorDocument 404 /assets/error-404.html +ErrorDocument 500 /assets/error-500.html + + + + # Turn off index.php handling requests to the homepage fixes issue in apache >=2.4 + + DirectoryIndex disabled + DirectorySlash On + + + SetEnv HTTP_MOD_REWRITE On + RewriteEngine On + + # Enable HTTP Basic authentication workaround for PHP running in CGI mode + RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] + + # Deny access to potentially sensitive files and folders + RewriteRule ^vendor(/|$) - [F,L,NC] + RewriteRule ^\.env - [F,L,NC] + RewriteRule silverstripe-cache(/|$) - [F,L,NC] + RewriteRule composer\.(json|lock) - [F,L,NC] + RewriteRule (error|silverstripe|debug)\.log - [F,L,NC] + + # Process through SilverStripe if no file with the requested name exists. + # Pass through the original path as a query parameter, and retain the existing parameters. + # Try finding framework in the vendor folder first + RewriteCond %{REQUEST_URI} ^(.*)$ + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule .* index.php + + + +### SILVERSTRIPE END ### diff --git a/public/assets/.gitignore b/public/assets/.gitignore new file mode 100644 index 0000000..15c830b --- /dev/null +++ b/public/assets/.gitignore @@ -0,0 +1,7 @@ +### SilverStripe Assets ### +/**/* +!.gitignore +!.htaccess +!web.config +!Uploads/ +!Uploads/silverware-logo.png diff --git a/public/assets/.htaccess b/public/assets/.htaccess new file mode 100644 index 0000000..a934c37 --- /dev/null +++ b/public/assets/.htaccess @@ -0,0 +1,35 @@ +# +# Whitelist appropriate assets files. +# This file is automatically generated via File.allowed_extensions configuration +# See AssetAdapter::renderTemplate() for reference. +# + +# We disable PHP via several methods +# Replace the handler with the default plaintext handler +AddHandler default-handler php phtml php3 php4 php5 inc + + + # Turn the PHP engine off + php_flag engine off + + + + + SetEnv HTTP_MOD_REWRITE On + + + RewriteEngine On + + # Allow error pages + RewriteCond %{REQUEST_FILENAME} -f + RewriteRule error[^\\/]*\.html$ - [L] + + # Block invalid file extensions + RewriteCond %{REQUEST_URI} !^[^.]*\.(?i:css|js|ace|arc|arj|asf|au|avi|bmp|bz2|cab|cda|csv|dmg|doc|docx|dotx|flv|gif|gpx|gz|hqx|ico|jpeg|jpg|kml|m4a|m4v|mid|midi|mkv|mov|mp3|mp4|mpa|mpeg|mpg|ogg|ogv|pages|pcx|pdf|png|pps|ppt|pptx|potx|ra|ram|rm|rtf|sit|sitx|tar|tgz|tif|tiff|txt|wav|webm|wma|wmv|xls|xlsx|xltx|zip|zipx)$ + RewriteRule .* - [F] + + # Non existant files passed to requesthandler + RewriteCond %{REQUEST_URI} ^(.*)$ + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule .* ../index.php [QSA] + diff --git a/assets/Uploads/silverware-logo.png b/public/assets/Uploads/silverware-logo.png similarity index 100% rename from assets/Uploads/silverware-logo.png rename to public/assets/Uploads/silverware-logo.png diff --git a/assets/web.config b/public/assets/web.config similarity index 100% rename from assets/web.config rename to public/assets/web.config diff --git a/favicon.ico b/public/favicon.ico similarity index 100% rename from favicon.ico rename to public/favicon.ico diff --git a/index.php b/public/index.php similarity index 59% rename from index.php rename to public/index.php index 58cf223..bd24b7a 100644 --- a/index.php +++ b/public/index.php @@ -5,7 +5,16 @@ use SilverStripe\Core\CoreKernel; use SilverStripe\Core\Startup\ErrorControlChainMiddleware; -require __DIR__ . '/vendor/autoload.php'; +// Find autoload.php +if (file_exists(__DIR__ . '/../vendor/autoload.php')) { + require __DIR__ . '/../vendor/autoload.php'; +} elseif (file_exists(__DIR__ . '/vendor/autoload.php')) { + require __DIR__ . '/vendor/autoload.php'; +} else { + header('HTTP/1.1 500 Internal Server Error'); + echo "autoload.php not found"; + exit(1); +} // Build request and detect flush $request = HTTPRequestBuilder::createFromEnvironment(); diff --git a/web.config b/public/web.config similarity index 94% rename from web.config rename to public/web.config index 66e5bbe..057f257 100644 --- a/web.config +++ b/public/web.config @@ -6,7 +6,6 @@ -