Moved installer to open, the right copy this time!

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/phpinstaller/trunk@39713 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
aoneil 2007-08-07 22:19:05 +00:00
commit 62076389c3
11 changed files with 1339 additions and 0 deletions

17
COPYING Normal file
View File

@ -0,0 +1,17 @@
Copyright (c) 2007, SilverStripe Limited - www.silverstripe.com
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of SilverStripe nor the names of its contributors may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.

207
ChangeLog Normal file
View File

@ -0,0 +1,207 @@
SilverStripe ChangeLog
2.0.3
- Theme support
- Widget support
- TinyMCE has been updated to 2.1.1.1
- Improved spam detection
- More API documentation
- PHP notice fixes
- Added support for __ss_environment.php files
- Use normal authentification rather than basicauth for db/build
- Fix CSS of profiler pop-up
- Fix specific newsletter bug
- Added sorting, highlighting, formatting to TableListField
- Automatic filesystem backup of POST-data in Form
- Support for right-aligned titles in FormField
- Custom CSS-clases in FormFields by addExtraClass() and removeExtraClass()
- Validation in ComplexTableField_Popup
- Added BankAccountField
- Changed DropdownField.php $emptyString-syntax from '0' to ''
- Better validation in PhoneNumberField
- Validation and RequiredFields for TableField
- Fixed IE6 DOM-parsing bug caused by FormResponse::load_form()
- Triggering previewwrite for 'delete' and 'replace' SQL-actions
- Changed record-insertion in DataObject
- Added DataObjectSet->getRange()
- Added Date::past_date()
- Boolean.php accepts database-default
- Added Varchar->RTF()
- Added Convert::raw2htmlatt(), Convert::raw2mailto()
- Optionally hide backtrace-headers in Debug::message() and Debug::show() (applied in 'showqueries')
- Improved validation in Email::is_valid_address()
- MimeType-fallback for Email (from /etc/mime.types)
- Added Description-field to Group.php
- Added $strict-flag to Permission::check()
- Fixed Permission::get_members_by_permission()
- Implemented showIndicator() and hideIndicator(), Improved statusMessage() to clear manually instead of fixed interval, added hideStatusMessage()
- Added memory_limit to publishall()
- Styling changes in TreeDropdownField, TableListField
- Allow member cms fields to be added by DataObjectDecorators
- Fix many-many component set relation setting
- Added FiledSet::insertAfter()
- Allow classes other than typography to be set on HtmlEditorFields
- Added readonly transforamtion for ImageField
- The Link for a RedirectorPage points to its target
- Add SQL_ prefix in place it was missing in Email
- Added ContentController::project()
- layout.css, form.css and typography.css are automatically included
- Allow CMS users to limit view/edit access to a page.
- Added a check to make sure record exists before calling hasMethod on it in CheckboxSetField
- Don't show classes user doesn't have permissions to change to in class dropdown
- Fixed bug in DataObject::addStaticVars()
- Check for string 'true' as well as boolean in SiteTree::MetaTags()
- Fix AllNewsletters value not being passed to OptionSetField in SubscribeForm
- Fix reading of Live pages in CMSMain
- Fix double page reading after changing the class
- Fix insert flash
- Fix version regex for release candidates
- Fix delete in Files and Images section
- Fixed saving root folder causes error
- Fixed "non-numeric ID" error that occurs when visiting newsletter section for a newsletter that doesn't exist (caused by session sometimes)
- Added anchors to page comments, and made rss feed link to them
2.0.2
- BlackCandy is the new default theme
- Much more API Documentation
- Reduced warnings when E_NOTICE is enabled
- Modules must now have _config.php files in order to be loaded
- Forms in newsletter & security section were incorrectly submitting when enter was pressed
- Fixed validation of date fields in a user defined form
- Fixed search in MemberTableField
- Fixed multiple security groups being created when logging in with default admin
- Ensure that WYSIWYG context menu always appears on the screen
- Fixed permissions for administrating page comments
- Added pagination for page comments
- Fixed a bug where you couldn't always edit the bottom of an WYSIWYG editor field
- Fixed ContentController::PageComments() method to die if spammers are POSTing form data when comments are disabled
- Fixed permission checking on PHP 5.0.5
- Fixed 'cannot access protected property' error in Security section on PHP 5.0.5
- Fixed javascript validation of forms
- Don't show popup when validation fails in Security section
- Fixed error when asp_tags = On
- Fixed bug where you have a non-required field with numeric validation
- Added ContentNegotiator::set_encoding() to choose a character set other than utf-8
- Added a limit of 20 steps in Breadcrumbs generation
- Changed SiteTree.Title length from 100 to 255
- Fixed random password generator in Member::createNewPassword()
- Fixed bug where scrollbars aren't shown in the CMS
- Let CMSMain be used to manage objects without Sort
- Fixed BatchProcess to not display an error if no objects could be processed
- The help button now redirects to http://userhelp.silverstripe.com
- Fixed a bug where a user is redirected incorrectly after logging in
- Changed temp-folder selection to not leave temp files lying around, and put silverstripe temp files into a silverstripe-cache folder
- Removed duplicate XML class
- Made guid of PageComments in rss feed unique
- Performance improvements to client-side javascript
- Fixed bugs caused by missing html elements
- Optimised behaviour load times
- Sorted the output of profiler
- Performance enhancements to form and template code
- Added trace argument to Profiler::show
- Added profiling scaffolds
- Fixed code to remove need for short_open_tag
- Fixed FileSize generation for sizes of just over 1 meg
- only show $messageBlock in FormField::FieldHolder() if $Message is existing
- fixed rightTitle and id in FormField::FieldHolder()
- Added Email::send_all_emails_to to assist in testing
- Added Email::cc_all_emails_to() and Email::bcc_all_emails_to()
- Fixed ?isDev=1 mode
- Replaced sendLiveErrorsTo with send_errors_to, for more flexibility
- Set default of sendWarnings on Debug::send_errors_to
- Fixed formatting of error emails sent from ajax requests
- Removed debug plumbing from the results of Debug::backtrace()
- Added ?profile_trace=1 url variable tool to show a trace on the profiler
- Simplified return data of htmlEmail, an inconsequential internal optimisation
- Create assets folder if it doesn't exist when uploading a file
- Improvements to profiling information
- Fixed bug in SiteTree::NestedTitle()
- Updated CalendarDateField, adding a calendar icon to the right of it
- Updated date field in CMS-edited forms to use CalendarDateField
- Added Form::current_action() and Form::single_field_required() to aid in form optimisation
- Don't append /home to the home page URL
- Small fix for windows installations
- Fixed efficiency problems in Versioned::get_latest_version
- Fixed File::sync(), to let it recurse into new directories in a single execution
- Fixed bug with getting form action that was breaking form submission and complextablefield pop-up
- Prepared CheckboxSetField for use editing a many-many join in the CMS, popualted with a SQLMap object
- Added TreeDropdownField::setTreeBaseID, for showing a sub-tree in your field
- Fixed SQLMap iteration
- Added option to TableField, to aid putting TableFields inside the ComplexTableField? popup
- Simplified EmailField validation error message
- Fixed some bugs in the debug emailer
- Reduced amount of ajax-refetching that the TreeSelectorFields do
- Added 'open in new window' checkbox to link inserter
- Fix macron support in reports
- Improved debug message (remove big blocks of redundant data)
- Allow for the disabling of default buttons. Apply this to CMSMain and GenericDataAdmin in the administration, so that we don't default to clicking the *DELETE* button.
- Added default value to first arg of permissionFailure(); it's not actually used!
- Added PermissionProvider class and Permission::get_codes()
- Added ClassInfo::implementorsOf()
- Added providePermissions() for core items, and set up a dropdown interface for the security CMS admin
- Added DataObject::add_extension() for adding decorators in _config.php
- Added DataObjectDecorator::extraDBFields() for modifying the decorated data objects, adding extra database fields
- Improved handling of EditableFormFields on new UserDefinedForms
- Version displayed in CMS now works correctly
- Removed non-XHTML compliant border attributes from editor
- Updated GenericDataAdmin to use new permissions model
- Fixed CMS action button support when text size increases
- Added message when report is empty
- fixed (overrides) to CSS to avoid larger font-size due to em values
- Fixed tree scrolling and resizing issues
- Improved search results message shown on first load
- Added 2nd argument to LeftAndMain::setApplicationName so that the name in the top corner and the name shown elsewhere can be 2 different strings
- Added event.setStyle to prototype_improvements.js
- Fix weird bug in behaviour to do with class.applyToChildren
- Add class text field to image properties dialog in TinyMCE
- Added ?debug_behaviour=1 URL option for debugging behaviour calls with Firebug
- Made calendar control register a date change when the calendar is used
- Improved console.log alternative
- Fixed sizing issues with CMS right content area
- Installer changes
- Added option of installing either the default template, or the tutorial template
- mod_rewrite check now works with http authentification
- Workaround for 'URL file-access is disabled in the server configuration' using curl for mod_rewrite test
- Better error message if the installer can't detect the web server
- Added an alternative .htaccess configuration
2.0.1
- Text->FirstParagraph() now only shows the first paragraph
- Fixed HTMLText->Summary()
- Fixed layout issues on IE7 for TreeDropdownField
- Don't show Akismet errors to user
- Removed overloaded MemberTableField->sourceItems() that was causing problems
- Improved layout of UserDefinedForm submissions in CMS
- Fixed UserDefinedForm submission emails
- Fixed UserDefinedForm permissions
- If a file extension doesn't have a maximum upload size associated with it, then allow uploads of any size
- Fixed a bug with the TreeMultiselectField that prevented it from displaying the checkboxes
- Made Scheduled tasks concrete so they can be instantiated
- Fixed sizing of tabs in CMS
- Fixed popup for single asset in Files & Images section
- Mime types fallback for servers don't have /etc/mime.types
- Fixed link to CMS on default homepage
- TableField fixes
- mb_string module is now an optional dependency
- Fixed security vunerability in search
- Fixed permissions table in Security section
- GD::color_web2gd() was using incorrect substr
- Fixed last link css
- Fixed el no properties error in IE
- Fixed duplicate checkbox fields in UserDefinedForm
- Fixed css in UserDefinedForm
- Don't show name field on root folder in Assets section
- Pressing the flash button a second time now hides the dropdown
- Added strong_create method to Object, as useCustomClass was not working correctly
- Installer fixes
- Fixed MySQL version check
- Merge with existing .htaccess file
- Test that mod_rewrite is working
- Added option to delete installer files after successful install
- Fixed PHP4 parse error so installer loads and shows correct error message
- Apache test passes if apache is used but apache php functions are not available
- SilverStripe needs at least PHP version 5.0.4
2.0.0
- Initial release

