Location: PHPKode > scripts > NConf > nconf-1.3.0-0/nconf/UPDATE.php
<?php
###
###  WELCOME TO NConf, configuration files are located here : config/..
###
#
# CONFIG
#

if ( !file_exists('config/nconf.php') ){
    $nconfdir = dirname( $_SERVER["SCRIPT_FILENAME"] );
    require_once('config.orig/authentication.php');
    require_once('include/functions.php');
    require_once('include/includeAllClasses.php');
    require_once('config.orig/nconf.php');
    require_once 'include/head.php';
    // here it will fail if update is not possible (when nconf is not already installed)
}else{
    require_once('main.php');
}



#
# Step handling
#
if ( !isset($_POST["step"]) ){
    $step = 0;
}else{
    $step = $_POST["step"];
    if (isset($_POST["submit"]) AND $_POST["submit"] == "Back"){
        # Back button pressed
        $step = $step - 1;
    }elseif(isset($_POST["submit"]) AND $_POST["submit"] == "Next"){
        # increase step for next form
        $step++;
    }else{
        #refreshing, no step modification
    }
    
}


#
# DB creation / handling
#
if (isset($_POST["db_status"])){
    $db_check = $_POST["db_status"];
}elseif (!empty($_GET["from"]) AND $_GET["from"] == "install" ){
    # coming from install when user already has an nconf installation
    $db_check = "connect";
    $step = 1;
}else{
    $db_check = FALSE;
}
unset($_POST["db_status"]);
if ( ($step == 2 AND $_POST["submit"] != "Back") AND !($db_check == "ok") ){
    # run again the Database part
    $step = 1;
}

# migrate handling
if (!empty($_POST["submit"]) AND $_POST["submit"] == "Convert" ){
    # do noting, the migrate scripts will do something
    $migrate = TRUE;
    $db_check = "upgrade";
}


# define installation/configuration
$_SESSION["install"] = TRUE;
require_once 'include/head.php';

###
### Functions for install
###

#
# Function which generates the html output (table rows)
#
function check_session_value($name){
    if ( isset($_SESSION["update_data"]) ){
        if (is_array($_SESSION["update_data"]) ){
            foreach ($_SESSION["update_data"] as $step){
                if ( array_key_exists($name, $step) ){
                    return $step[$name];
                }
            }
        }
    }
    # if not in session, load data from config, else use default values
    if ( defined($name) ){
        return constant($name);
    }
    return FALSE;
}

function table_row_text($title, $value, $description, $type = "text", $attention = 0, $disabled = 0, $check_input = 0){
    $cache_value = check_session_value($title);
    if ($cache_value) $value = $cache_value;
    $row = '
        <tr>
            <td width=150>'.$title.'</td>
        <td width=270>';
        $row .= '<input type="'.$type.'" name="'.$title.'" maxlength=50 value="'.$value.'"';
            if ($disabled == 1) $row .= ' disabled="disabled" ';
            if ($check_input == 1) $row .= ' onchange="check_input()" onkeyup="check_input()"';
        $row .= '>';
        $row .= '</td><td width=20 class="attention">';
            if ($attention == 1) $row .= "*";
        $row .= '</td><td>';
            if (!empty($description)) $row .= $description;
        $row .= '</td></tr>';
    return $row;
}
function table_row_select($title, $values, $selected, $description, $attention = 0, $check_input = 0){
    $cache_value = check_session_value($title);
    if ($cache_value) $selected = $cache_value;
    $row = '
        <tr>
            <td width=150>'.$title.'</td>
        <td width=270>';
        $row .= '<select name="'.$title.'"';
        if ($check_input == 1) $row .= ' onchange="check_input()"';
        $row .= '>';
        foreach ($values as $name => $value){
            $row .= '<option value="'.$value.'"';
            if ($value == $selected) $row .= ' selected';
            $row .= '>'.$name.'</option>';
        }
        $row .= '</select>';
        $row .= '</td><td width=20 class="attention">';
            if ($attention == 1) $row .= "*";
        $row .= '</td><td>';
            if (!empty($description)) $row .= $description;
        $row .= '</td></tr>';
    return $row;
}

function table_row_description($title, $description, $display = ""){
    $row = "";
    if (!empty($title)){
        $row = '
        <tr id="'.$title.'_titel" name="'.$title.'" style="display:'.$display.'">
            <td colspan=3><h2>'.$title.'</h2></td>
        </tr>';
    }
    if (!empty($description)){
    $row .= '<tr id="'.$title.'_desc" name="'.$title.'" style="display:'.$display.'">
            <td colspan=3>'.$description.'<br><br></td>
        </tr>
    ';
    }

    return $row;
}


