diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2009-02-28 21:01:33 -0800 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2009-02-28 21:01:33 -0800 |
commit | 458c03786735bd3e3b6619b2d20538bd55acd0c6 (patch) | |
tree | c133f9f3c711ae1babccc1bcc12485194c776ec5 | |
parent | 2ad667f704300dcb825a4822d567cbc8ebfebe02 (diff) |
check some prereqs for installation
-rw-r--r-- | install.php | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/install.php b/install.php index a34214c48..18fc362b6 100644 --- a/install.php +++ b/install.php @@ -3,7 +3,11 @@ define('INSTALLDIR', dirname(__FILE__)); function main() { - checkPrereqs(); + if (!checkPrereqs()) + { + return; + } + if ($_SERVER['REQUEST_METHOD'] == 'POST') { handlePost(); } else { @@ -13,6 +17,55 @@ function main() function checkPrereqs() { + if (file_exists(INSTALLDIR.'/config.php')) { + ?><p class="error">Config file "config.php" already exists.</p> + <? + return false; + } + + if (version_compare(PHP_VERSION, '5.0.0', '<')) { + ?><p class="error">Require PHP version 5 or greater.</p><? + return false; + } + + $reqs = array('gd', 'mysql', 'curl', + 'xmlwriter', 'mbstring', + 'gettext'); + + foreach ($reqs as $req) { + if (!checkExtension($req)) { + ?><p class="error">Cannot load required extension "<?= $req ?>".</p><? + return false; + } + } + + if (!is_writable(INSTALLDIR)) { + ?><p class="error">Cannot write config file to "<?= INSTALLDIR ?>".</p> + <p>On your server, try this command:</p> + <blockquote>chmod a+w <?= INSTALLDIR ?></blockquote> + <? + return false; + } + + if (!is_writable(INSTALLDIR.'/avatar/')) { + ?><p class="error">Cannot write avatar directory "<?= INSTALLDIR ?>/avatar/".</p> + <p>On your server, try this command:</p> + <blockquote>chmod a+w <?= INSTALLDIR ?>/avatar/</blockquote> + <? + return false; + } + + return true; +} + +function checkExtension($name) +{ + if (!extension_loaded($name)) { + if (!dl($name.'.so')) { + return false; + } + } + return true; } function showForm() |