22
INSTALL Normal file
View File

@ -0,0 +1,22 @@
Thanks for downloading SilverStripe CMS.
Simply extract the archive to a folder in a web-accessible location and visit the folder
in your web browser (which in turn runs index.php).
This will lead you through a web-based installation process.
Server Requirements
* PHP 5+
* MySQL 4.1+
* Apache or Lighttpd webserver (feel free to try with others)
* Details at http://doc.silverstripe.com/doku.php?id=server-requirements
General documentation, tutorials:
* Wiki: http://doc.silverstripe.com/
* Tutorials: http://doc.silverstripe.com/doku.php?id=silverstripe-tutorial
Forum
* http://www.silverstripe.com/silverstripe-forum/

6
UPGRADING Normal file
View File

@ -0,0 +1,6 @@
To upgrade your installation of SilverStripe, simply copy the
sapphire, cms & jsparty folders overtop of your existing installation.
Then flush the cache and rebuild the database (db/build?flush=1).
If there are any special notes on upgrading to a particular version,
these will be documented here.

22
check-php.php Normal file
View File

@ -0,0 +1,22 @@
<?php
if(ini_get("short_open_tag")) {
header("Location: install.php");
} else {
echo "Please set the PHP option short_open_tag to true, restart your webserver, and then refresh your browser to continue.";
}
?>
<!--<?php /*-->
<html>
<head>
<title>No PHP Support</title>
</head>
<body>
<h1>No PHP Support</h1>
<p>
<p>Before I can install SilverStripe 2, you must add PHP support to your webserver.</p>
<p><a href="check-php.php">Try again</a></p>
</body>
</html>
<!--*/?>-->

