BUGFIX: Friendlier error when you have a site running on a PHP4 server, or a server without PHP.

API CHANGE: Move some of the installer into the sapphire directory.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@66894 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-11-28 01:55:28 +00:00
parent 025d2b2498
commit 8671b022e4
4 changed files with 347 additions and 0 deletions

View File

@ -0,0 +1,173 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>SilverStripe CMS Installation</title>
<script type="text/js">
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="themes/blackcandy/css/layout.css" />
<link rel="stylesheet" type="text/css" href="themes/blackcandy/css/typography.css" />
<link rel="stylesheet" type="text/css" href="themes/blackcandy/css/form.css" />
<link rel="stylesheet" type="text/css" href="sapphire/dev/install/install.css" />
<link rel="shortcut icon" href="favicon.ico" />
</head>
<body>
<div id="BgContainer">
<div id="Container">
<div id="Header">
<h1>SilverStripe CMS Installation</h1>
<p>Version <?php echo $silverstripe_version; ?></p>
</div>
<div id="Navigation">&nbsp;</div>
<div class="clear"><!-- --></div>
<div id="Layout">
<div class="typography">
<h1>Welcome to SilverStripe</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 href="#requirements">see below</a> for details.<br />
If you are having problems meeting the requirements, see the <a href="http://doc.silverstripe.com/doku.php?id=server-requirements">server requirements wiki page</a>.
</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.<br />
If you are having problems meeting the requirements, see the <a href="http://doc.silverstripe.com/doku.php?id=server-requirements">server requirements wiki page</a>.
</p>
<?php } else if(!$dbReq->hasErrors()) { ?>
<p class="good">
You're ready to install! &nbsp;&nbsp;
</p>
<?php } ?>
<p>
<b>Template to install:</b>
</p>
<ul id="Themes">
<li><input type="radio" name="template" value="blackcandy" id="BlackCandy" checked="checked" /><label for="BlackCandy">BlackCandy, default template ready to use.</label></li>
<li><input type="radio" name="template" value="tutorial" id="EmptyTemplate" /><label for="EmptyTemplate">Empty template, ready to begin the tutorial.</label></li>
</ul>
<p>You can change the template or download another from the SilverStripe website after installation.</p>
<input type="checkbox" id="stats" name="stats" checked="checked"><label for="stats">Send information on my webserver to SilverStripe (this is only version information, used for statistical purposes)</label><br />
<?php if($alreadyInstalled) { ?>
<p class="warning">
<strong>Note:</strong> It seems as though SilverStripe is already installed here. If you ask me to install, I will overwrite
the <strong>.htaccess</strong> and <strong>mysite/_config.php</strong> files.
<br />
<input type="checkbox" id="ReIn" name="force_reinstall" onclick="document.getElementById('install_button').disabled = !this.checked" /><label for="ReIn">That's okay, please re-install SilverStripe and overwrite these files.</label>
</p>
<?php } ?>
<p>
<?php if($alreadyInstalled) { ?>
<input id="install_button" type="submit" disabled="disabled" class="action" name="go" value="Install SilverStripe" onclick="document.getElementById('saving_top').style.display = ''; this.value = 'Installing SilverStripe...'" />
<?php } else { ?>
<input id="install_button" type="submit" class="action" name="go" value="Install SilverStripe" onclick="document.getElementById('saving_top').style.display = ''; this.value = 'Installing SilverStripe...'" />
<?php } ?>
<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" />
<h4>MySQL Database</h4>
<?php if($dbReq->hasErrors()) { ?>
<p class="error"><!-- 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 id="mysql_credentials">
<label for="mysql_server">MySQL server:</label>
<span class="middleColumn"><input id="mysql_server" class="text" type="text" name="mysql[server]" value="<?php echo $databaseConfig['server']; ?>" /></span>
<label for="mysql_username">MySQL username:</label>
<span class="middleColumn"><input id="mysql_username" class="text" type="text" name="mysql[username]" value="<?php echo $databaseConfig['username']; ?>" /></span>
<label for="mysql_password">MySQL password:</label>
<span class="middleColumn"><input id="mysql_password" class="text" type="password" name="mysql[password]" value="<?php echo $databaseConfig['password']; ?>" /></span>
<label for="mysql_database">MySQL database:</label>
<span class="middleColumn"><input id="mysql_database" class="text" type="text" name="mysql[database]" value="<?php echo $databaseConfig['database']; ?>" onchange="this.value = this.value.replace(/[^A-Za-z0-9_]+/g,'');" /></span>
<input type="submit" class="action" value="Re-check requirements" />
</p>
<p class="mysql">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>
<div class="clear"><!-- --></div>
<h5>Details</h5>
<?php $dbReq->showTable("MySQL Configuration"); ?>
<br />
<h4>SilverStripe Administration Account</h4>
<p id="AdminAccount">
<label for="admin_username">Administrator email:</label>
<span class="middleColumn"><input type="text" class="text" name="admin[username]" id="admin_username" value="<?php echo $adminConfig['username']; ?>" /></span>
<label for="admin_password">Administrator password:</label>
<span class="middleColumn"><input type="text" class="text" name="admin[password]" id="admin_password" value="<?php echo $adminConfig['password']; ?>" /></span>
<label for="admin_firstname">Administrator first name:</label>
<span class="middleColumn"><input type="text" class="text" name="admin[firstname]" id="admin_firstname" value="<?php echo $adminConfig['firstname']; ?>" /></span>
<label for="admin_surname">Administrator surname:</label>
<span class="middleColumn"><input type="text" class="text" name="admin[surname]" id="admin_surname" value="<?php echo $adminConfig['surname']; ?>" /></span>
</p>
<p class="adminAcc">
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>
<br />
<h4>Development Servers</h4>
<p id="DevSites">
<label for="devsites">Development servers:</label>
<span class="middleColumn"><textarea name="devsites" id="devsites" rows="5" />localhost
127.0.0.1</textarea></span>
</p>
<p class="devHelp">
SilverStripe allows you to run a site in <a href="http://doc.silverstripe.com/doku.php?id=devmode">development mode</a>.
This shows all error messages in the web browser instead of emailing them to the administrator, and allows
the database to be built without logging in as administrator. Please enter the host/domain names for servers
you will be using for development.
</p>
<br />
<h4 id="requirements">Requirements</h4>
<?php
$req->showTable();
?>
</form>
</div>
</div>
<div class="clear"><!-- --></div>
</div>
<div id="Footer">
<div class="footerTop"><!-- --></div>
<p><a href="http://www.silverstripe.com">SilverStripe Open Source CMS</a> | Copyright &copy; 2008 SilverStripe Limited</p>
</div>
</div>
</body>
</html>

118
dev/install/install.css Normal file
View File

@ -0,0 +1,118 @@
body {
text-align: center;
}
#Container * {
text-align: left;
}
ul#Themes{
list-style: none;
margin: 5px;
}
ul#Themes li {
clear: both;
padding: 3px 0;
}
ul#Themes input {
float: left;
width: 10px;
height: 10px;
}
ul#Themes label {
margin: -2px 5px 0 15px;
}
.good td {
color: green;
}
.warning td {
color: #ef7f24;
}
.testResults .error td {
border: 1px #CCC solid;
color: red;
}
p.error {
padding: 0.5em;
background-color: #ffe9e9;
border: 1px #ff8e8e solid;
color: #f03838;
}
p.warning {
padding: 0.5em;
background-color: #fef1e1;
border: 1px #ffc28b solid;
color: #cb6a1c;
}
p.warning label {
display: inline;
margin-left: 5px;
color: #cb6a1c
}
p.good {
padding: 0.5em;
background-color: #e2fee1;
border: 1px #43cb3e solid;
color: #359318;
}
p.error a,
p.warning a,
p.good a {
color: inherit;
text-decoration: underline;
}
p.error a:hover {
text-decoration: none;
}
span.middleColumn {
width: 312px;
margin-right: 0;
padding: 4px;
}
input.text, textarea, select {
padding: 2px;
border: 1px solid #A7A7A7;
color: #000;
font-size: 1.2em;
font-weight: bold;
width: 305px;
}
#stats {
float: left;
margin: 5px;
}
table.testResults {
border-collapse: collapse;
width: 100%;
margin: 10px 0;
}
#Layout h4 {
font-size: 2em;
clear: left;
}
.testResults td {
border: 1px #CCC solid;
width: 400px;
padding: 4px;
}
.clear {
clear: both;
}
p.mysql,
p.adminAcc,
p.devHelp {
padding-top: 20px;
}
p#mysql_credentials,
p#AdminAccount,
p#DevSites {
width: 330px;
margin-top: 0;
float: left;
}
#Layout input.action {
text-align: center;
width: 160px;
font-size: 1em;
}