function table_row_check($title, $status){
    if ($status === TRUE){
        $row = '
        <tr>
            <td><b>'.$title.'</b></td>
            <td class="status_ok">OK</td>
            <td></td>
        </tr>';
    }elseif ($status == "UNKNOWN"){
        $row = '
        <tr>
            <td><b>'.$title.'</b></td>
            <td class="status_unknown">UNKNOWN</td>
            <td></td>
        </tr>';
    }elseif ($status === FALSE OR $status == 'ATTENTION'){
        $status = ($status === FALSE) ? 'FAILED' : $status;
        $row = '
        <tr>
            <td><b>'.$title.'</b></td>
            <td class="status_failed">'.$status.'</td>
            <td></td>
        </tr>';
    }else{
        $row = '
        <tr class="ui-widget-header header">
            <td><b>'.$title.'</b></td>
            <td class="status_failed">FAILED</td>
            <td>
                <a href="javascript:swap_visible(\''.$title.'\')">
                <img src="img/icon_expand.gif" id="swap_icon_'.$title.'" > 
                show errorcode
                </a>
            </td>
        </tr>
        <tr id="'.$title.'" style="display:none"  class="ui-widget-content">
            <td colspan=3 class="ui-nconf-content">'.$status.'</td>
        </tr>';

    }

    return $row;
}


function write_config($file, $replacers, $special = ''){
    global $error;
    global $info;
    foreach($replacers as $replacer){
        if ( check_session_value($replacer) === FALSE){
            message($error, "Not all necessary config variables are present. ($replacer)");
            return FALSE;
        }
    }
    # read the config file
    $lines = file($file);
    if ($lines === FALSE){
        message($error, "The config file ($file) could not be read.");
        return FALSE;
    }

    # try to open config file writable, else readable
    if (is_writable($file)) {
        $fh = fopen($file, "w");
    }else{
        $fh = fopen($file, "r");
        message($error, "read only");
    }
    if ($fh === FALSE){
        message($error, "The config file ($file) could not be opened.");
        return FALSE;
    }else{
        $new_config = '';
        $log = '';
        # go thru each line
        foreach ($lines as $line){
            $mark_line = 0;

            # ignore comments
            if ( !preg_match( '/^#/', $line) ){
                # find the replacer (the constant)
                foreach ($replacers as $replacer){
                    if ($special == "password_file"){
                        if ( preg_match( '/^admin/', $line) ){
                            $line = "admin::".check_session_value($replacer)."::admin::Administrator::\n";
                            $mark_line = 1;
                        }
                    }else{
                        if ( preg_match( '/^define\(["\']'.$replacer.'["\']/', $line) ){
                            $line = "define('$replacer', '".check_session_value($replacer)."');\n";
                            $mark_line = 1;
                        }
                    }
                }
            }

            # mark the new lines
            if ($mark_line){
                $log .= "<b>".htmlspecialchars($line)."</b><br>";
            }else{
                $log .= htmlspecialchars($line)."<br>";
            }
            
            # add line to config var
            $new_config .= $line;
        }


        #write to file
        if ( fwrite($fh, $new_config) == FALSE){
            # could not write to file, put out config code on page
            message($info, "The config directory and all its content must be writable for your webserver user", "overwrite");
            message($error, "Could not write config file ($file), please change the <b>bold lines</b> manually or remotely upload the file into the config directory");
            return $log;
        }else{
            # write file success
            return TRUE;
        }
        fclose($fh);
    
    }

}

# For creating/importing the database
function parse_mysql_dump($url){
	$result = FALSE;
    $file_content = file($url);
    $query = "";
    foreach($file_content as $sql_line){
      if(trim($sql_line) != "" && strpos($sql_line, "--") === false){
        $query .= $sql_line;
		// TODO: check compatibility of regex
		// This regex does not work on xampp:
		//   if(preg_match("/;[\040]*\$/", $sql_line)){
		//   - why is there a backslash bevore $
		//   - [\040] seems not work on xampp (windows) installation
        if(preg_match('/;[\s]*$/', $sql_line)){
          $result = mysql_query($query);
          if (!$result) return $result;

          $query = "";
        }
      }
    }
    return $result;
}


function upgrade_mysql($file){
    $update = parse_mysql_dump($file);
    return $update;
}