63
config-form.css Normal file
View File

@ -0,0 +1,63 @@
* {
font-family: Arial;
}
#All {
width: 50em;
margin: 2em auto;
border: 1px #CCC solid;
padding: 1em;
}
form {
margin: 0;
}
h1 {
margin-top: 0;
}
label span {
float: left;
width: 12em;
}
.good td {
color: green;
}
.warning td {
color: orange;
}
.testResults .error td {
background-color: #C00;
border: 1px #700 solid;
color: white;
}
p.error {
padding: 0.5em;
background-color: #C00;
border: 1px #700 solid;
color: white;
}
p.warning {
padding: 0.5em;
background-color: #E70;
border: 1px #A70 solid;
color: white;
}
p.good {
padding: 0.5em;
background-color: #0C0;
border: 1px #070 solid;
color: white;
}
.testResults {
border-collapse: collapse;
font-size: 80%;
}
.testResults td {
border: 1px #CCC solid;
width: 400px;
padding: 0.2em;
}

115
config-form.html Normal file
View File

@ -0,0 +1,115 @@
<html>
<head>
<title>SilverStripe CMS Installation</title>
<script>
function show(id) {
document.getElementById(id).style.display = '';
}
function hide(id) {
document.getElementById(id).style.display = 'none';
}
</script>
<link rel="stylesheet" type="text/css" href="config-form.css" />
</head>
<body>
<div id="All">
<p style="float: right"><b>Version <?= $silverstripe_version ?></b></p>
<h1>SilverStripe CMS Installation</h1>
<p>Thanks for choosing to use SilverStripe! Please follow the instructions below to get SilverStripe
installed.</p>
<form action="install.php" method="post">
<?php if(isset($hasErrorOtherThanDatabase)) { ?>
<p class="error">You aren't currently able to install the software. Please <a style="color: #CCF" href="#requirements">see below</a> for details.</p>
<?php } else { ?>
<?php if($req->hasWarnings()) { ?>
<p class="warning">There are some issues that we recommend you look at before installing, however, you are still able to install the software. Please see below for details.</p>
<?php } else if(!$dbReq->hasErrors()) { ?>
<p class="good">You're ready to install! &nbsp;&nbsp;
</p>
<p><b>Template to install:</b></p>
<input type="radio" name="template" value="default" checked="checked">Default template</input><br />
<input type="radio" name="template" value="tutorial">Tutorial template</input><br />
<?php } ?>
<?php if($alreadyInstalled) { ?>
<p><b>Note:</b> It seems as though SilverStripe is already installed here. If you ask me to install, I will overwrite
the <b>.htaccess</b> and <b>mysite/_config.php</b> files. <br /> <br />
<label style="cursor: pointer">
<input type="checkbox" name="force_reinstall" onclick="document.getElementById('install_button').disabled = !this.checked" /> That's okay, please re-install SilverStripe and overwrite these files.
</label>
</p>
<? } ?>
<p>
<?php if($alreadyInstalled) { ?>
<input id="install_button" type="submit" disabled="disabled" name="go" value="Install SilverStripe" onclick="document.getElementById('saving_top').style.display = ''; this.value = 'Installing SilverStripe...'" />
<?php } else { ?>
<input id="install_button" type="submit" name="go" value="Install SilverStripe" onclick="document.getElementById('saving_top').style.display = ''; this.value = 'Installing SilverStripe...'" />
<? } ?>
<span id="saving_top" style="display: none">
&nbsp;
<img src="cms/images/network-save.gif" />
(this will take a minute or so)
</span>
</p>
<?php } ?>
<input type="hidden" name="database" value="MySQLDatabase" />
<h2>MySQL Database</h2>
<p>
SilverStripe stores its content in a MySQL database. Please provide the username
and password to connect to the server here. If this account has permission to create databases, then we will
create the database for you; otherwise, you must give the name of a database that already exists.
</p>
<?php if($dbReq->hasErrors()) { ?>
<p class="error">These database details don't appear to be correct. Please enter the correct details before installing.</p>
<?php } else { ?>
<p class="good">These database details look all good!</p>
<?php } ?>
<p style="margin-left: 2em" id="mysql_credentials" > <!--style="display: none"-->
<label for="mysql_server"> <span>MySQL server:</span> <input id="mysql_server" type="text" name="mysql[server]" value="<?= $databaseConfig['server'] ?>" /></label> <br />
<label for="mysql_username"> <span>MySQL username:</span> <input id="mysql_username" type="text" name="mysql[username]" value="<?= $databaseConfig['username'] ?>" /></label> <br />
<label for="mysql_password"> <span>MySQL password:</span> <input id="mysql_password" type="text" name="mysql[password]" value="<?= $databaseConfig['password'] ?>" /></label> <br />
<label for="mysql_database"><span>MySQL database:</span> <input id="mysql_database" type="text" name="mysql[database]" value="<?= $databaseConfig['database'] ?>" onchange="this.value = this.value.replace(/[^A-Za-z0-9_]+/g,'');" /></label> <br />
</p>
<p style="margin-left: 2em"><input type="submit" value="Re-check requirements" /></p>
<h4>Details</h4>
<?php $dbReq->showTable("MySQL Configuration"); ?>
<br /><hr />
<h2>SilverStripe Administration Account</h2>
<p>
We will set up 1 administrator account for you automatically. Enter the email address and password. If you'd
rather log-in with a username instead of an email address, enter that instead.
</p>
<p style="margin-left: 2em">
<label for="username"> <span>Administrator email:</span> <input type="text" name="username" id="username" value="admin" /></label> <br />
<label for="password"> <span>Administrator password:</span> <input type="text" name="password" id="password" value="password" /></label> <br />
</p>
<br /><hr />
<h2 id="requirements">Requirements</h2>
<?php
$req->showTable();
?>
</form>
</div>
</body>
</html>

