Changeset 25

Show
Ignore:
Timestamp:
2007-11-23 15:57:17 (4 years ago)
Author:
hannes
Message:

made failures of the installer less fatal (ticket #11):

  • template files are only deleted once everything is done
  • database is emptied again on failure
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/includes/lang/en.php

    r20 r25  
    397397$LANG['installer_database_success'] = 'The database has been set up successfully.'; 
    398398$LANG['installer_overall_success'] = "Congratulations! Your Spam Board has been fully set up. If you didn't see any error messages or warnings, it should now be fully functional.<br /><br />You still have some work to do, of course:<ol><li>delete this installer script</li><li>go to <a href=\"%boardurl%\">your board</a></li><li>log in with the admin account you just created</li><li>go to the Administration Panel</li><li>set up at least one category and one forum</li><li>set appropriate permissions on this forum</li><li>deactive maintainance mode in the settings</li></ol>"; 
     399$LANG['installer_warning_cleanup_failed'] = "Warning: Although the installation of your board has been finished successfully, the install script didn't manage to clean every up. This isn't fatal at all, it just meant there are still a few pre-install files floating around your directory tree. If you like to have it completely clean, delete all .tmpl files in includes/config/."; 
    399400 
    400401/* error messages */ 
  • trunk/install.php

    r22 r25  
    169169                    // include new settings again 
    170170                    require('includes/config/settings.php'); 
    171                     // remove settings.tmpl 
    172                     unlink('includes/config/settings.tmpl'); 
    173171                } else { $ok = 0; } 
    174172                /* initialize crypto module */ 
     
    187185                            // set permissions 
    188186                            @chmod('includes/config/crypt.php', 0660); 
    189                             // remove template 
    190                             unlink('includes/config/crypt.tmpl'); 
    191187                            // get new crypto settings 
    192188                            require('includes/config/crypt.php'); 
     
    194190                    } else { $ok = 0; } 
    195191                } else { $ok = 0; } 
    196                 /* move other template files to their actual names */ 
    197                 if (@rename('includes/config/bans.tmpl', 'includes/config/bans.php')) { 
     192                /* copy other template files to their actual names */ 
     193                if (@copy('includes/config/bans.tmpl', 'includes/config/bans.php')) { 
    198194                    @chmod('includes/config/bans.php', 0660); 
    199195                } else { $ok = 0; } 
    200                 if (@rename('includes/config/logins.tmpl', 'includes/config/logins.php')) { 
     196                if (@copy('includes/config/logins.tmpl', 'includes/config/logins.php')) { 
    201197                    @chmod('includes/config/logins.php', 0660); 
    202198                } else { $ok = 0; } 
    203                 if (@rename('includes/config/memberstages.tmpl', 'includes/config/memberstages.php')) { 
     199                if (@copy('includes/config/memberstages.tmpl', 'includes/config/memberstages.php')) { 
    204200                    @chmod('includes/config/memberstages.php', 0660); 
    205201                } else { $ok = 0; } 
     
    297293            } 
    298294        } 
     295        /* clean up */ 
     296        if ($ok == 1) { 
     297            // remove settings.tmpl 
     298            if (@unlink('includes/config/settings.tmpl')) { 
     299            } else { $ok = 2; } 
     300            // remove crypt.tmpl 
     301            if (@unlink('includes/config/crypt.tmpl')) { 
     302            } else { $ok = 2; } 
     303            // remove bans.tmpl 
     304            if (@unlink('includes/config/bans.tmpl')) { 
     305            } else { $ok = 2; } 
     306            // remove logins.tmpl 
     307            if (@unlink('includes/config/logins.tmpl')) { 
     308            } else { $ok = 2; } 
     309            // remove memberstages.tmpl 
     310            if (@unlink('includes/config/memberstages.tmpl')) { 
     311            } else { $ok = 2; } 
     312        } else { 
     313            // something went wrong, so remove everything from the database again 
     314            if ($db = @file_get_contents('db/clean.sql')) { 
     315                // one SQL query at a time 
     316                $db = explode(';', $db); 
     317                foreach ($db as $query) { 
     318                    $C->query(str_replace('%prefix%', $SETTINGS['dbtableprefix'], $query)); 
     319                } 
     320            } 
     321        } 
    299322        /* everything done */ 
    300         if ($ok == 1) { 
     323        if ($ok >= 1) { 
     324            if ($ok == 2) { 
     325                print($LANG['installer_warning_cleanup_failed'] . '<br /><br />'); 
     326            } 
    301327            print(str_replace('%boardurl%', 'http://' . $_SERVER['HTTP_HOST'] . $SETTINGS['webpath'] , $LANG['installer_overall_success'])); 
    302328        }