tags:

views:

34

answers:

0

Hi guys I created an install wizard but its quite basic and only runs mysqli. How do you think I could best expand this? (non-mysql), what other features are required? I plan to use it for any of my clients who wish for me to create them an app but not give away any server details.

Ok so the file structure looks a little like this

connection |---databaseSet.class.php |---database.class.php |---connection.ini

installWizard |---installer.php |---tables.sql

and my code thus far

[databaseSettings file]

<?php

    class databaseSet{

    // can only be called by children
    protected $server;
    protected $username;
    protected $password;
    protected $database;
    protected $errorlog;

    public function __construct(){
        // parse ini file
        $ini = parse_ini_file('connection.ini');//(block with .httaccess)

        // assign settings to vars
        $this->server   = $ini['server'];
        $this->username = $ini['username'];
        $this->password = $ini['password'];
        $this->database = $ini['database'];
        $this->errorlog = '../logs/errorlog.txt';

    }



    }// end databaseSet class

?>

[database file]

<?php

    require_once(dirname(__FILE__) . 'databaseSet.class.php' );

    class database extends databaseSet{

        private $link;

        public function __construct(){

            // construct database settings
            parent::__construct();

            if(is_null($this->link)):
                $this->connect();
                endif;
        }

        public function connect(){
            // create connection
            $this->link = @mysqli_connect($this->server, $this->username, $this->password, $this->database);
            // test connection
            if(@mysqli_connect_errno()):

                // generate user error
                die('Unable to establish a database connection, contact an admin!<br />');
                // generate system error 
                error_log(date('D M Y H:i:s') . " | " . mysqli_connect_error() . "\n", 3, $this->errorlog);
        }

        //........to be continued

    }// end database class
?>

[connection.ini]

<?php
; File created by install wizard on 26/06/2010 @ 17:15

[Database Config]
;Server name(usually localhost, but check with your host first)
server = 'localhost';
;Database Username
username = 'root';
;Database password
password = '********';
;Database Name
database = 'mydatabase';

?>

[Installer.php Web file]

<?php

    if(isset($_GET['install']))
     {
     $install = $_GET['install'];
     }
     else
     {
     $install = 'welcome';
     }


     switch($install)
    {
        case 'welcome':
        echo 'Welcome to the mysql Install Wizard';
        break;

        case 'gatherdetails':
        // show form to gather details
        break;

        case 'testConnection':
        //test the connection
        break;

        case 'create config':
        //create the config.ini file
        break;

        case 'installTables':
        //install tables from tables.sql
        break;

        case 'createAdmin':
        //create an admin account
        break;


?>