function print_file($file){
    $file_content = @file_get_contents($file);
    if ($file_content !== FALSE){
        echo '<pre class="editor_field">'.$file_content.'</pre>';
        return TRUE;
    }else{
        return FALSE;
    }
}

# upgrade file handling
function upgrade_files($installed_version, $dir, $file_regex, $action, $special = ''){
    # read the directory
    $dirs = getDirectoryTree($dir);
    $success = TRUE;

    # update each separate version
    do {
        # reset next version
        if ( isset($next_update_version) ){
            $installed_version = $next_update_version;
            unset($next_update_version);
        }

        # read the destination version
        foreach($dirs as $update_folder){
            if( preg_match('/^(.*)_to_(.*)$/', $update_folder, $matches) ){
                $from_version = $matches[1];
                $to_version = $matches[2];
                # has actual version a upgrade directory ?
                if($installed_version == $from_version
                    OR ( $special == 'last_readme' AND $installed_version == $to_version )
                ){
                    if (empty($_SESSION["base_version"]) ){
                        NConf_DEBUG::set($installed_version, 'DEBUG', "Saving current installed base version for later reference");
                        $_SESSION["base_version"] = $installed_version;
                    }
                    # or if no update just display the last README file
                    if (empty($special)){
                        $next_update_version = $to_version;
                    }
                    
                    $files = getFiles($dir.'/'.$update_folder);
                    NConf_DEBUG::set($files, 'DEBUG', "files");
                    # prepare pre & after update
                    if ($special == 'upgrade'){
                        # check if file exists
                        if ( in_array('pre_db_update_extension.php', $files) ){
                            $pre_DB_update_script   = $dir.'/'.$update_folder.'/pre_db_update_extension.php';
                        }
                        if ( in_array('after_db_update_extension.php', $files) ){
                            $after_DB_update_script = $dir.'/'.$update_folder.'/after_db_update_extension.php';
                        }
                    }
                    
                    # Migration before db update
                    if ( !empty($pre_DB_update_script) AND is_readable($pre_DB_update_script)) {
                        echo '</table>
                                  <table width="400">';
                        echo table_row_check('Found script to run before update!', 'ATTENTION' );
                        require_once($pre_DB_update_script);
                        if (!$pre_status){
                          return "stopped";
                        }
                    }
                    # normal update process
                    foreach($files as $update_file){
                        if( preg_match($file_regex, $update_file) ){
                            if (($special == "load_extension") AND is_readable($dir.'/'.$update_folder.'/'.$update_file)){
                                include($dir.'/'.$update_folder.'/'.$update_file);
                            }elseif (is_callable($action)){
                                $update = $action($dir.'/'.$update_folder.'/'.$update_file);
                                echo table_row_check('Executing '.$update_file, $update );
                                if (!$update){
                                    $success = FALSE;
                                }
                            }
                        }
                    }
                    
                    # after update migrations
                    if (!empty($after_DB_update_script) AND is_readable($after_DB_update_script)) {
                        echo '</table>
                                  <table width="400">';
                        echo table_row_check('Found migration possibility to run after update!', 'ATTENTION' );
                        require_once($after_DB_update_script);
                        break;
                    }
                }
            }
        }
    } while ( !empty($next_update_version) );

    return $success;
}

# checks if update conflicts with user classes / attributes
$conflict_classes = array();
$conflict_attributes = array();
function db_conflict_check($file){
    global $conflict_classes;
    global $conflict_attributes;
    $success = TRUE;

    $ini_array = parse_ini_file($file, FALSE);
    if ( !empty($ini_array) ){
        # attributes
        foreach ($ini_array AS $class => $entries){
            if ( is_array($entries) ){
                # many attributes on a class defined
                foreach ($entries AS $attribute){
                    if ($attribute == 1){
                        # class
                        $query = 'SELECT id_class FROM ConfigClasses WHERE config_class="'.$class.'"';
                        if ( db_handler($query, "num_rows", "Check update conflict on class: '$class'") > 0){
                            array_push($conflict_classes, $class);
                            $success = FALSE;
                        }
                    }else{
                        # attribute
                        $query = 'SELECT id_attr
                                    FROM ConfigAttrs
                                    WHERE attr_name="'.$attribute.'"
                                    AND fk_id_class=(SELECT id_class FROM ConfigClasses WHERE config_class="'.$class.'")';
                        if ( db_handler($query, "num_rows", "Check update conflict with attribute '$attribute.' on class '$class'") > 0){
                            array_push($conflict_attributes, "$class: $attribute");
                            $success = FALSE;
                        }
                    }
                }
            } // array
        } // loop entries
    } // ini file/array

    return $success;

}

