diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2009-06-10 04:46:20 +0000 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2009-06-10 04:46:20 +0000 |
commit | 4110838cb44c9e2e54f8ff8d722fdcbc5666fafe (patch) | |
tree | 51335c05e93194217c90a46b21e5477bba47c378 /install.php | |
parent | 003c63e587128c6d095386c563c2615c2ac245c2 (diff) | |
parent | 207750e75774c823328889cb4102aad6a0b12281 (diff) |
Merge branch '0.8.x' of git://gitorious.org/laconica/dev into dev/0.8.x
Diffstat (limited to 'install.php')
-rw-r--r-- | install.php | 61 |
1 files changed, 33 insertions, 28 deletions
diff --git a/install.php b/install.php index 32915200b..133f2b30f 100644 --- a/install.php +++ b/install.php @@ -35,15 +35,17 @@ function main() function checkPrereqs() { + $pass = true; + if (file_exists(INSTALLDIR.'/config.php')) { ?><p class="error">Config file "config.php" already exists.</p> <?php - return false; + $pass = false; } if (version_compare(PHP_VERSION, '5.0.0', '<')) { ?><p class="error">Require PHP version 5 or greater.</p><?php - return false; + $pass = false; } $reqs = array('gd', 'mysql', 'curl', @@ -53,7 +55,7 @@ function checkPrereqs() foreach ($reqs as $req) { if (!checkExtension($req)) { ?><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>On your server, try this command: <code>chmod a+w <?php echo INSTALLDIR; ?></code> <?php - return false; + $pass = false; } if (!is_writable(INSTALLDIR.'/avatar/')) { ?><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> <? - return false; + $pass = false; } - return true; + return $pass; } function checkExtension($name) @@ -115,16 +117,16 @@ function showForm() <p class="form_guide" id='fancy-form_guide'>Enable fancy (pretty) URLs. Auto-detection failed, it depends on Javascript.</p> </li> <li> - <label for="host">Hostname</label> - <input type="text" id="host" name="host" /> - <p class="form_guide">Database hostname</p> - </li> - <li> <label for="host">Site path</label> <input type="text" id="path" name="path" value="$config_path" /> <p class="form_guide">Site path, following the "/" after the domain name in the URL. Empty is fine. Field should be filled automatically.</p> </li> <li> + <label for="host">Hostname</label> + <input type="text" id="host" name="host" /> + <p class="form_guide">Database hostname</p> + </li> + <li> <label for="host">Database</label> <input type="text" id="database" name="database" /> <p class="form_guide">Database name</p> @@ -173,36 +175,38 @@ function handlePost() <dd> <ul> <?php + $fail = false; + if (empty($host)) { updateStatus("No hostname specified.", true); - showForm(); - return; + $fail = true; } if (empty($database)) { updateStatus("No database specified.", true); - showForm(); - return; + $fail = true; } if (empty($username)) { updateStatus("No username specified.", true); - showForm(); - return; + $fail = true; } if (empty($password)) { updateStatus("No password specified.", true); - showForm(); - return; + $fail = true; } if (empty($sitename)) { updateStatus("No sitename specified.", true); - showForm(); - return; + $fail = true; } + if($fail){ + showForm(); + return; + } + updateStatus("Starting installation..."); updateStatus("Checking database..."); $conn = mysql_connect($host, $username, $password); @@ -247,7 +251,7 @@ function handlePost() } updateStatus("Done!"); 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 @@ -257,16 +261,17 @@ function writeConf($sitename, $sqlUrl, $fancy, $path) { $res = file_put_contents(INSTALLDIR.'/config.php', "<?php\n". + "if (!defined('LACONICA')) { exit(1); }\n\n". "\$config['site']['name'] = \"$sitename\";\n\n". ($fancy ? "\$config['site']['fancy'] = true;\n\n":''). "\$config['site']['path'] = \"$path\";\n\n". - "\$config['db']['database'] = \"$sqlUrl\";\n\n"); + "\$config['db']['database'] = \"$sqlUrl\";\n\n". + "?>"); return $res; } function runDbScript($filename, $conn) { -return true; $sql = trim(file_get_contents($filename)); $stmts = explode(';', $sql); foreach ($stmts as $stmt) { @@ -290,13 +295,13 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US"> <head> <title>Install Laconica</title> - <link rel="stylesheet" type="text/css" href="theme/base/css/display.css?version=0.8" media="screen, projection, tv"/> + <link rel="shortcut icon" href="favicon.ico"/> <link rel="stylesheet" type="text/css" href="theme/default/css/display.css?version=0.8" media="screen, projection, tv"/> <!--[if IE]><link rel="stylesheet" type="text/css" href="theme/base/css/ie.css?version=0.8" /><![endif]--> <!--[if lte IE 6]><link rel="stylesheet" type="text/css" theme/base/css/ie6.css?version=0.8" /><![endif]--> - <!--[if IE]><link rel="stylesheet" type="text/css" href="theme/earthy/css/ie.css?version=0.8" /><![endif]--> - <script src='js/jquery.min.js'></script> - <script src='js/install.js'></script> + <!--[if IE]><link rel="stylesheet" type="text/css" href="theme/default/css/ie.css?version=0.8" /><![endif]--> + <script src="js/jquery.min.js"></script> + <script src="js/install.js"></script> </head> <body id="install"> <div id="wrap"> |