17
index.html Normal file
View File

@ -0,0 +1,17 @@
<html>
<!--
This simple page will redirect to check-php.php
check-php.php will either redirect to install.php or no-php.html, depending on whether PHP support
is installed
-->
<head>
</head>
<body>
<script>
window.location = 'check-php.php';
</script>
<noscript>
<a href="install.php">Click here to install</a>
</noscript>
</body>
</html>

3
index.php Normal file
View File

@ -0,0 +1,3 @@
<?php
header("Location: check-php.php");
?>

792
install.php Normal file
View File

@ -0,0 +1,792 @@
<?php
/**
* SilverStripe CMS Installer
* This installer doesn't use any of the fancy Sapphire stuff in case it's unsupported.
*/
ini_set('max_execution_time', 300);
// Load database config
if(isset($_REQUEST['mysql'])) {
$databaseConfig = $_REQUEST['mysql'];
} else {
$databaseConfig = array(
"server" => "localhost",
"username" => "root",
"password" => "",
"database" => "SS_mysite",
);
}
$alreadyInstalled = (file_exists('assets') || file_exists('mysite/_config.php'));
if(file_exists('sapphire/silverstripe_version')) {
$sapphireVersionFile = file_get_contents('sapphire/silverstripe_version');
if(strstr($sapphireVersionFile, "/sapphire/trunk")) {
$silverstripe_version = "trunk";
} else {
preg_match("/sapphire\/(?:(?:branches)|(?:tags))(?:\/rc)?\/([A-Za-z0-9._-]+)\/silverstripe_version/", $sapphireVersionFile, $matches);
$silverstripe_version = $matches[1];
}
} else {
$silverstripe_version = "unknown";
}
// Check requirements
$req = new InstallRequirements();
$req->check();
if($req->hasErrors()) $hasErrorOtherThanDatabase = true;
if($databaseConfig) {
$dbReq = new InstallRequirements();
$dbReq->checkdatabase($databaseConfig);
}
// Actual processor
if(isset($_REQUEST['go']) && !$req->hasErrors() && !$dbReq->hasErrors()) {
// Confirm before reinstalling
if(!isset($_REQUEST['force_reinstall']) && $alreadyInstalled) {
include('config-form.html');
} else {
$inst = new Installer();
$inst->install($_REQUEST);
}
// Show the config form
} else {
include('config-form.html');
}
/**
* This class checks requirements
* Each of the requireXXX functions takes an argument which gives a user description of the test. It's an array
* of 3 parts:
* $description[0] - The test catetgory
* $description[1] - The test title
* $description[2] - The test error to show, if it goes wrong
*/
class InstallRequirements {
var $errors, $warnings, $tests;
/**
* Just check that the database configuration is okay
*/
function checkdatabase($databaseConfig) {
if($this->requireFunction('mysql_connect', array("PHP Configuration", "MySQL support", "MySQL support not included in PHP."))) {
$this->requireMySQLServer($databaseConfig['server'], array("MySQL Configuration", "Does the server exist",
"Can't find the a MySQL server on '$databaseConfig[server]'", $databaseConfig['server']));
if($this->requireMysqlConnection($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password'],
array("MySQL Configuration", "Are the access credentials correct", "That username/password doesn't work"))) {
@$this->requireMySQLVersion("4.1", array("MySQL Configuration", "MySQL version at least 4.1", "MySQL version 4.1 is required, you only have ", "MySQL " . mysql_get_server_info()));
}
$this->requireDatabaseOrCreatePermissions($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password'], $databaseConfig['database'],
array("MySQL Configuration", "Can I access/create the database", "I can't create new databases and the database '$databaseConfig[database]' doesn't exist"));
}
}
/**
* Check everything except the database
*/
function check() {
$this->errors = null;
$this->requirePHPVersion('5.0.4', array("PHP Configuration", "PHP5 installed", null, "PHP version " . phpversion()));
// Check that we can identify the root folder successfully
$this->requireFile('config-form.html', array("File permissions",
"Does the webserver know where files are stored?",
"The webserver isn't letting me identify where files are stored.",
$this->getBaseDir()
));
$this->requireFile('mysite', array("File permissions", "mysite/ folder exists", "There's no mysite folder."));
$this->requireFile('sapphire', array("File permissions", "sapphire/ folder exists", "There's no sapphire folder."));
$this->requireFile('cms', array("File permissions", "cms/ folder exists", "There's no cms folder."));
$this->requireFile('jsparty', array("File permissions", "jsparty/ folder exists", "There's no jsparty folder."));
$this->requireWriteable('.', array("File permissions", "Is the base folder writeable?", null));
$this->requireWriteable('mysite', array("File permissions", "Is the mysite /folder writeable?", null));
if(!is_writeable(dirname(tempnam('adfadsfdas','')))) {
$this->error(array("File permissions", "Is the temporary folder writeable?", "The temporary folder isn't writeable!"));
}
// Check that there's no stray files to get in the way
//$this->moveFileOutOfTheWay('.htaccess', "Please remove the current .htaccess file.");
//$this->moveFileOutOfTheWay('mysite/_config.php', "Please remove the current mysite/_config.php file.");
// Check for rewriting
$webserver = strip_tags(trim($_SERVER['SERVER_SIGNATURE']));
if($webserver == '') {
$webserver = "I can't tell what webserver you are running";
}
$this->isRunningApache(array("Webserver Configuration", "Server software", "$webserver. Without Apache I can't tell if mod_rewrite is enabled.", $webserver));
if(function_exists('apache_get_modules')) {
$this->requireApacheModule('mod_rewrite', array("Webserver Configuration", "mod_rewrite enabled", "You need mod_rewrite to run SilverStripe CMS, but it is not enabled."));
} else {
$this->warning(array("Webserver Configuration", "mod_rewrite enabled", "I can't tell whether mod_rewrite is running. You may need to configure a rewriting rule yourself."));
}
// Check for $_SERVER configuration
$this->requireServerVariables(array('SCRIPT_NAME','HTTP_HOST','SCRIPT_FILENAME'), array("Webserver config", "Recognised webserver", "You seem to be using an unsupported webserver. The server variables SCRIPT_NAME, HTTP_HOST, SCRIPT_FILENAME need to be set."));
// Check for GD support
if(!$this->requireFunction("imagecreatetruecolor", array("PHP Configuration", "GD2 support", "PHP must have GD version 2."))) {
$this->requireFunction("imagecreate", array("PHP Configuration", "GD2 support", "GD2 support", "GD support for PHP not included."));
}
// Check for XML support
$this->requireFunction('xml_set_object', array("PHP Configuration", "XML support", "XML support not included in PHP."));
// Check for MySQL support
$this->requireFunction('mysql_connect', array("PHP Configuration", "MySQL support", "MySQL support not included in PHP."));
// Check memory allocation
$this->requireMemory(20*1024*1024, 32*1024*1024, array("PHP Configuration", "Memory allocated (PHP config option 'memory_limit')", "SilverStripe needs a minimum of 20M allocated to PHP, but recommends 32M.", ini_get("memory_limit")));
// Check allow_call_time_pass_reference
$this->suggestPHPSetting('allow_call_time_pass_reference', array(1,'1','on','On'), array("PHP Configuration", "Check that the php.ini setting allow_call_time_pass_reference is on",
"You can install with allow_call_time_pass_reference not set, but some warnings may get displayed. For best results, turn it on."));
return $this->errors;
}
function suggestPHPSetting($settingName, $settingValues, $testDetails) {
$this->testing($testDetails);
$val = ini_get($settingName);
if(!in_array($val, $settingValues) && $val != $settingValues) {
$testDetails[2] = "$settingName is set to '$val' in php.ini. $testDetails[2]";
$this->warning($testDetails);
}
}
function requireMemory($min, $recommended, $testDetails) {
$this->testing($testDetails);
$mem = $this->getPHPMemory();
if($mem < $min && $mem > 0) {
$testDetails[2] .= " You only have " . ini_get("memory_limit") . " allocated";
$this->error($testDetails);
} else if($mem < $recommended && $mem > 0) {
$testDetails[2] .= " You only have " . ini_get("memory_limit") . " allocated";
$this->warning($testDetails);
} elseif($mem == 0) {
$testDetails[2] .= " We can't determine how much memory you have allocated. Install only if you're sure you've allocated at least 20 MB.";
$this->warning($testDetails);
}
}
function getPHPMemory() {
$memString = ini_get("memory_limit");
switch(strtolower(substr($memString,-1))) {
case "k":
return round(substr($memString,0,-1)*1024);
case "m":
return round(substr($memString,0,-1)*1024*1024);
case "g":
return round(substr($memString,0,-1)*1024*1024*1024);
default:
return round($memString);
}
}
function listErrors() {
if($this->errors) {
echo "<p>The following problems are preventing me from installing SilverStripe CMS:</p>";
foreach($this->errors as $error) {
echo "<li>" . htmlentities($error) . "</li>";
}
}
}
function showTable($section = null) {
if($section) {
$tests = $this->tests[$section];
echo "<table class=\"testResults\" width=\"100%\">";
foreach($tests as $test => $result) {
echo "<tr class=\"$result[0]\"><td>$test</td><td>" . nl2br(htmlentities($result[1])) . "</td></tr>";
}
echo "</table>";
} else {
foreach($this->tests as $section => $tests) {
echo "<h3>$section</h3>";
echo "<table class=\"testResults\" width=\"100%\">";
foreach($tests as $test => $result) {
echo "<tr class=\"$result[0]\"><td>$test</td><td>" . nl2br(htmlentities($result[1])) . "</td></tr>";
}
echo "</table>";
}
}
}
function showInstallStatus() {
if($this->warnings) {
echo "I have installed SilverStripe CMS, however, you should note the following:";
foreach($this->warnings as $warning) {
echo "<li>" . htmlentities($warning) . "</li>";
}
} else {
?>
<p>I have installed SilverStripe CMS successfully!</p>
<p><a href="./admin/" target="_blank">Open the CMS tool</a><br />
<a href="./" target="_blank">Open the site</a></p>
<?
}
}
function requireFunction($funcName, $testDetails) {
$this->testing($testDetails);
if(!function_exists($funcName)) $this->error($testDetails);
else return true;
}
function requirePHPVersion($version, $testDetails) {
$this->testing($testDetails);
list($reqA, $reqB, $reqC) = explode('.', $version);
list($a, $b, $c) = explode('.', phpversion());
$c = ereg_replace('-.*$','',$c);
if($a > $reqA) return true;
if($a == $reqA && $b > $reqB) return true;
if($a == $reqA && $b == $reqB && $c >= $reqC) return true;
if(!$testDetails[2]) {
if($a < $reqA) {
$testDetails[2] = "You need PHP version $version or later, only $a.$b.$c is installed. Unfortunately PHP$a and PHP$reqA have some incompatabilities, so if you are on a your web-host may need to move you to a different server. Some software doesn't work with PHP5 and so upgrading a shared server could be problematic.";
} else {
$testDetails[2] = "You need PHP version $version or later, only $a.$b.$c is installed. Please upgrade your server, or ask your web-host to do so.";
}
}
$this->error($testDetails);
}
function requireFile($filename, $testDetails) {
$this->testing($testDetails);
$filename = $this->getBaseDir() . $filename;
if(!file_exists($filename)) {
$testDetails[2] .= " (file '$filename' not found)";
$this->error($testDetails);
}
}
function requireNoFile($filename, $testDetails) {
$this->testing($testDetails);
$filename = $this->getBaseDir() . $filename;
if(file_exists($filename)) {
$testDetails[2] .= " (file '$filename' found)";
$this->error($testDetails);
}
}
function moveFileOutOfTheWay($filename, $testDetails) {
$this->testing($testDetails);
$filename = $this->getBaseDir() . $filename;
if(file_exists($filename)) {
if(file_exists("$filename.bak")) rm("$filename.bak");
rename($filename, "$filename.bak");
}
}
function requireWriteable($filename, $testDetails) {
$this->testing($testDetails);
$filename = $this->getBaseDir() . $filename;
if(!is_writeable($filename)) {
$user = posix_getpwuid(posix_geteuid());
$groups = posix_getgroups();
foreach($groups as $group) {
$groupInfo = posix_getgrgid($group);
$groupList[] = $groupInfo['name'];
}
$groupList = "'" . implode("', '", $groupList) . "'";
$testDetails[2] .= "User '$user[name]' needs to write be able to write to this file:\n$filename";
$this->error($testDetails);
}
}
function requireApacheModule($moduleName, $testDetails) {
$this->testing($testDetails);
if(!in_array($moduleName, apache_get_modules())) $this->error($testDetails);
}
function requireMysqlConnection($server, $username, $password, $testDetails) {
$this->testing($testDetails);
$conn = @mysql_connect($server, $username, $password);
if($conn) {
return true;
/*
if(mysql_query("CREATE DATABASE testing123")) {
mysql_query("DROP DATABASE testing123");
return true;
} else {
$testDetails[2] .= " (user '$username' doesn't have CREATE DATABASE permissions.)";
$this->error($testDetails);
}
*/
} else {
$testDetails[2] .= ": " . mysql_error();
$this->error($testDetails);
}
}
function requireMySQLServer($server, $testDetails) {
$this->testing($testDetails);
$conn = @mysql_connect($server, null, null);
if($conn || mysql_errno() < 2000) {
return true;
} else {
$testDetails[2] .= ": " . mysql_error();
$this->error($testDetails);
}
}
function requireMySQLVersion($version, $testDetails) {
$this->testing($testDetails);
if(!mysql_get_server_info()) {
$testDetails[2] = 'Cannot determine the version of MySQL installed. Please ensure at least version 4.1 is installed.';
$this->warning($testDetails);
} else {
list($majorRequested, $minorRequested) = explode('.', $version);
list($majorHas, $minorHas) = explode('.', mysql_get_server_info());
if(($majorHas > $majorRequested) || ($majorHas == $majorRequested && $minorHas >= $minorRequested)) {
return true;
} else {
$testDetails[2] .= "{$majorHas}.{$minorHas}.";
$this->error($testDetails);
}
}
}
function requireDatabaseOrCreatePermissions($server, $username, $password, $database, $testDetails) {
$this->testing($testDetails);
$conn = @mysql_connect($server, $username, $password);
if(@mysql_select_db($database)) {
$okay = "Database '$database' exists";
} else {
if(@mysql_query("CREATE DATABASE testing123")) {
mysql_query("DROP DATABASE testing123");
$okay = "Able to create a new database";
} else {
$testDetails[2] .= " (user '$username' doesn't have CREATE DATABASE permissions.)";
$this->error($testDetails);
return;
}
}
if($okay) {
$testDetails[3] = $okay;
$this->testing($testDetails);
}
}
function requireServerVariables($varNames, $errorMessage) {
//$this->testing($testDetails);
foreach($varNames as $varName) {
if(!$_SERVER[$varName]) $missing[] = '$_SERVER[' . $varName . ']';
}
if(!isset($missing)) {
return true;
} else {
$testDetails[2] .= " (the following PHP variables are missing: " . implode(", ", $missing) . ")";
$this->error($testDetails);
}
}
function isRunningApache($testDetails) {
$this->testing($testDetails);
if(function_exists('apache_get_modules') || stristr($_SERVER['SERVER_SIGNATURE'], 'Apache'))
return true;
$this->warning($testDetails);
return false;
}
function getBaseDir() {
return dirname($_SERVER['SCRIPT_FILENAME']) . '/';
}
function testing($testDetails) {
if(!$testDetails) return;
$section = $testDetails[0];
$test = $testDetails[1];
$message = "OK";
if(isset($testDetails[3])) $message .= " ($testDetails[3])";
$this->tests[$section][$test] = array("good", $message);
}
function error($testDetails) {
$section = $testDetails[0];
$test = $testDetails[1];
$this->tests[$section][$test] = array("error", $testDetails[2]);
$this->errors[] = $testDetails;
}
function warning($testDetails) {
$section = $testDetails[0];
$test = $testDetails[1];
$this->tests[$section][$test] = array("warning", $testDetails[2]);
$this->warnings[] = $testDetails;
}
function hasErrors() {
return sizeof($this->errors);
}
function hasWarnings() {
return sizeof($this->warnings);
}
}
class Installer extends InstallRequirements {
function install($config) {
session_start();
?>
<h1>Installing SilverStripe...</h1>
<p>I am now running through the installation steps (this should take about 30 seconds)</p>
<p>If you receive a fatal error, refresh this page to continue the installation
<?
flush();
echo "<li>Creating 'assets' folder...</li>";
flush();
$this->makeFolder('assets');
// Write the config file
$template = $_POST['template'] == 'tutorial' ? 'tutorial' : 'mysite';
echo "<li>Creating '$template/_config.php'...</li>";
flush();
$this->createFile("$template/_config.php", <<<PHP
<?
global \$project;
\$project = '$template';
global \$databaseConfig;
\$databaseConfig = array(
"type" => "$config[database]",
"server" => "{$config['mysql']['server']}",
"username" => "{$config['mysql']['username']}",
"password" => "{$config['mysql']['password']}",
"database" => "{$config['mysql']['database']}",
);
// If we're running on local host, or a server with 'dev.' in its
// name, set the site to dev mode. You should add test for your
// development servers here also.
if(strpos(Director::baseURL(), "localhost") !== false ||
strpos(Director::baseURL(), "127.0.0.1") !== false ||
strpos(Director::baseURL(), "dev.")) {
Director::set_environment_type("dev");
}
?>
PHP
);
echo "<li>Creating '.htaccess' file...</li>";
flush();
$this->createHtaccess();
// Load the sapphire runtime
$_SERVER['SCRIPT_FILENAME'] = dirname($_SERVER['SCRIPT_FILENAME']) . '/sapphire/main.php';
chdir('sapphire');
require_once("core/Core.php");
require_once("core/ManifestBuilder.php");
require_once("core/ClassInfo.php");
require_once('core/Object.php');
require_once('core/control/Director.php');
require_once('filesystem/Filesystem.php');
echo "<li>Building database schema...</li>";
flush();
// Build database
ManifestBuilder::compileManifest();
$dbAdmin = new DatabaseAdmin();
$dbAdmin->init();
$dbAdmin->doBuild(true);
echo "<li>Checking mod_rewrite works</li>";
$_SESSION['username'] = $_REQUEST['username'];
$_SESSION['password'] = $_REQUEST['password'];
if($this->checkModRewrite()) {
if($this->errors) {
} else {
echo "<p>Installed SilverStripe successfully. I will now try and direct you to
<a href=\"home/successfullyinstalled\">home/successfullyinstalled</a> to confirm that the installation was successful.</p>
<script>setTimeout(function() { window.location.href = 'home/successfullyinstalled'; }, 1000);</script>
";
}
}
return $this->errors;
}
function makeFolder($folder) {
$base = $this->getBaseDir();
if(!file_exists($base . $folder)) {
if(!mkdir($base . $folder, 02775)) {
$this->error("Couldn't create a folder called $base$folder");
} else {
chmod($base . $folder, 02775);
}
}
}
function renameFolder($oldName, $newName) {
if($oldName == $newName) return true;
$base = $this->getBaseDir();
if(!rename($base . $oldName, $base . $newName)) {
$this->error("Couldn't rename $base$oldName to $base$newName");
return false;
} else {
return true;
}
}
function copyFolder($oldName, $newName) {
if($oldName == $newName) return true;
$base = $this->getBaseDir();
if(!copyr($base . $oldName, $base . $newName)) {
$this->error("Couldn't rename $base$oldName to $base$newName");
return false;
} else {
return true;
}
}
function createFile($filename, $content) {
$base = $this->getBaseDir();
if(($fh = fopen($base . $filename, 'w')) && fwrite($fh, $content) && fclose($fh)) {
return true;
} else {
$this->error("Couldn't write to file $base$filename");
}
}
function createHtaccess() {
$start = "### SILVERSTRIPE START ###\n";
$end= "\n### SILVERSTRIPE END ###";
$rewrite = <<<TEXT
RewriteEngine On
RewriteRule \.js$ - [L]
RewriteRule \.css$ - [L]
RewriteRule \.png$ - [L]
RewriteRule \.jpg$ - [L]
RewriteRule \.gif$ - [L]
RewriteRule \.php$ - [L]
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
TEXT
;
$rewriteAlternative = $rewrite;
str_replace("sapphire", $_SERVER['DOCUMENT_ROOT'] . '/sapphire', $rewriteAlternative);
$baseURL = dirname($_SERVER['SCRIPT_NAME']);
if($baseURL == "/") {
$baseURL = "";
}
if(file_exists('.htaccess')) {
$htaccess = file_get_contents('.htaccess');
copy('.htaccess', '.htaccess_orig');
if(strpos($htaccess, '### SILVERSTRIPE START ###') !== false && strpos($htaccess, '### SILVERSTRIPE END ###') !== false) {
echo "<li>Existing .htaccess found, merging in SilverStripe rewrite rules</li>";
$start = substr($htaccess, 0, strpos($htaccess, '### SILVERSTRIPE START ###')) . "### SILVERSTRIPE START ###\n";
$end = "\n" . substr($htaccess, strpos($htaccess, '### SILVERSTRIPE END ###'));
}
}
$this->createFile('.htaccess_rewrite', $start . $rewrite . $end);
$this->createFile('.htaccess_alternative', $start . $rewriteAlternative . $end);
}
function checkModRewrite() {
copy('../.htaccess_rewrite', '../.htaccess');
if($this->performModRewriteTest() == true) {
return true;
}
copy('../.htaccess_alternative', '../.htaccess');
if($this->performModRewriteTest() == false) {
echo "<li>ERROR: mod_rewrite not working, redirecting to mod_rewrite test page</li>";
if(file_exists('../.htaccess_orig')) {
copy('../.htaccess_orig', '../.htaccess');
} else {
unlink('../.htaccess');
}
echo "I will now try and direct you to <a href=\"rewritetest.php\">rewritetest</a> to troubleshoot mod_rewrite</p>
<script>setTimeout(function() { window.location.href = 'rewritetest.php'; }, 1000);</script>
";
return false;
}
return true;
}
function performModRewriteTest() {
$baseURL = dirname($_SERVER['SCRIPT_NAME']);
if($baseURL == "/") {
$baseURL = "";
}
// Check if mod_rewrite works properly
$location = 'http://' . (isset($_SERVER['PHP_AUTH_USER']) ? "$_SERVER[PHP_AUTH_USER]:$_SERVER[PHP_AUTH_PW]@" : '') . $_SERVER['HTTP_HOST'] . $baseURL . '/InstallerTest/testRewrite';
@$testrewriting = file_get_contents($location);
if($testrewriting == 'OK') {
return true;
}
// Workaround for 'URL file-access is disabled in the server configuration' using curl
if(function_exists('curl_init')) {
$ch = curl_init($location);
$fp = @fopen("temp", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
$testrewriting = file_get_contents('temp');
unlink('temp');
if($testrewriting == 'OK') {
return true;
}
}
return false;
}
}
/**
* Copy a file, or recursively copy a folder and its contents
*
* @author Aidan Lister <aidan@php.net>
* @version 1.0.1
* @link http://aidanlister.com/repos/v/function.copyr.php
* @param string $source Source path
* @param string $dest Destination path
* @return bool Returns TRUE on success, FALSE on failure
*/
function copyr($source, $dest)
{
// Simple copy for a file
if (is_file($source)) {
return copy($source, $dest);
}
// Make destination directory
if (!is_dir($dest)) {
mkdir($dest);
}
// Loop through the folder
$dir = dir($source);
while (false !== $entry = $dir->read()) {
// Skip pointers
if ($entry == '.' || $entry == '..') {
continue;
}
// Deep copy directories
if ($dest !== "$source/$entry") {
copyr("$source/$entry", "$dest/$entry");
}
}
// Clean up
$dir->close();
return true;
}
function rm($fileglob)
{
if (is_string($fileglob)) {
if (is_file($fileglob)) {
return unlink($fileglob);
} else if (is_dir($fileglob)) {
$ok = rm("$fileglob/*");
if (! $ok) {
return false;
}
return rmdir($fileglob);
} else {
$matching = glob($fileglob);
if ($matching === false) {
trigger_error(sprintf('No files match supplied glob %s', $fileglob), E_USER_WARNING);
return false;
}
$rcs = array_map('rm', $matching);
if (in_array(false, $rcs)) {
return false;
}
}
} else if (is_array($fileglob)) {
$rcs = array_map('rm', $fileglob);
if (in_array(false, $rcs)) {
return false;
}
} else {
trigger_error('Param #1 must be filename or glob pattern, or array of filenames or glob patterns', E_USER_ERROR);
return false;
}
return true;
}
?>

75
rewritetest.php Normal file
View File

@ -0,0 +1,75 @@
<?php
if(file_exists('.htaccess_rewrite')) {
copy(".htaccess_rewrite", ".htaccess");
}
$baseURL = dirname($_SERVER['SCRIPT_NAME']);
if($baseURL == "/") {
$baseURL = "";
}
if(isset($_REQUEST['force'])) {
echo "Forced continue, attempting to redirect to <a href=\"home/successfullyinstalled\">home/successfullyinstalled</a>.
<script>setTimeout(function() { window.location.href = 'home/successfullyinstalled'; }, 1000);</script>";
} else {
$modRewriteWorking = performModRewriteTest();
if(!$modRewriteWorking) {
copy(".htaccess_alternative", ".htaccess");
$modRewriteWorking = performModRewriteTest();
}
if($modRewriteWorking) {
echo "mod_rewrite is working! I will now try and direct you to
<a href=\"home/successfullyinstalled\">home/successfullyinstalled</a> to confirm that the installation was successful.
<script>setTimeout(function() { window.location.href = 'home/successfullyinstalled'; }, 1000);</script>
";
} else {
unlink('.htaccess');
if(file_exists('.htaccess_orig')) {
copy('.htaccess_orig', '.htaccess');
}
echo "mod_rewrite doesn't appear to be working. Make sure:" .
"<ul>" .
"<li>mod_rewrite is enabled in your httpd.conf</li>" .
"<li>AllowOverride is enabled for the current path.</li>" .
"</ul>" .
"Please check these options, then refresh this page." .
"If you believe that your configuration is correct, <a href=\"rewritetest.php?force=1\">click here to proceed anyway.</a>";
}
}
function performModRewriteTest() {
$baseURL = dirname($_SERVER['SCRIPT_NAME']);
if($baseURL == "/") {
$baseURL = "";
}
// Check if mod_rewrite works properly
$location = 'http://' . (isset($_SERVER['PHP_AUTH_USER']) ? "$_SERVER[PHP_AUTH_USER]:$_SERVER[PHP_AUTH_PW]@" : '') . $_SERVER['HTTP_HOST'] . $baseURL . '/InstallerTest/testRewrite';
@$testrewriting = file_get_contents($location);
if($testrewriting == 'OK') {
return true;
}
// Workaround for 'URL file-access is disabled in the server configuration' using curl
if(function_exists('curl_init')) {
$ch = curl_init($location);
$fp = @fopen("temp", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
$testrewriting = file_get_contents('temp');
unlink('temp');
if($testrewriting == 'OK') {
return true;
}
}
return false;
}
?>