function db_conflict_feedback(){
    global $conflict_classes;
    global $conflict_attributes;

    $feedback = '';
    # class conflict
    if ( !empty($conflict_classes) ){
        $feedback .= NConf_HTML::text('classes:', FALSE, 'b');
        $feedback .= '<ul>';
        foreach ($conflict_classes AS $class){
            $feedback .= '<li>'.$class.'</li>';
        }
        $feedback .= '</ul>';
    }
    # attribute conflict
    if( !empty($conflict_attributes) ){
        $feedback .= NConf_HTML::text('attributes:', FALSE, 'b');
        $feedback .= '<ul>';
        foreach ($conflict_attributes AS $attributes){
            if ( is_array($attributes) ){
                foreach ($attributes AS $attribute){
                    $feedback .= '<li>'.$attribute.'</li>';
                }
            }else{
                $feedback .= '<li>'.$attributes.'</li>';
            }
        }
        $feedback .= '</ul>';
        
        return $feedback;
    }else{
        # no conflict
        return FALSE;
    }
}


#
# Session handling
#
foreach ($_POST as $key => $value){
    #do not save the submit button
    if ( $key == "submit" OR $key == "step" OR !isset($_POST["step"]) ) continue;
    $_SESSION["update_data"][$_POST["step"]][$key] = $value;
}



echo '<form name="install" action="UPDATE.php" method="post">';
echo '<input type=hidden name="step" value="'.$step.'">';

# Begin table
echo '<table width="100%" border=0>';


#
# Install Steps
#


