function main()
{
- checkPrereqs();
+ if (!checkPrereqs())
+ {
+ return;
+ }
+
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
handlePost();
} else {
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()