Removed return from 1st line of runDbScript()
fixed broken html tag on success page. handlePost() now will show as many errors as it can (instead of one at a time) checkPrereqs() will show all errors at once instead of failing on first one, installer will be able to try to fix all instead of fixing one at a time and trying again. writeConf(): added if LACONICA is !defined exit Tests: drop database and remove config.php, ran installer. Passed.
This commit is contained in:
parent
dbf82f7c1e
commit
a3280961d2
36
install.php
36
install.php
|
@ -35,15 +35,17 @@ function main()
|
||||||
|
|
||||||
function checkPrereqs()
|
function checkPrereqs()
|
||||||
{
|
{
|
||||||
|
$pass = true;
|
||||||
|
|
||||||
if (file_exists(INSTALLDIR.'/config.php')) {
|
if (file_exists(INSTALLDIR.'/config.php')) {
|
||||||
?><p class="error">Config file "config.php" already exists.</p>
|
?><p class="error">Config file "config.php" already exists.</p>
|
||||||
<?php
|
<?php
|
||||||
return false;
|
$pass = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version_compare(PHP_VERSION, '5.0.0', '<')) {
|
if (version_compare(PHP_VERSION, '5.0.0', '<')) {
|
||||||
?><p class="error">Require PHP version 5 or greater.</p><?php
|
?><p class="error">Require PHP version 5 or greater.</p><?php
|
||||||
return false;
|
$pass = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$reqs = array('gd', 'mysql', 'curl',
|
$reqs = array('gd', 'mysql', 'curl',
|
||||||
|
@ -53,7 +55,7 @@ function checkPrereqs()
|
||||||
foreach ($reqs as $req) {
|
foreach ($reqs as $req) {
|
||||||
if (!checkExtension($req)) {
|
if (!checkExtension($req)) {
|
||||||
?><p class="error">Cannot load required extension: <code><?php echo $req; ?></code></p><?php
|
?><p class="error">Cannot load required extension: <code><?php echo $req; ?></code></p><?php
|
||||||
return false;
|
$pass = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,17 +63,17 @@ function checkPrereqs()
|
||||||
?><p class="error">Cannot write config file to: <code><?php echo INSTALLDIR; ?></code></p>
|
?><p class="error">Cannot write config file to: <code><?php echo INSTALLDIR; ?></code></p>
|
||||||
<p>On your server, try this command: <code>chmod a+w <?php echo INSTALLDIR; ?></code>
|
<p>On your server, try this command: <code>chmod a+w <?php echo INSTALLDIR; ?></code>
|
||||||
<?php
|
<?php
|
||||||
return false;
|
$pass = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_writable(INSTALLDIR.'/avatar/')) {
|
if (!is_writable(INSTALLDIR.'/avatar/')) {
|
||||||
?><p class="error">Cannot write avatar directory: <code><?php echo INSTALLDIR; ?>/avatar/</code></p>
|
?><p class="error">Cannot write avatar directory: <code><?php echo INSTALLDIR; ?>/avatar/</code></p>
|
||||||
<p>On your server, try this command: <code>chmod a+w <?php echo INSTALLDIR; ?>/avatar/</code></p>
|
<p>On your server, try this command: <code>chmod a+w <?php echo INSTALLDIR; ?>/avatar/</code></p>
|
||||||
<?
|
<?
|
||||||
return false;
|
$pass = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return $pass;
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkExtension($name)
|
function checkExtension($name)
|
||||||
|
@ -173,32 +175,34 @@ function handlePost()
|
||||||
<dd>
|
<dd>
|
||||||
<ul>
|
<ul>
|
||||||
<?php
|
<?php
|
||||||
|
$fail = false;
|
||||||
|
|
||||||
if (empty($host)) {
|
if (empty($host)) {
|
||||||
updateStatus("No hostname specified.", true);
|
updateStatus("No hostname specified.", true);
|
||||||
showForm();
|
$fail = true;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($database)) {
|
if (empty($database)) {
|
||||||
updateStatus("No database specified.", true);
|
updateStatus("No database specified.", true);
|
||||||
showForm();
|
$fail = true;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($username)) {
|
if (empty($username)) {
|
||||||
updateStatus("No username specified.", true);
|
updateStatus("No username specified.", true);
|
||||||
showForm();
|
$fail = true;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($password)) {
|
if (empty($password)) {
|
||||||
updateStatus("No password specified.", true);
|
updateStatus("No password specified.", true);
|
||||||
showForm();
|
$fail = true;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($sitename)) {
|
if (empty($sitename)) {
|
||||||
updateStatus("No sitename specified.", true);
|
updateStatus("No sitename specified.", true);
|
||||||
|
$fail = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($fail){
|
||||||
showForm();
|
showForm();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -247,7 +251,7 @@ function handlePost()
|
||||||
}
|
}
|
||||||
updateStatus("Done!");
|
updateStatus("Done!");
|
||||||
if ($path) $path .= '/';
|
if ($path) $path .= '/';
|
||||||
updateStatus("You can visit your <a href='/$path'>new Laconica site</a).");
|
updateStatus("You can visit your <a href='/$path'>new Laconica site</a>.");
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
@ -257,6 +261,7 @@ function writeConf($sitename, $sqlUrl, $fancy, $path)
|
||||||
{
|
{
|
||||||
$res = file_put_contents(INSTALLDIR.'/config.php',
|
$res = file_put_contents(INSTALLDIR.'/config.php',
|
||||||
"<?php\n".
|
"<?php\n".
|
||||||
|
"if (!defined('LACONICA')) { exit(1); }\n\n".
|
||||||
"\$config['site']['name'] = \"$sitename\";\n\n".
|
"\$config['site']['name'] = \"$sitename\";\n\n".
|
||||||
($fancy ? "\$config['site']['fancy'] = true;\n\n":'').
|
($fancy ? "\$config['site']['fancy'] = true;\n\n":'').
|
||||||
"\$config['site']['path'] = \"$path\";\n\n".
|
"\$config['site']['path'] = \"$path\";\n\n".
|
||||||
|
@ -267,7 +272,6 @@ function writeConf($sitename, $sqlUrl, $fancy, $path)
|
||||||
|
|
||||||
function runDbScript($filename, $conn)
|
function runDbScript($filename, $conn)
|
||||||
{
|
{
|
||||||
return true;
|
|
||||||
$sql = trim(file_get_contents($filename));
|
$sql = trim(file_get_contents($filename));
|
||||||
$stmts = explode(';', $sql);
|
$stmts = explode(';', $sql);
|
||||||
foreach ($stmts as $stmt) {
|
foreach ($stmts as $stmt) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user