diff --git a/.scrutinizer.yml b/.scrutinizer.yml index af75ba3b4..be463575b 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,15 +1,7 @@ -tools: - php_pdepend: - enabled: true - excluded_dirs: - - vendor - - thirdparty - - tests - - parsers/HTML/BBCodeParser - - docs - custom_commands: - - - scope: file - command: php tests/phpcs_runner.php %pathname% - filter: - excluded_paths: ["*/css/*", "css/*", "thirdparty/*", "*/jquery-changetracker/*", "parsers/HTML/BBCodeParser/*", "*/SSTemplateParser.php$", "docs/*", "*/images/*"] +inherit: true +filter: + excluded_paths: + - thirdparty/* + - parsers/* + - docs/* + - images/* diff --git a/.travis.yml b/.travis.yml index 11290fb18..0a9502c97 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -language: php +language: php php: - 5.4 @@ -13,11 +13,14 @@ env: matrix: - DB=MYSQL - DB=SQLITE - - DB=PGSQL + - DB=PGSQL matrix: allow_failures: - - php: hhvm-nightly + - php: hhvm + - php: 7.0 + - php: nightly + include: - php: 5.4 env: DB=MYSQL PDO=1 @@ -29,7 +32,11 @@ matrix: env: DB=MYSQL BEHAT_TEST=1 - php: 5.3 env: DB=MYSQL - - php: hhvm-nightly + - php: 7.0 + env: DB=MYSQL + - php: nightly + env: DB=MYSQL + - php: hhvm env: DB=MYSQL before_install: - sudo apt-get update -qq @@ -45,7 +52,7 @@ before_script: - php ~/travis-support/travis_setup_selenium.php --if-env BEHAT_TEST - php ~/travis-support/travis_setup_php54_webserver.php --if-env BEHAT_TEST -script: +script: - "if [ \"$BEHAT_TEST\" = \"\" ]; then vendor/bin/phpunit framework/tests; fi" - "if [ \"$BEHAT_TEST\" = \"1\" ]; then vendor/bin/behat @framework; fi" diff --git a/_config/Oembed.yml b/_config/Oembed.yml index 659d0f3d6..02be4c601 100644 --- a/_config/Oembed.yml +++ b/_config/Oembed.yml @@ -8,6 +8,12 @@ Oembed: 'https://*.youtube.com/watch*': http: 'http://www.youtube.com/oembed/', https: 'https://www.youtube.com/oembed/?scheme=https' + 'http://*.youtu.be/*': + http: 'http://www.youtube.com/oembed/', + https: 'https://www.youtube.com/oembed/?scheme=https' + 'https://youtu.be/*': + http: 'http://www.youtube.com/oembed/', + https: 'https://www.youtube.com/oembed/?scheme=https' 'http://*.flickr.com/*': 'http://www.flickr.com/services/oembed/' 'http://*.viddler.com/*': diff --git a/admin/code/ModelAdmin.php b/admin/code/ModelAdmin.php index 5ef961891..11d2ec2c2 100644 --- a/admin/code/ModelAdmin.php +++ b/admin/code/ModelAdmin.php @@ -120,7 +120,7 @@ abstract class ModelAdmin extends LeftAndMain { public function getEditForm($id = null, $fields = null) { $list = $this->getList(); - $exportButton = new GridFieldExportButton('before'); + $exportButton = new GridFieldExportButton('buttons-before-left'); $exportButton->setExportColumns($this->getExportFields()); $listField = GridField::create( $this->sanitiseClassName($this->modelClass), @@ -129,7 +129,7 @@ abstract class ModelAdmin extends LeftAndMain { $fieldConfig = GridFieldConfig_RecordEditor::create($this->stat('page_length')) ->addComponent($exportButton) ->removeComponentsByType('GridFieldFilterHeader') - ->addComponents(new GridFieldPrintButton('before')) + ->addComponents(new GridFieldPrintButton('buttons-before-left')) ); // Validation diff --git a/admin/css/screen.css b/admin/css/screen.css index 15a7c0d10..53c19c2ab 100644 --- a/admin/css/screen.css +++ b/admin/css/screen.css @@ -141,6 +141,7 @@ body, html { font-size: 12px; line-height: 16px; font-family: Arial, sans-serif; .ui-accordion .ui-accordion-content { border: 1px solid #c0c0c2; border-top: none; } .ui-autocomplete { max-height: 240px; overflow-x: hidden; overflow-y: auto; } +.ui-autocomplete-loading { background-image: url(../images/throbber.gif) !important; background-position: 97% center !important; background-repeat: no-repeat !important; background-size: auto !important; } /** This file defines common styles for form elements used throughout the CMS interface. It is an addition to the base styles defined in framework/css/Form.css. @package framework @subpackage admin */ /** ---------------------------------------------------- Basic form fields ---------------------------------------------------- */ @@ -455,7 +456,7 @@ body.cms { overflow: hidden; } .ss-loading-screen .loading-animation { display: none; position: absolute; left: 50%; margin-left: -21.5px; top: 80%; } /** -------------------------------------------- Actions -------------------------------------------- */ -.cms-content-actions, .cms-preview-controls { margin: 0; padding: 12px 12px; z-index: 0; border-top: 1px solid #cacacc; -moz-box-shadow: 1px 0 0 #ECEFF1, rgba(248, 248, 248, 0.9) 0 1px 0px inset, rgba(201, 205, 206, 0.8) 0 0 1px; -webkit-box-shadow: 1px 0 0 #ECEFF1, rgba(248, 248, 248, 0.9) 0 1px 0px inset, rgba(201, 205, 206, 0.8) 0 0 1px; box-shadow: 1px 0 0 #ECEFF1, rgba(248, 248, 248, 0.9) 0 1px 0px inset, rgba(201, 205, 206, 0.8) 0 0 1px; height: 28px; background-color: #ECEFF1; } +.cms-content-actions, .cms-preview-controls { margin: 0; padding: 12px 12px; z-index: 999; border-top: 1px solid #cacacc; -moz-box-shadow: 1px 0 0 #ECEFF1, rgba(248, 248, 248, 0.9) 0 1px 0px inset, rgba(201, 205, 206, 0.8) 0 0 1px; -webkit-box-shadow: 1px 0 0 #ECEFF1, rgba(248, 248, 248, 0.9) 0 1px 0px inset, rgba(201, 205, 206, 0.8) 0 0 1px; box-shadow: 1px 0 0 #ECEFF1, rgba(248, 248, 248, 0.9) 0 1px 0px inset, rgba(201, 205, 206, 0.8) 0 0 1px; height: 28px; background-color: #ECEFF1; } /** -------------------------------------------- Messages -------------------------------------------- */ .message { display: block; clear: both; margin: 0 0 8px; padding: 10px 12px; font-weight: normal; border: 1px #ccc solid; background: #fff; background: rgba(255, 255, 255, 0.5); text-shadow: none; -moz-border-radius: 3px 3px 3px 3px; -webkit-border-radius: 3px; border-radius: 3px 3px 3px 3px; } diff --git a/admin/javascript/LeftAndMain.Content.js b/admin/javascript/LeftAndMain.Content.js index 7347b7ff9..b041ce30c 100644 --- a/admin/javascript/LeftAndMain.Content.js +++ b/admin/javascript/LeftAndMain.Content.js @@ -46,9 +46,6 @@ // when JSTree auto-selects elements on first load. if(!origEvent) { return false; - }else if($(origEvent.target).hasClass('jstree-icon') || $(origEvent.target).hasClass('jstree-pageicon')){ - // in case the click is not on the node title, ie on pageicon or dragicon, - return false; } // Don't allow checking disabled nodes diff --git a/admin/javascript/LeftAndMain.js b/admin/javascript/LeftAndMain.js index 054373a39..8e424f123 100644 --- a/admin/javascript/LeftAndMain.js +++ b/admin/javascript/LeftAndMain.js @@ -670,8 +670,11 @@ jQuery.noConflict(); // Support a full reload if(xhr.getResponseHeader('X-Reload') && xhr.getResponseHeader('X-ControllerURL')) { - document.location.href = $('base').attr('href').replace(/\/*$/, '') - + '/' + xhr.getResponseHeader('X-ControllerURL'); + var baseUrl = $('base').attr('href'), + rawURL = xhr.getResponseHeader('X-ControllerURL'), + url = $.path.isAbsoluteUrl(rawURL) ? rawURL : $.path.makeUrlAbsolute(rawURL, baseUrl); + + document.location.href = url; return; } diff --git a/admin/javascript/lang/id.js b/admin/javascript/lang/id.js new file mode 100644 index 000000000..ed7c83caa --- /dev/null +++ b/admin/javascript/lang/id.js @@ -0,0 +1,16 @@ +// This file was generated by GenerateJavaScriptI18nTask from javascript/lang/src/id.js. +// See https://github.com/silverstripe/silverstripe-buildtools for details +if(typeof(ss) == 'undefined' || typeof(ss.i18n) == 'undefined') { + if(typeof(console) != 'undefined') console.error('Class ss.i18n not defined'); +} else { + ss.i18n.addDictionary('id', { + "LeftAndMain.CONFIRMUNSAVED": "Anda ingin tinggalkan laman ini?\n\nPERINGATAN: Perubahan tidak akan disimpan.\n\nTekan OK untuk lanjut, atau Batal untuk tetap di laman ini.", + "LeftAndMain.CONFIRMUNSAVEDSHORT": "PERINGATAN: Perubahan tidak akan disimpan.", + "SecurityAdmin.BATCHACTIONSDELETECONFIRM": "Anda ingin menghapus kelompok %s?", + "ModelAdmin.SAVED": "Tersimpan", + "ModelAdmin.REALLYDELETE": "Anda yakin ingin menghapus?", + "ModelAdmin.DELETED": "Terhapus", + "ModelAdmin.VALIDATIONERROR": "Kesalahan Validasi", + "LeftAndMain.PAGEWASDELETED": "Laman sudah terhapus. Untuk mengedit, pilih pada sisi kiri." +}); +} \ No newline at end of file diff --git a/admin/javascript/lang/id_ID.js b/admin/javascript/lang/id_ID.js new file mode 100644 index 000000000..9b2cdedd4 --- /dev/null +++ b/admin/javascript/lang/id_ID.js @@ -0,0 +1,16 @@ +// This file was generated by GenerateJavaScriptI18nTask from javascript/lang/src/id_ID.js. +// See https://github.com/silverstripe/silverstripe-buildtools for details +if(typeof(ss) == 'undefined' || typeof(ss.i18n) == 'undefined') { + if(typeof(console) != 'undefined') console.error('Class ss.i18n not defined'); +} else { + ss.i18n.addDictionary('id_ID', { + "LeftAndMain.CONFIRMUNSAVED": "Anda ingin tinggalkan laman ini?\n\nPERINGATAN: Perubahan tidak akan disimpan.\n\nTekan OK untuk lanjut, atau Batal untuk tetap di laman ini.", + "LeftAndMain.CONFIRMUNSAVEDSHORT": "PERINGATAN: Perubahan tidak akan disimpan.", + "SecurityAdmin.BATCHACTIONSDELETECONFIRM": "Anda ingin menghapus kelompok %s?", + "ModelAdmin.SAVED": "Tersimpan", + "ModelAdmin.REALLYDELETE": "Anda yakin ingin menghapus?", + "ModelAdmin.DELETED": "Terhapus", + "ModelAdmin.VALIDATIONERROR": "Kesalahan Validasi", + "LeftAndMain.PAGEWASDELETED": "Laman sudah terhapus. Untuk mengedit, pilih pada sisi kiri." +}); +} \ No newline at end of file diff --git a/admin/javascript/lang/src/id.js b/admin/javascript/lang/src/id.js new file mode 100644 index 000000000..5485d3f02 --- /dev/null +++ b/admin/javascript/lang/src/id.js @@ -0,0 +1,10 @@ +{ + "LeftAndMain.CONFIRMUNSAVED": "Anda ingin tinggalkan laman ini?\n\nPERINGATAN: Perubahan tidak akan disimpan.\n\nTekan OK untuk lanjut, atau Batal untuk tetap di laman ini.", + "LeftAndMain.CONFIRMUNSAVEDSHORT": "PERINGATAN: Perubahan tidak akan disimpan.", + "SecurityAdmin.BATCHACTIONSDELETECONFIRM": "Anda ingin menghapus kelompok %s?", + "ModelAdmin.SAVED": "Tersimpan", + "ModelAdmin.REALLYDELETE": "Anda yakin ingin menghapus?", + "ModelAdmin.DELETED": "Terhapus", + "ModelAdmin.VALIDATIONERROR": "Kesalahan Validasi", + "LeftAndMain.PAGEWASDELETED": "Laman sudah terhapus. Untuk mengedit, pilih pada sisi kiri." +} \ No newline at end of file diff --git a/admin/javascript/lang/src/id_ID.js b/admin/javascript/lang/src/id_ID.js new file mode 100644 index 000000000..5485d3f02 --- /dev/null +++ b/admin/javascript/lang/src/id_ID.js @@ -0,0 +1,10 @@ +{ + "LeftAndMain.CONFIRMUNSAVED": "Anda ingin tinggalkan laman ini?\n\nPERINGATAN: Perubahan tidak akan disimpan.\n\nTekan OK untuk lanjut, atau Batal untuk tetap di laman ini.", + "LeftAndMain.CONFIRMUNSAVEDSHORT": "PERINGATAN: Perubahan tidak akan disimpan.", + "SecurityAdmin.BATCHACTIONSDELETECONFIRM": "Anda ingin menghapus kelompok %s?", + "ModelAdmin.SAVED": "Tersimpan", + "ModelAdmin.REALLYDELETE": "Anda yakin ingin menghapus?", + "ModelAdmin.DELETED": "Terhapus", + "ModelAdmin.VALIDATIONERROR": "Kesalahan Validasi", + "LeftAndMain.PAGEWASDELETED": "Laman sudah terhapus. Untuk mengedit, pilih pada sisi kiri." +} \ No newline at end of file diff --git a/admin/javascript/lang/src/sv.js b/admin/javascript/lang/src/sv.js index 9ae79d583..38a9630b6 100644 --- a/admin/javascript/lang/src/sv.js +++ b/admin/javascript/lang/src/sv.js @@ -6,5 +6,5 @@ "ModelAdmin.REALLYDELETE": "Vill du verkligen radera?", "ModelAdmin.DELETED": "Raderad", "ModelAdmin.VALIDATIONERROR": "Valideringsfel", - "LeftAndMain.PAGEWASDELETED": "Sidan raderades. För att redigera en sida, välj den från menyn till vänster." + "LeftAndMain.PAGEWASDELETED": "Sidan raderades. För att redigera en sida, välj den i menyn till vänster." } \ No newline at end of file diff --git a/admin/javascript/lang/sv.js b/admin/javascript/lang/sv.js index 20a1034e0..c3428b51d 100644 --- a/admin/javascript/lang/sv.js +++ b/admin/javascript/lang/sv.js @@ -11,6 +11,6 @@ if(typeof(ss) == 'undefined' || typeof(ss.i18n) == 'undefined') { "ModelAdmin.REALLYDELETE": "Vill du verkligen radera?", "ModelAdmin.DELETED": "Raderad", "ModelAdmin.VALIDATIONERROR": "Valideringsfel", - "LeftAndMain.PAGEWASDELETED": "Sidan raderades. För att redigera en sida, välj den från menyn till vänster." + "LeftAndMain.PAGEWASDELETED": "Sidan raderades. För att redigera en sida, välj den i menyn till vänster." }); } \ No newline at end of file diff --git a/admin/scss/_style.scss b/admin/scss/_style.scss index e0a2729d9..8cc272c47 100644 --- a/admin/scss/_style.scss +++ b/admin/scss/_style.scss @@ -429,7 +429,7 @@ body.cms { .cms-content-actions, .cms-preview-controls { margin: 0; padding: $grid-y*1.5 $grid-y*1.5; - z-index: 0; + z-index: 999; border-top: 1px solid lighten($color-separator, 4%); @include box-shadow( 1px 0 0 $tab-panel-texture-color, diff --git a/admin/scss/_uitheme.scss b/admin/scss/_uitheme.scss index 4449a2f5b..11a57139b 100644 --- a/admin/scss/_uitheme.scss +++ b/admin/scss/_uitheme.scss @@ -85,8 +85,16 @@ } } -.ui-autocomplete{ +.ui-autocomplete { max-height: 240px; overflow-x: hidden; overflow-y: auto; + + /** sorry about the !important but the specificity of other selectors mandates it over writing out very specific selectors **/ + &-loading { + background-image: url(../images/throbber.gif) !important; + background-position: 97% center !important; + background-repeat: no-repeat !important; + background-size: auto !important; + } } diff --git a/control/Controller.php b/control/Controller.php index 1680f36d8..43a93b8ae 100644 --- a/control/Controller.php +++ b/control/Controller.php @@ -501,6 +501,7 @@ class Controller extends RequestHandler implements TemplateGlobalProvider { // absolute redirection URLs not located on this site may cause phishing if(Director::is_site_url($url)) { + $url = Director::absoluteURL($url, true); return $this->redirect($url); } else { return false; diff --git a/control/Director.php b/control/Director.php index 865f52ce4..f069e2cc8 100644 --- a/control/Director.php +++ b/control/Director.php @@ -510,14 +510,16 @@ class Director implements TemplateGlobalProvider { if ($protocol = Config::inst()->get('Director', 'alternate_protocol')) { $return = ($protocol == 'https'); } else if( - isset($_SERVER['HTTP_X_FORWARDED_PROTO']) + TRUSTED_PROXY + && isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https' ) { // Convention for (non-standard) proxy signaling a HTTPS forward, // see https://en.wikipedia.org/wiki/List_of_HTTP_header_fields $return = true; } else if( - isset($_SERVER['HTTP_X_FORWARDED_PROTOCOL']) + TRUSTED_PROXY + && isset($_SERVER['HTTP_X_FORWARDED_PROTOCOL']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTOCOL']) == 'https' ) { // Less conventional proxy header diff --git a/control/HTTPRequest.php b/control/HTTPRequest.php index 62229e2f4..3a8756d31 100644 --- a/control/HTTPRequest.php +++ b/control/HTTPRequest.php @@ -655,10 +655,10 @@ class SS_HTTPRequest implements ArrayAccess { * @return string */ public function getIP() { - if (!empty($_SERVER['HTTP_CLIENT_IP'])) { + if (TRUSTED_PROXY && !empty($_SERVER['HTTP_CLIENT_IP'])) { //check ip from share internet return $_SERVER['HTTP_CLIENT_IP']; - } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { + } elseif (TRUSTED_PROXY && !empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { //to check ip is pass from proxy return $_SERVER['HTTP_X_FORWARDED_FOR']; } elseif(isset($_SERVER['REMOTE_ADDR'])) { diff --git a/control/HTTPResponse.php b/control/HTTPResponse.php index 061c09311..40d1db497 100644 --- a/control/HTTPResponse.php +++ b/control/HTTPResponse.php @@ -286,7 +286,7 @@ EOT * @return bool */ public function isFinished() { - return in_array($this->statusCode, array(301, 302, 401, 403)); + return in_array($this->statusCode, array(301, 302, 303, 304, 305, 307, 401, 403)); } } diff --git a/core/Constants.php b/core/Constants.php index 7c5a526d2..86655be76 100644 --- a/core/Constants.php +++ b/core/Constants.php @@ -23,6 +23,8 @@ * - FRAMEWORK_ADMIN_PATH: Absolute filepath, e.g. "/var/www/my-webroot/framework/admin" * - THIRDPARTY_DIR: Path relative to webroot, e.g. "framework/thirdparty" * - THIRDPARTY_PATH: Absolute filepath, e.g. "/var/www/my-webroot/framework/thirdparty" + * - TRUSTED_PROXY: true or false, depending on whether the X-Forwarded-* HTTP + * headers from the given client are trustworthy (e.g. from a reverse proxy). * * @package framework * @subpackage core @@ -85,6 +87,35 @@ function stripslashes_recursively(&$array) { } } +/** + * Validate whether the request comes directly from a trusted server or not + * This is necessary to validate whether or not the values of X-Forwarded- + * or Client-IP HTTP headers can be trusted + */ +if(!defined('TRUSTED_PROXY')) { + $trusted = true; // will be false by default in a future release + + if(getenv('BlockUntrustedProxyHeaders') // Legacy setting (reverted from documentation) + || getenv('BlockUntrustedIPs') // Documented setting + || defined('SS_TRUSTED_PROXY_IPS') + ) { + $trusted = false; + + if(defined('SS_TRUSTED_PROXY_IPS') && SS_TRUSTED_PROXY_IPS !== 'none') { + if(SS_TRUSTED_PROXY_IPS === '*') { + $trusted = true; + } elseif(isset($_SERVER['REMOTE_ADDR'])) { + $trusted = in_array($_SERVER['REMOTE_ADDR'], explode(',', SS_TRUSTED_PROXY_IPS)); + } + } + } + + /** + * Declare whether or not the connecting server is a trusted proxy + */ + define('TRUSTED_PROXY', $trusted); +} + /** * A blank HTTP_HOST value is used to detect command-line execution. * We update the $_SERVER variable to contain data consistent with the rest of the application. @@ -147,12 +178,21 @@ if(!isset($_SERVER['HTTP_HOST'])) { /** * Fix HTTP_HOST from reverse proxies */ - if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { + if (TRUSTED_PROXY && isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { + // Get the first host, in case there's multiple separated through commas $_SERVER['HTTP_HOST'] = strtok($_SERVER['HTTP_X_FORWARDED_HOST'], ','); } } +if (defined('SS_ALLOWED_HOSTS')) { + $all_allowed_hosts = explode(',', SS_ALLOWED_HOSTS); + if (!in_array($_SERVER['HTTP_HOST'], $all_allowed_hosts)) { + header('HTTP/1.1 400 Invalid Host', true, 400); + die(); + } +} + /** * Define system paths */ diff --git a/core/startup/ParameterConfirmationToken.php b/core/startup/ParameterConfirmationToken.php index 18546d5d4..206e8f302 100644 --- a/core/startup/ParameterConfirmationToken.php +++ b/core/startup/ParameterConfirmationToken.php @@ -11,14 +11,37 @@ * It will likely be heavily refactored before the release of 3.2 */ class ParameterConfirmationToken { + + /** + * The name of the parameter + * + * @var string + */ protected $parameterName = null; + + /** + * The parameter given + * + * @var string|null The string value, or null if not provided + */ protected $parameter = null; + + /** + * The validated and checked token for this parameter + * + * @var string|null A string value, or null if either not provided or invalid + */ protected $token = null; protected function pathForToken($token) { return TEMP_FOLDER.'/token_'.preg_replace('/[^a-z0-9]+/', '', $token); } + /** + * Generate a new random token and store it + * + * @return string Token name + */ protected function genToken() { // Generate a new random token (as random as possible) require_once(dirname(dirname(dirname(__FILE__))).'/security/RandomGenerator.php'); @@ -31,7 +54,17 @@ class ParameterConfirmationToken { return $token; } + /** + * Validate a token + * + * @param string $token + * @return boolean True if the token is valid + */ protected function checkToken($token) { + if(!$token) { + return false; + } + $file = $this->pathForToken($token); $content = null; @@ -43,16 +76,23 @@ class ParameterConfirmationToken { return $content == $token; } + /** + * Create a new ParameterConfirmationToken + * + * @param string $parameterName Name of the querystring parameter to check + */ public function __construct($parameterName) { // Store the parameter name $this->parameterName = $parameterName; + // Store the parameter value $this->parameter = isset($_GET[$parameterName]) ? $_GET[$parameterName] : null; - // Store the token - $this->token = isset($_GET[$parameterName.'token']) ? $_GET[$parameterName.'token'] : null; - // If a token was provided, but isn't valid, ignore it - if ($this->token && (!$this->checkToken($this->token))) $this->token = null; + // If the token provided is valid, mark it as such + $token = isset($_GET[$parameterName.'token']) ? $_GET[$parameterName.'token'] : null; + if ($this->checkToken($token)) { + $this->token = $token; + } } /** @@ -66,7 +106,8 @@ class ParameterConfirmationToken { /** * Is the parameter requested? - * + * ?parameter and ?parameter=1 are both considered requested + * * @return bool */ public function parameterProvided() { @@ -75,11 +116,12 @@ class ParameterConfirmationToken { /** * Is the necessary token provided for this parameter? - * + * A value must be provided for the token + * * @return bool */ public function tokenProvided() { - return $this->token !== null; + return !empty($this->token); } /** @@ -98,6 +140,11 @@ class ParameterConfirmationToken { unset($_GET[$this->parameterName]); } + /** + * Determine the querystring parameters to include + * + * @return array List of querystring parameters with name and token parameters + */ public function params() { return array( $this->parameterName => $this->parameter, @@ -114,14 +161,16 @@ class ParameterConfirmationToken { // Are we http or https? Replicates Director::is_https() without its dependencies/ $proto = 'http'; if( - isset($_SERVER['HTTP_X_FORWARDED_PROTO']) + TRUSTED_PROXY + && isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https' ) { // Convention for (non-standard) proxy signaling a HTTPS forward, // see https://en.wikipedia.org/wiki/List_of_HTTP_header_fields $proto = 'https'; } else if( - isset($_SERVER['HTTP_X_FORWARDED_PROTOCOL']) + TRUSTED_PROXY + && isset($_SERVER['HTTP_X_FORWARDED_PROTOCOL']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTOCOL']) == 'https' ) { // Less conventional proxy header @@ -154,6 +203,10 @@ class ParameterConfirmationToken { return "$proto://" . preg_replace('#/{2,}#', '/', implode('/', $parts)); } + /** + * Forces a reload of the request with the token included + * This method will terminate the script with `die` + */ public function reloadWithToken() { $location = $this->currentAbsoluteURL(); @@ -179,7 +232,7 @@ You are being redirected. If you are not redirected soon, cl * Given a list of token names, suppress all tokens that have not been validated, and * return the non-validated token with the highest priority * - * @param type $keys List of token keys in ascending priority (low to high) + * @param array $keys List of token keys in ascending priority (low to high) * @return ParameterConfirmationToken The token container for the unvalidated $key given with the highest priority */ public static function prepare_tokens($keys) { diff --git a/css/GridField.css b/css/GridField.css index 1da9ca33e..c671c0695 100644 --- a/css/GridField.css +++ b/css/GridField.css @@ -68,11 +68,14 @@ Used in side panels and action tabs .cms table.ss-gridfield-table tr.sortable-header { background: #dbe3e8; } .cms table.ss-gridfield-table tr.sortable-header th { padding: 0; font-weight: normal; } .cms table.ss-gridfield-table tr.sortable-header th .ss-ui-button { font-weight: normal; } -.cms table.ss-gridfield-table tr:hover { background: #FFFAD6 !important; } +.cms table.ss-gridfield-table tr:hover { background: #FFFAD6; } .cms table.ss-gridfield-table tr:first-child { background: transparent; } +.cms table.ss-gridfield-table tr:first-child:hover { background: #FFFAD6; } .cms table.ss-gridfield-table tr.ss-gridfield-even { background: #F0F4F7; } .cms table.ss-gridfield-table tr.ss-gridfield-even.ss-gridfield-last { border-bottom: none; } +.cms table.ss-gridfield-table tr.ss-gridfield-even:hover { background: #FFFAD6; } .cms table.ss-gridfield-table tr.even { background: #F0F4F7; } +.cms table.ss-gridfield-table tr.even:hover { background: #FFFAD6; } .cms table.ss-gridfield-table tr th { font-weight: bold; font-size: 12px; color: #FFF; padding: 5px; border-right: 1px solid rgba(0, 0, 0, 0.1); } .cms table.ss-gridfield-table tr th div.fieldgroup, .cms table.ss-gridfield-table tr th div.fieldgroup-field { width: 100%; position: relative; } .cms table.ss-gridfield-table tr th div.fieldgroup { min-width: 200px; padding-right: 0; } diff --git a/dev/FixtureBlueprint.php b/dev/FixtureBlueprint.php index 388c273a4..3c77b50d9 100644 --- a/dev/FixtureBlueprint.php +++ b/dev/FixtureBlueprint.php @@ -190,13 +190,7 @@ class FixtureBlueprint { // If LastEdited was set in the fixture, set it here if($data && array_key_exists('LastEdited', $data)) { - $edited = $this->parseValue($data['LastEdited'], $fixtures); - $update = new SQLUpdate( - $class, - array('"LastEdited"' => $edited), - array('"ID"' => $obj->id) - ); - $update->execute(); + $this->overrideField($obj, 'LastEdited', $data['LastEdited'], $fixtures); } } catch(Exception $e) { Config::inst()->update('DataObject', 'validation_enabled', $validationenabled); @@ -297,4 +291,17 @@ class FixtureBlueprint { $obj->$name = $this->parseValue($value, $fixtures); } -} + protected function overrideField($obj, $fieldName, $value, $fixtures = null) { + $table = ClassInfo::table_for_object_field(get_class($obj), $fieldName); + $value = $this->parseValue($value, $fixtures); + + DB::manipulate(array( + $table => array( + "command" => "update", "id" => $obj->ID, + "fields" => array($fieldName => is_string($value) ? "'$value'" : $value) + ) + )); + $obj->$fieldName = $value; + } + +} \ No newline at end of file diff --git a/docs/en/00_Getting_Started/01_Installation/02_Mac_OSX.md b/docs/en/00_Getting_Started/01_Installation/02_Mac_OSX.md index ac1bfecff..92ee440db 100644 --- a/docs/en/00_Getting_Started/01_Installation/02_Mac_OSX.md +++ b/docs/en/00_Getting_Started/01_Installation/02_Mac_OSX.md @@ -1,75 +1,49 @@ -# Mac OSX +# Mac OSX with MAMP -This topic covers setting up your Mac as a Web Server and installing SilverStripe. +This topic covers setting up your Mac as a web server and installing SilverStripe. -While OSX Comes bundled with PHP and Apache (Thanks Apple!) Its not quite ideal for SilverStripe so for setting up a -webserver on OSX we suggest using [MAMP](http://www.mamp.info/en/index.php) or using [MacPorts](http://www.macports.org/) -to manage your packages. +OSX comes bundled with PHP and Apache, but you're stuck with the versions it ships with. +It is also a bit harder to install additional PHP modules required by SilverStripe. +[MAMP](http://www.mamp.info/en/) is a simple way to get a complete webserver +environment going on your OSX machine, without removing or altering any system-level configuration. -If you want to use the default OSX PHP version then you will need to recompile your own versions of PHP with GD. Providing instructions -for how to recompile PHP is beyond the scope of our documentation but try an online search. +Check out the [MAC OSX with Homebrew](other_installation_options/Mac_OSX_Homebrew) +for an alternative, more configurable installation process. -## Installing MAMP +## Requirements -If you have decided to install using MacPorts you can skip this section. +Please check the [system requirements](http://www.mamp.info/en/documentation/) for MAMP, +you'll need a fairly new version of OSX to run it. -Once you have downloaded and Installed MAMP start the Application and Make sure everything is running by clicking the -MAMP icon. Under `Preferences -> PHP` make sure Version 5 is Selected. +## MAMP Installation -Open up `/Applications/MAMP/conf/PHP5/php.ini` and make the following configuration changes: + * [Download MAMP](http://www.mamp.info/en/) + * Install and start MAMP + * Check out your new web server environment on `http://localhost:8888` - memory_limit = 64M +## SilverStripe Installation -Once you make that change open the MAMP App Again by clicking on the MAMP Icon and click Stop Servers then Start -Servers - this is so our changes to the php.ini take effect. +[Composer](http://getcomposer.org) is a dependancy manager for PHP, and the preferred way to +install SilverStripe. It ensures that you get the correct set of files for your project. +Composer uses your MAMP PHP executable to run and also requires [git](http://git-scm.com) +to automatically download the required files from GitHub and other repositories. -## Installing SilverStripe +In order to install Composer, we need to let the system know where to find the PHP executable. +Open or create the `~/.bash_profile` file in your home folder, then add the following line: +`export PATH=/Applications/MAMP/bin/php/php5.5.22/bin:$PATH` +You'll need to adjust the PHP version number (`php5.5.22`). The currently running PHP version is shown on `http://localhost:8888/MAMP/index.php?page=phpinfo`. +Run `source ~/.bash_profile` for the changes to take effect. You can verify that the correct executable +is used by running `which php`. It should show the path to MAMP from above. -### Composer -[Composer (a dependancy manager for PHP)](http://getcomposer.org) is the preferred way to install SilverStripe and ensure you get the correct set of files for your project. +Now you're ready to install Composer: Run `curl -sS https://getcomposer.org/installer | php`. +We recommend that you make the `composer` executable available globally, +which requires moving the file to a different folder. Run `mv composer.phar /usr/local/bin/composer`. +More detailed installation instructions are available on [getcomposer.org](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx). +You can verify the installation by typing the `composer` command, which should show you a command overview. -Composer uses your MAMP PHP executable to run and also requires [git](http://git-scm.com) (so it can automatically download the required files from GitHub). +Finally, we're ready to install SilverStripe through composer: +`composer create-project silverstripe/installer /Applications/MAMP/htdocs/silverstripe/`. +After finishing, the installation wizard should be available at `http://localhost:8888/silverstripe`. +The MAMP default database credentials are user `root` and password `root`. -#### Install composer using MAMP - 1. First create an alias for our bash profile, using your preferred terminal text editor (nano, vim, etc) open `~/.bash_profile`. - - 2. Add the following line (adjusting the version number of PHP to your installation of MAMP): `alias phpmamp='/Applications/MAMP/bin/php/php5.4.10/bin/php'`. - - 3. The run `. ~/.bash_profile` to reload the bash profile and make it accessible. - - 4. This will create an alias, `phpmamp`, allowing you to use the MAMP installation of PHP. Please take note of the PHP version, in this case 5.4.10, as with different versions of MAMP this may be different. Check your installation and see what version you have, and replace the number accordingly (this was written with MAMP version 2.1.2). - - 5. With that setup, we are ready to install `composer`. This is a two step process if we would like this to be installed globally (only do the first step if you would like `composer` installed to the local working directory only). - - First, run the following command in the terminal: `curl -sS https://getcomposer.org/installer | phpmamp` - - We are using `phpmamp` so that we correctly use the MAMP installation of PHP from above. - - - Second, if you want to make composer available globally, we need to move the file to '/usr/local/bin/composer'. To do this, run the following command: - `sudo mv composer.phar /usr/local/bin/composer` - - Terminal will ask you for your root password, after entering it and pressing the 'return' (or enter) key, you'll have a working global installation of composer on your mac that uses MAMP. - - 6. You can verify your installation worked by typing the following command: - `composer` - It'll show you the current version and a list of commands you can use. - - 7. Run the following command to get a fresh copy of SilverStripe via composer: - - `composer create-project silverstripe/installer /Applications/MAMP/htdocs/silverstripe/` - - 8. You can now [use composer](http://doc.silverstripe.org/framework/en/getting_started/composer/) to manage future SilverStripe updates and adding modules with a few easy commands. - - -### Package Download - -[Download](http://silverstripe.org/software/download/) the latest SilverStripe installer package. Copy the tar.gz or zip file to the 'Document Root' for MAMP - By Default its `/Applications/MAMP/htdocs`. -Don't know what your Document Root is? Open MAMP Click `Preferences -> Apache`. - -Extract the tar.gz file to a folder, e.g. `silverstripe/` (you always move the tar.gz file first and not the other way -around as SilverStripe uses a '.htaccess' file which is hidden from OSX so if you move SilverStripe the .htaccess file -won't come along. - -### Run the installation wizard -Once you have a copy of the required code (by either of the above methods), open your web browser and go to `http://localhost:8888/silverstripe/`. Enter your database details - by default with MAMP its user `root` and password `root` and select your account details. Click "Check Details". - -Once everything is sorted hit "Install!" and Voila, you have SilverStripe installed +We have a separate in-depth tutorial for [Composer Installation and Usage](composer). \ No newline at end of file diff --git a/docs/en/00_Getting_Started/01_Installation/04_Other_installation_Options/Mac_OSX_Homebrew.md b/docs/en/00_Getting_Started/01_Installation/04_Other_installation_Options/Mac_OSX_Homebrew.md new file mode 100644 index 000000000..2806c804b --- /dev/null +++ b/docs/en/00_Getting_Started/01_Installation/04_Other_installation_Options/Mac_OSX_Homebrew.md @@ -0,0 +1,118 @@ +# Mac OSX with Homebrew + +This topic covers setting up your Mac as a web server and installing SilverStripe. + +OSX comes bundled with PHP, but you're stuck with the version and modules it ships with. +If you run projects on different PHP versions, or care about additional PHP module support +and other dependencies such as MariaDB, we recommend an installation through [Homebrew](http://brew.sh/). + +Check out the [MAC OSX with MAMP](../Mac_OSX) for an alternative installation process +which packages up the whole environment into a convenient application. + +## Requirements + +Since we're compiling PHP, some build tooling is required. +Run the following command to install Xcode Command Line Tools. + + xcode-select --install + +Now you can install Homebrew itself: + + ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + +## Install PHP + +First we're telling Homebrew about some new repositories to get the PHP installation from: + + brew tap homebrew/dupes + brew tap homebrew/php + +We're installing PHP 5.5 here, with the required `mcrypt` module: + + brew install php55 php55-mcrypt + +There's a [Homebrew Troubleshooting](https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Troubleshooting.md) guide if Homebrew doesn't work out as expected (run `brew update` and `brew doctor`). + +Have a look at the [brew-php-switcher](https://github.com/philcook/brew-php-switcher) +project to install multiple PHP versions in parallel and switch between them easily. + +## Install the Database (MariaDB/MySQL) + + brew install mariadb + unset TMPDIR + mysql_install_db --user=`whoami` --basedir="$(brew --prefix mariadb)" --datadir=/usr/local/var/mysql --tmpdir=/tmp + mysql.server start + '/usr/local/opt/mariadb/bin/mysql_secure_installation' + +To start the database server on boot, run the following: + + ln -sfv /usr/local/opt/mariadb/*.plist ~/Library/LaunchAgents + +You can also use `mysql.server start` and `mysql.server stop` on demand. + +## Configure PHP and Apache + +We're not installing Apache, since OSX already ships with a perfectly fine installation of it. + +Edit the existing configuration at `/etc/apache2/httpd.conf`, +and uncomment/add the following lines to activate the required modules: + + LoadModule rewrite_module libexec/apache2/mod_rewrite.so + LoadModule php5_module /usr/local/opt/php55/libexec/apache2/libphp5.so + +Change the `DocumentRoot` setting to your user folder (replacing `` with your OSX user name): + + DocumentRoot "/Users//Sites" + +Now find the section starting with `` and change it as follows, +again replacing `` with your OSX user name: + + /Sites"> + Options FollowSymLinks Multiviews + MultiviewsMatch Any + AllowOverride All + Require all granted + + +We also recommend running the web server process with your own user on a development environment, +since it makes permissions easier to handle when running commands both +from the command line and through the web server. Find and adjust the following options, +replacing the `` placeholder: + + User + Group staff + +Now start the web server: + + sudo apachectl start + +Every configuration change requires a restart: + + sudo apachectl restart + +You can also load this webserver on boot: + + sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist + +After starting the webserver, you should see a simple "Forbidden" page generated by Apache +when accessing `http://localhost`. + +## SilverStripe Installation + +[Composer](http://getcomposer.org) is a dependancy manager for PHP, and the preferred way to +install SilverStripe. It ensures that you get the correct set of files for your project. +Composer uses the PHP executable we've just installed. It also needs [git](http://git-scm.com) +to automatically download the required files from GitHub and other repositories. + +Run `curl -sS https://getcomposer.org/installer | php` to install the `composer` executable. +We recommend that you make the executable available globally, +which requires moving the file to a different folder. Run `mv composer.phar /usr/local/bin/composer`. +More detailed installation instructions are available on [getcomposer.org](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx). +You can verify the installation by typing the `composer` command, which should show you a command overview. + +Finally, we're ready to install SilverStripe through composer: +`composer create-project silverstripe/installer /Users//Sites/silverstripe/`. +After finishing, the installation wizard should be available at `http://localhost/silverstripe`. +The Homebrew MariaDB default database credentials are user `root` and password `root`. + +We have a separate in-depth tutorial for [Composer Installation and Usage](composer). \ No newline at end of file diff --git a/docs/en/00_Getting_Started/01_Installation/04_Other_installation_Options/Windows_IIS6.md b/docs/en/00_Getting_Started/01_Installation/04_Other_installation_Options/Windows_IIS6.md deleted file mode 100644 index 0ad4ee086..000000000 --- a/docs/en/00_Getting_Started/01_Installation/04_Other_installation_Options/Windows_IIS6.md +++ /dev/null @@ -1,152 +0,0 @@ -# Install SilverStripe manually on Windows using IIS 6 - -
Note: These instructions may not work, as they're no longer maintained.
- -How to prepare Windows Server 2003 for SilverStripe using IIS 6 and FastCGI. - -This guide will work for the following operating systems: - - * Windows Server 2003 - * Windows Server 2003 R2 - -Database install and configuration is not covered here, it is assumed you will do this yourself. - -PHP comes with MySQL support out of the box, but you will need to install the [SQL Server Driver for PHP](http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=80e44913-24b4-4113-8807-caae6cf2ca05) -from Microsoft if you want to use SQL Server. - -## Preparation - -Open **Windows Update** and make sure everything is updated, including optional updates. It is important that all .NET Framework updates including service packs are installed. - -## Install IIS - - - Open **Control Panel** > **Add/Remove Programs** - - Click **Add/Remove Windows Components** on the left hand bar - - Check **Application Server** and then click **Next** to install it - -## Install FastCGI for IIS - - - Download and install this package: http://www.iis.net/download/fastcgi - - Open **inetmgr.exe** - - Right click **Web Sites** and go to **Properties** - - Click the **Home Directory** tab - - Click **Configuration...** then **Add** - - In the **Add/Edit Extension Mapping** dialog, click **Browse...** and navigate to fcgiext.dll which is located in %windir%\system32\inetsrv - - In the **Extension** text box, enter **.php** - - Under **Verbs** in the **Limit to** text box, enter **GET,HEAD,POST** - - Ensure that the **Script engine** and **Verify that file exists** boxes are checked then click **OK** - - Open fcgiext.ini located in %windir%\system32\inetsrv. In the [Types] section of the file, add **php=PHP** - - Create a new section called **[PHP]** at the bottom of the file, like this: - - [PHP] - ExePath=c:\php5\php-cgi.exe - -Finally, run these commands in **Command Prompt** - - cd %windir%\system32\inetsrv - cscript fcgiconfig.js -set -section:"PHP" -InstanceMaxRequests:10000 - cscript fcgiconfig.js -set -section:"PHP" -EnvironmentVars:PHP_FCGI_MAX_REQUESTS:10000 - cscript fcgiconfig.js -set -section:"PHP" -ActivityTimeout:300 - -## Install PHP - - - [Download PHP](http://windows.php.net/download) (**Zip** link underneath the **VC9 x86 Non Thread Safe** section) - - [Download WinCache](http://www.iis.net/download/WinCacheForPHP) (**WinCache 1.1 for PHP 5.3**) - - Extract the PHP zip contents to **c:\php5** - - Run the WinCache self-extractor and extract to **c:\php5\ext**. A file called **php_wincache.dll** should now reside in **c:\php5\ext** - - Rename **php.ini-development** to **php.ini** in **c:\php5** - - Open **php.ini**, located in **c:\php5** with **Notepad** or another editor like **Notepad++** - - Search for **date.timezone**, uncomment it by removing the semicolon and set a timezone from here: http://php.net/manual/en/timezones.php - - Search for **fastcgi.impersonate**, uncomment it by removing the semicolon and set it like this: **fastcgi.impersonate = 1** - - Search for **cgi.fix_pathinfo**, uncomment it by removing the semicolon and set it like this: **cgi.fix_pathinfo = 1** - - Search for **cgi.force_redirect**, uncomment it by removing the semicolon and set it like this: **cgi.force_redirect = 0** - - Search for **fastcgi.logging**, uncomment it by removing the semicolon and set it like this: **fastcgi.logging = 0** - - Search for **extension_dir** and make sure it looks like this: **extension_dir = "ext"** (use proper double quotation characters here) - - Find the "Dynamic Extensions" part of the file, and replace all extension entries with the following: - - ;extension=php_bz2.dll - extension=php_curl.dll - ;extension=php_enchant.dll - ;extension=php_exif.dll - ;extension=php_fileinfo.dll - extension=php_gd2.dll - ;extension=php_gettext.dll - ;extension=php_gmp.dll - ;extension=php_imap.dll - ;extension=php_intl.dll - ;extension=php_ldap.dll - extension=php_mbstring.dll - extension=php_mysql.dll - extension=php_mysqli.dll - ;extension=php_oci8.dll - ;extension=php_oci8_11g.dll - ;extension=php_openssl.dll - ;extension=php_pdo_mysql.dll - ;extension=php_pdo_oci.dll - ;extension=php_pdo_odbc.dll - ;extension=php_pdo_pgsql.dll - ;extension=php_pdo_sqlite.dll - ;extension=php_pgsql.dll - ;extension=php_shmop.dll - ;extension=php_snmp.dll - ;extension=php_soap.dll - ;extension=php_sockets.dll - ;extension=php_sqlite3.dll - ;extension=php_sqlite.dll - extension=php_tidy.dll - extension=php_wincache.dll - ;extension=php_xmlrpc.dll - ;extension=php_xsl.dll - -This is a minimal set of loaded extensions which will get you started. - -If want to use **SQL Server** as a database, you will need to install the [SQL Server Driver for PHP](http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=80e44913-24b4-4113-8807-caae6cf2ca05) and add an extension entry for it to the list above. - -## Test PHP - - - Open **Command Prompt** and type the following: - c:\php5\php.exe -v - -You should see some output showing the PHP version. If you get something else, or nothing at all, then there are missing updates for your copy of Windows Server 2003. Open **Windows Update** and make sure you've updated everything including optional updates. - -## Install SilverStripe - - - [Download SilverStripe](http://silverstripe.org/downloads) - - Extract the download contents to **C:\Inetpub\wwwroot\silverstripe** - - Open **inetmgr.exe** - - Right click **Web Sites** and go to **New** > **Web Site** - - Fill in all appropriate details. If you enter **(All Unassigned)** for the IP address field, make sure the port is something other than **80**, as this will conflict with "Default Web Site" in IIS. When asked for path, enter **C:\Inetpub\wwwroot\silverstripe** - - Browse to **http://localhost:8888** or to the IP address you just assigned in your browser. - -An installation screen should appear. There may be some permission problems, which you should be able to correct by assigning the **Users** group write permissions by right clicking files / folders in Windows Explorer and going to **Properties** then the **Security** tab. - -When ready, hit **Install SilverStripe**. - -SilverStripe should now be installed and you should have a basic site with three pages. - -However, URLs will not look "nice", like this: http://localhost/index.php/about-us. In order to fix this problem, we need to install a third-party URL rewriting tool, as IIS 6 does not support this natively. - -Proceed to **Install IIRF** below to enable nice URLs. - -## Install IIRF - -At the moment, all URLs will have index.php in them. This is because IIS does not support URL rewriting. To make this work, we need to install IIRF which is a third-party plugin for IIS. - - - [Download IIRF](http://iirf.codeplex.com/releases/view/36814) and install it - - Create a new file called iirf.ini in C:\inetpub\wwwroot\silverstripe with this content - RewriteEngine On - MaxMatchCount 10 - IterationLimit 5 - # URLs with query strings - # Don't catch successful file references - RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^(.*)\?(.+)$ /framework/main.php?url=$1&$2 - # URLs without query strings - RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^(.*)$ /framework/main.php?url=$1 - -Friendly URLs should now be working when you browse to your site. - -Remember that IIRF works on a per-virtual host basis. This means for each site you want IIRF to work for, you need to add a new entry to **Web Sites** in **inetmgr.exe**. - -Thanks to **kcd** for the rules: [http://www.silverstripe.org/installing-silverstripe/show/10488#post294415](http://www.silverstripe.org/installing-silverstripe/show/10488#post294415) diff --git a/docs/en/00_Getting_Started/01_Installation/How_To/Configure_Nginx.md b/docs/en/00_Getting_Started/01_Installation/How_To/Configure_Nginx.md index ff0b9c6cd..a8ae1cbd3 100644 --- a/docs/en/00_Getting_Started/01_Installation/How_To/Configure_Nginx.md +++ b/docs/en/00_Getting_Started/01_Installation/How_To/Configure_Nginx.md @@ -8,12 +8,14 @@ able to run PHP files via the FastCGI-wrapper from Nginx. Now you need to set up a virtual host in Nginx with configuration settings that are similar to those shown below. +
If you don't fully understand the configuration presented here, consult the [nginx documentation](http://nginx.org/en/docs/). Especially be aware of [accidental php-execution](https://nealpoole.com/blog/2011/04/setting-up-php-fastcgi-and-nginx-dont-trust-the-tutorials-check-your-configuration/ "Don't trust the tutorials") when extending the configuration.
+ But enough of the disclaimer, on to the actual configuration — typically in `nginx.conf`: server { @@ -21,6 +23,11 @@ But enough of the disclaimer, on to the actual configuration — typically in `n root /path/to/ss/folder; server_name site.com www.site.com; + + # Defend against SS-2015-013 -- http://www.silverstripe.org/software/download/security-releases/ss-2015-013 + if ($http_x_forwarded_host) { + return 400; + } location / { try_files $uri /framework/main.php?url=$uri&$query_string; diff --git a/docs/en/00_Getting_Started/01_Installation/index.md b/docs/en/00_Getting_Started/01_Installation/index.md index 9b90f4122..d8daddbbd 100644 --- a/docs/en/00_Getting_Started/01_Installation/index.md +++ b/docs/en/00_Getting_Started/01_Installation/index.md @@ -1,19 +1,16 @@ # Installation -These instructions show you how to install SilverStripe on any web server. -The best way to install from the source code is to use [Composer](../composer). +These instructions show you how to install SilverStripe on any web server. Check out our operating system specific guides for [Linux](linux_unix), [Windows Server](windows) and [Mac OSX](mac_osx). ## Installation Steps -* [Download](http://silverstripe.org/download) the installer package -* Make sure the webserver has MySQL and PHP support. See [Server Requirements](../server_requirements) for more information. -* Unpack the installer somewhere into your web-root. Usually the www folder or similar. Most downloads from SilverStripe -are compressed tarballs. To extract these files you can either do them natively (Unix) or with 7-Zip (Windows) -* Visit your sites domain or IP address in your web browser. -* You will be presented with a form where you enter your MySQL login details and are asked to give your site a 'project -name' and the default login details. Follow the questions and select the *install* button at the bottom of the page. +* Make sure the webserver has MySQL and PHP support (check our [server requirements](../server_requirements)). +* Either [download the installer package](http://silverstripe.org/download), or [install through Composer](../composer). +* If using with the installer download, extract it into your webroot. +* Visit your domain or IP address in your web browser. +* You will be presented with an installation wizard asking for database and login credentials. * After a couple of minutes, your site will be set up. Visit your site and enjoy! ## Issues? diff --git a/docs/en/00_Getting_Started/02_Composer.md b/docs/en/00_Getting_Started/02_Composer.md index b254ca798..9caab927a 100644 --- a/docs/en/00_Getting_Started/02_Composer.md +++ b/docs/en/00_Getting_Started/02_Composer.md @@ -9,7 +9,9 @@ We also have separate instructions for [installing modules with Composer](/devel ## Installing composer -To install Composer, run the following commands from your command-line. +Before installing Composer you should ensure your system has the version control system, [Git installed](http://git-scm.com/book/en/v2/Getting-Started-Installing-Git). Composer uses Git to check out the code dependancies you need to run your SilverStripe CMS website from the code repositories maintained on GitHub. + +Next, to install Composer, run the following commands from your command-line. # Download composer.phar curl -s https://getcomposer.org/installer | php @@ -77,7 +79,7 @@ You can find other packages with the following command: composer search silverstripe -This will return a list of package names of the forum `vendor/package`. If you prefer, you can search for pacakges on [packagist.org](https://packagist.org/search/?q=silverstripe). +This will return a list of package names of the forum `vendor/package`. If you prefer, you can search for packages on [packagist.org](https://packagist.org/search/?q=silverstripe). The second part after the colon, `*`, is a version string. `*` is a good default: it will give you the latest version that works with the other modules you have installed. Alternatively, you can specificy a specific version, or a constraint such as `>=3.0`. For more information, read the [Composer documentation](http://getcomposer.org/doc/01-basic-usage.md#the-require-key). diff --git a/docs/en/00_Getting_Started/05_Coding_Conventions.md b/docs/en/00_Getting_Started/05_Coding_Conventions.md index 5f7da481f..7c62781ae 100644 --- a/docs/en/00_Getting_Started/05_Coding_Conventions.md +++ b/docs/en/00_Getting_Started/05_Coding_Conventions.md @@ -431,7 +431,7 @@ Put code into the classes in the following order (where applicable). ### SQL Format -If you have to use raw SQL, make sure your code works across databases make sure you escape your queries like below, +If you have to use raw SQL, make sure your code works across databases. Make sure you escape your queries like below, with the column or table name escaped with double quotes as below. :::php diff --git a/docs/en/00_Getting_Started/index.md b/docs/en/00_Getting_Started/index.md index e3937e382..bd891249d 100644 --- a/docs/en/00_Getting_Started/index.md +++ b/docs/en/00_Getting_Started/index.md @@ -37,8 +37,27 @@ For more flexibility, you can set up either of the following web servers, and us Mac OS X comes with a built-in webserver, but there are a number of other options: * [Install using MAMP](mac-osx) - * Install using the built-in webserver (no docs yet) - * Install using MacPorts (no docs yet) + * [Install using Homebrew](installation/other_installation_options/mac_osx_homebrew) + +### Virtual Machines through Vagrant + +[Vagrant](https://www.vagrantup.com/) creates portable development environments +which can be hosted on Linux, Windows and Mac OS X. The virtual machine +usually runs a flavour of Linux. As a self-contained pre-configured environment, +getting up an running with Vagrant tends to be easier than creating a complete +development environment from scratch on your own machine. + + * [silverstripe-australia/vagrant-environment](https://github.com/silverstripe-australia/vagrant-environment) + * [BetterBrief/vagrant-skeleton](https://github.com/BetterBrief/vagrant-skeleton) + +Note: These instructions are supported by the community. + +## Virtual Machines through Bitnami + +[Bitnami](https://bitnami.com) is an online service that makes it easy to get +apps running on cloud providers like Amazon Web Services as well as local +virtualised environments. Bitnami has a [SilverStripe Virtual Machine](https://bitnami.com/stack/silverstripe/virtual-machine) +ready for download or installation on a cloud platform. ## Troubleshooting diff --git a/docs/en/01_Tutorials/index.md b/docs/en/01_Tutorials/index.md index 845a93707..de5afce94 100644 --- a/docs/en/01_Tutorials/index.md +++ b/docs/en/01_Tutorials/index.md @@ -10,16 +10,16 @@ These tutorials are deprecated, and have been replaced by the new [Lessons](http These include video screencasts, written tutorials and code examples to get you started working with SilverStripe websites. * [How to set up a local development environment in SilverStripe](https://vimeo.com/108861537) -* [Lesson 1: Creating your first theme](http://www.silverstripe.org/learn/lessons/lesson-1-creating-your-first-theme/) -* [Lesson 2: Migrating static templates into your theme](http://www.silverstripe.org/learn/lessons/lesson-2-migrating-static-templates-into-your-theme/) -* [Lesson 3: Adding dynamic content](http://www.silverstripe.org/learn/lessons/lesson-3-adding-dynamic-content/) -* [Lesson 4: Working with multiple templates](http://www.silverstripe.org/learn/lessons/lesson-4-working-with-multiple-templates/) -* [Lesson 5: The holder/page pattern](http://www.silverstripe.org/learn/lessons/lesson-5-the-holderpage-pattern/) -* [Lesson 6: Adding Custom Fields to a Page](http://www.silverstripe.org/learn/lessons/lesson-6-adding-custom-fields-to-a-page/) -* [Lesson 7: Working with Files and Images](http://www.silverstripe.org/learn/lessons/lesson-7-working-with-files-and-images/) -* [Lesson 8: Introduction to the ORM](http://www.silverstripe.org/learn/lessons/lesson-8-introduction-to-the-orm) -* [Lesson 9: Data Relationships - $has_many](http://www.silverstripe.org/learn/lessons/lesson-9-working-with-data-relationships-has-many) -* [Lesson 10: Introduction to the ORM](http://www.silverstripe.org/learn/lessons/lesson-10-working-with-data-relationships-many-many) +* [Lesson 1: Creating your first theme](http://www.silverstripe.org/learn/lessons/creating-your-first-theme) +* [Lesson 2: Migrating static templates into your theme]http://www.silverstripe.org/learn/lessons/migrating-static-templates-into-your-theme) +* [Lesson 3: Adding dynamic content](http://www.silverstripe.org/learn/lessons/adding-dynamic-content) +* [Lesson 4: Working with multiple templates](http://www.silverstripe.org/learn/lessons/working-with-multiple-templates) +* [Lesson 5: The holder/page pattern](http://www.silverstripe.org/learn/lessons/the-holderpage-pattern) +* [Lesson 6: Adding Custom Fields to a Page](http://www.silverstripe.org/learn/lessons/adding-custom-fields-to-a-page) +* [Lesson 7: Working with Files and Images](http://www.silverstripe.org/learn/lessons/working-with-files-and-images) +* [Lesson 8: Introduction to the ORM](http://www.silverstripe.org/learn/lessons/introduction-to-the-orm) +* [Lesson 9: Data Relationships - $has_many](http://www.silverstripe.org/learn/lessons/working-with-data-relationships-has-many) +* [Lesson 10: Introduction to the ORM](http://www.silverstripe.org/learn/lessons/working-with-data-relationships-many-many) ## Help: If you get stuck diff --git a/docs/en/02_Developer_Guides/01_Templates/01_Syntax.md b/docs/en/02_Developer_Guides/01_Templates/01_Syntax.md index e94005dfa..2a1c54a22 100644 --- a/docs/en/02_Developer_Guides/01_Templates/01_Syntax.md +++ b/docs/en/02_Developer_Guides/01_Templates/01_Syntax.md @@ -70,7 +70,7 @@ These variables will call a method / field on the object and insert the returned * `$Foo.Bar` will call `$obj->Foo()->Bar()` If a variable returns a string, that string will be inserted into the template. If the variable returns an object, then -the system will attempt to render the object through its' `forTemplate()` method. If the `forTemplate()` method has not +the system will attempt to render the object through its `forTemplate()` method. If the `forTemplate()` method has not been defined, the system will return an error.
@@ -96,7 +96,7 @@ Variables can come from your database fields, or custom methods you define on yo Method names that begin with `get` will automatically be resolved when their prefix is excluded. For example, the above method call `$UsersIpAddress` would also invoke a method named `getUsersIpAddress()`.
-The variable's that can be used in a template vary based on the object currently in [scope](#scope). Scope defines what +The variables that can be used in a template vary based on the object currently in [scope](#scope). Scope defines what object the methods get called on. For the standard `Page.ss` template the scope is the current [api:Page_Controller] class. This object gives you access to all the database fields on [api:Page_Controller], its corresponding [api:Page] record and any subclasses of those two. @@ -243,7 +243,7 @@ object that is being looped over. `<% loop %>` statements iterate over a [api:DataList] instance. As the template has access to the list object, templates can call [api:DataList] methods. -Sort the list by a given field. +Sorting the list by a given field. :::ss
    @@ -270,7 +270,7 @@ Reversing the loop. <% end_loop %>
-Filtering the loop +Filtering the loop. :::ss
    @@ -279,7 +279,7 @@ Filtering the loop <% end_loop %>
-Methods can also be chained +Methods can also be chained. :::ss