if ($step == 0){
    # some checks
    function find_SQL_Version() {
        $output = shell_exec('mysql -V');
        if ( !$output ){
            # could not execute
            return "UNKNOWN";
        }
        preg_match('/Distrib ([0-9]+[\.0-9]*)/i', $output, $version);
        if ( !empty($version[1]) ){
            return $version[1];
        }else{
            return FALSE;
        }
    }

    function find_PERL_Version() {
        $output = shell_exec('perl -v');
        NConf_DEBUG::set($output, 'DEBUG', "Perl version check");
        if ( !$output ){
            # could not execute
            return "UNKNOWN";
        }
        preg_match('/v([0-9]+[\.0-9]*)/i', $output, $version);
        if ( !empty($version[1]) ){
            return $version[1];
        }else{
            return FALSE;
        }
    }


    # html content
    echo table_row_description("Welcome to NConf update ".VERSION_NUMBER, 'This will update NConf to version "'.VERSION_NUMBER.'"<br>The pre-update check will test your system for NConf.');
    echo '</table>';


    ###
    # WARN if update is not stable version
    if ( constant("VERSION_NOT_FINAL_WARNING") !== ''){
        echo NConf_HTML::limit_space(
            NConf_HTML::show_error('Attention', VERSION_NOT_FINAL_WARNING)
            , 'style="width: 500px;"'
        );
    }


    # shorter table for this step
    echo '<table width="240">';
    echo table_row_description("Requirements", '');
    echo table_row_check('PHP 5.0 (or higher) -> '.phpversion(), version_compare(phpversion(), '5.0', '>=') );

    # mysql version check
    $mysql_status = find_SQL_Version();
    if ($mysql_status == "UNKNOWN"){
        echo table_row_check('MySQL 5.0.2 (or higher)', "UNKNOWN");
    }else{
        echo table_row_check('MySQL 5.0.2 (or higher) -> '.$mysql_status, version_compare($mysql_status, '5.0.2', '>=') );
    }

    # php-mysql support
    $mysql_status = function_exists('mysql_connect');
    if (!$mysql_status) message ($error, 'Could not find function "mysql_connect()"<br>You must configure PHP with mysql support.');
    echo table_row_check('PHP-MySQL support', $mysql_status);


    $perl_status = find_PERL_Version();
    if ($perl_status == "UNKNOWN"){
        echo table_row_check('Perl 5.6 (or higher)', "UNKNOWN");
    }else{
        echo table_row_check('Perl 5.6 (or higher) -> '.$perl_status, version_compare($perl_status, '5.6', '>=') );
    }

}elseif ($step == 1){
        echo table_row_description("MySQL database configuration", 'Please enter the DB information for NConf installation.');
        echo table_row_text("DBHOST", "localhost", "DB server");
        echo table_row_text("DBNAME", "database_name", "DB name");
        echo table_row_text("DBUSER", "user_name", "DB user name");
        echo table_row_text("DBPASS", "password", "DB user password", "password");
	echo '<tr><td><br></td></tr>';

        # shorter table for this step
        echo '</table>';
        # say that next step is the connect db part
        echo '<input type=hidden name="db_status" value="connect">';

        echo '<table width="200">';
        
    if ($db_check !== FALSE ){
        echo table_row_description('Checks', '');
        if (function_exists('mysql_connect')){
            $dbh = @mysql_connect(check_session_value("DBHOST"),check_session_value("DBUSER"),check_session_value("DBPASS"));
            if (!$dbh){
                # unfortunately mysql_error wont give information about last error here
                message($error, 'Could not connect: ' . mysql_error());
                # php >= 5.2.0 provides additional phperror which could give more information about the last mysql error
                if ( function_exists('error_get_last') ){
                    $php_error = error_get_last();
                    message($error, $php_error["message"]);
                }
            }
        }else{
            $dbh = FALSE;
            message($error, '<b>mysql_connect</b> not found, you must install PHP with mysql support!');
        }

        if (!$dbh){
            echo table_row_check('Connect to DB', FALSE );
            $msg_error = NConf_DEBUG::show_debug('ERROR');
            echo table_row_description('', "<br>$msg_error");
        }else{
            echo table_row_check('connect to mysql', TRUE ); 
            $db_selected = @mysql_select_db(check_session_value("DBNAME"));
            if ($db_selected ){
                # DB selected, try to create tables
                echo table_row_check('access database', TRUE ); 

                $installed_version = FALSE;

                # newest version is :
                $newest_version = VERSION_NUMBER;


                ###
                # check installed version
                ###
                # get version directories
                $dirs = getDirectoryTree('UPDATE');
                $update_conflict = FALSE;
                $conflict_feedback = '';
                if ( empty($dirs) ){
                    echo table_row_check('check versions in UPDATE directory', FALSE );
                }else{
                    foreach($dirs as $update_folder){
                        include('UPDATE/'.$update_folder.'/version_check.php');
                    }
                }
                
                # check conflicts before updating
                $conflict_check = upgrade_files($installed_version, 'UPDATE', '/\.ini$/', 'db_conflict_check');

                if ($installed_version){
                    echo table_row_check('DB version detected: '.$installed_version, TRUE );
                    if ( version_compare($installed_version, $newest_version, '>=') ){
                        # check if some updates were done, or if just no update is necessary
                        if ( empty($_SESSION["base_version"]) ){
                             $message = "<br>No update necessary";
                        }else{
                             $message = "<br>Update finished";
                        }
                        echo table_row_description($message, '<input type=hidden name="db_status" value="ok"><input type=hidden name="old_version" value="'.$installed_version.'">');
                    }elseif($db_check == "upgrade" OR $db_check == "upgrade_pass_migrate"){
                        echo table_row_check('update conflict check', $conflict_check );
                        echo '</table>
                                <input type=hidden name="old_version" value="'.$installed_version.'">
                              <table width="300">';
                        echo table_row_description('<br>Update in progress...', '');
                    }else{
                        if (!empty($migrate) ){
                            # ignore update, migration script should do some stuff
                        }elseif ($conflict_check == TRUE){
                            # ok
                            echo table_row_check('update conflict check', TRUE );
                            echo table_row_description('<br>Please proceed to update', '<input type=hidden name="db_status" value="upgrade">');
                        }else{
                            # version check correct, but update conflict detected
                            $feedback = db_conflict_feedback();
                            echo table_row_check('update conflict check', FALSE );
                            # close check table
                            echo '</table>';
                            echo '<table width="100%">';
                            
                            # there will be a db conflict when proceeding
                            echo table_row_description('<br>Conflict detected', 'Setup has detected a possible conflict within the data schema of the NConf application.<br>The following classes / attributes already seem to exist in the database:');
                            echo NConf_HTML::table_row_text( $feedback );
                            echo table_row_description('', 'Adding your own classes / attributes to the schema can lead to unexpected behavour of NConf!
                                <br>Are you sure you wish to proceed with the update? Some of your data could be lost!');
                            echo NConf_HTML::table_row_text('<input type="hidden" name="db_status" value="upgrade">');
                        }
                    }

                    ?>
                    <script type="text/javascript">
                    <!--
                        disable('DBHOST');
                        disable('DBNAME');
                        disable('DBUSER');
                        disable('DBPASS');
                    //-->
                    </script>
                    <?php

                    # upgrade process
                    if ($db_check == "upgrade" OR $db_check == "upgrade_pass_migrate"){
                        # update DB with sql files
                        $success = upgrade_files($installed_version, 'UPDATE', '/\.sql$/', 'upgrade_mysql', $db_check);
                        NConf_DEBUG::set($success, 'DEBUG', "upgrade_files feedback");
                        if ($success === "stopped"){
                            # if status = stopped, the next button should proceed without migrating data
                            echo table_row_description('', '<input type=hidden name="db_status" value="upgrade_pass_migrate">');
                        }else{
                            # DB version is up to date, go to next step
                            if ( VERSION_NUMBER == $installed_version ){
                                echo table_row_description('', '<input type=hidden name="db_status" value="ok">');
                            }else{
                                echo table_row_description('', '<input type=hidden name="db_status" value="upgrade">');
                            }
                            
                        }

                    }  // end of upgrade
                    
                    # Check for perl scripts to give user a choice to run.
                    # These could be scripts for helping migrate data
                    # The logic of these extensions is handled by them self
                    # This feature is not yet complete, because we do not need it until now...
                    //upgrade_files($installed_version, 'UPDATE', '/extension\.php$/', '', 'load_extension');
                    

                }else{
                    echo table_row_check('lookup NConf DB version', FALSE );
                    echo '</table><table width="500">';
                    echo table_row_description("<br><br>NConf version could not be determined.", 'Please enter the correct data to connect to the existing NConf DB.<br>For first-time installation of NConf use the <b><a href="INSTALL.php">INSTALL</a></b> function.');

                }
                

            }else{
                # failed to select db
                echo table_row_check('access database', FALSE ); 
                echo '</table><table width="450">';
                echo table_row_description("Wrong information", 'Please enter the correct data to connect to the existing NConf DB.
                        <br>For first-time installation of NConf use the <b><a href="INSTALL.php">INSTALL</a></b> function.');
            }
        }
    }

}elseif ($step == 2){
    if ( empty($_SESSION["base_version"]) ){
        echo table_row_description("No database update found / no update required", "Please carefully examine the following release notes for additional update instructions.");
        echo '</table>';
        # display the last README
        $update = upgrade_files(VERSION_NUMBER, 'UPDATE', '/^README$/', 'print_file', 'last_readme');
    }else{
        echo table_row_description("Please carefully examine the following release notes for additional update instructions.", '');
        echo '</table>';
        $update = upgrade_files($_SESSION["base_version"], 'UPDATE', '/^README$/', 'print_file');
    }



}elseif ($step == 3){
            echo table_row_description("Update complete", 'Please delete the following files and directories to continue:<br>
                <br>- INSTALL
                <br>- INSTALL.php
                <br>- UPDATE
                <br>- UPDATE.php');
            session_unset();



}





# End table
echo '</table>';

$save_error = FALSE;
echo '<table>
            <tr><td>
                <div id="buttons">';
                if ( $step != 1 ){ echo '<br>'; }
                if ( $step == 1
                    AND (
                        isset($conflict_check) AND ($conflict_check == FALSE)
                        AND ($db_check != "upgrade" )
                    )
                ){ echo '<a href="index.php"><input type="button" value="Cancel"></a>&nbsp;&nbsp;'; }
                if ( $step == 4 AND $save_error === TRUE ){
                    echo '<input type="Submit" value="Retry" name="submit" align="middle">&nbsp;&nbsp;';
                }elseif($step == 3 AND $save_error === FALSE ){
                    # saved, go to index page
                    echo '<input type="button" value="Finish" name="submit" align="middle" onclick="location.href=\'index.php\'">&nbsp;&nbsp;';
                }
                if ($step != 3){
                    echo '<input type="Submit" value="Next" name="submit" align="middle">&nbsp;&nbsp;';
                }
                /*
                if ($step != 0 AND !($step == 4 AND $save_error === FALSE)){
                    echo '<input type="Submit" value="Back" name="submit" align="middle">&nbsp;&nbsp;';
                }*/

                echo'
                <!--<input type="Reset" value="Reset">-->
                </div>
            </td></tr>
        </table>
';
echo '</form>';


#
# Load footer
#
require_once 'include/foot.php';

/* DEBUG HELP
echo '<div align="left"><pre>';
var_dump($_SESSION["install_data"]);
echo '</pre></div>';
*/
###
### Finish
### anything is loaded until here
###
?>
Return current item: NConf