View File

@ -0,0 +1,40 @@
<html>
<head>
<title>PHP 5 is required</title>
<link rel="stylesheet" type="text/css" href="themes/blackcandy/css/layout.css" />
<link rel="stylesheet" type="text/css" href="themes/blackcandy/css/typography.css" />
<link rel="stylesheet" type="text/css" href="themes/blackcandy/css/form.css" />
<link rel="stylesheet" type="text/css" href="sapphire/dev/install/install.css" />
</head>
<body>
<div id="BgContainer">
<div id="Container">
<div id="Header">
<h1>SilverStripe CMS Installation</h1>
</div>
<div id="Navigation">&nbsp;</div>
<div class="clear"><!-- --></div>
<div id="Layout">
<div class="typography">
<h1>PHP 5 required</h1>
<h2>To run SilverStripe, please install PHP 5.0 or greater.</h2>
<p>We have detected that you are running PHP version <b>$PHPVersion</b>. In order to run SilverStripe,
you must have PHP version 5.0 or greater, and for best results we recommend PHP 5.2 or greater.</p>
<p>If you are running on a shared host, you may need to ask your hosting provider how to do this.</p>
</div>
</div>
<div class="clear"><!-- --></div>
</div>
<div id="Footer">
<div class="footerTop"><!-- --></div>
<p><a href="http://www.silverstripe.com">SilverStripe Open Source CMS</a> | Copyright &copy; 2008 SilverStripe Limited</p>
</div>
</div>
</body>
</html>

View File

@ -1,5 +1,21 @@
<?php
/************************************************************************************
************************************************************************************
** **
** If you can read this text in your browser then you don't have PHP installed. **
** Please install PHP 5.0 or higher, preferably PHP 5.2. **
** **
************************************************************************************
************************************************************************************/
$majorVersion = strtok(phpversion(),'.');
if($majorVersion < 5) {
header("HTTP/1.1 500 Server Error");
echo str_replace('$PHPVersion', phpversion(), file_get_contents("dev/install/php5-required.html"));
die();
}
/**
* Main file that handles every page request.
*