<?php
/*******************************************************************************
 *   Prepare Empty Database
 *******************************************************************************
 *   GuppY PHP Script - version 6.0
 *   CeCILL Copyright (C) 2004-2020 by Laurent Duveau
 *   Initiated by Laurent Duveau and Nicolas Alves
 *   Web site = https://www.freeguppy.org/
 *   e-mail   = guppy@freeguppy.org
 *   V6 developed by Lud Bienaimé
 *      with the participation of the GuppY Team
 *******************************************************************************
 *   Latest Changes :
 * v6.00.00 (December 15, 2020) : initial release
 ******************************************************************************/

header('Pragma: no-cache');
define('CHEMIN', '../');
$selskin = 'no_skin';
include CHEMIN.'inc/includes.inc';
include $lng.'-install.inc';
include 'func_install.php';

$form  = import('form');
$doing = import('doing');


if (empty($form)) {
    DisplayHeader();
	echo '
<p style="text-align:center;">
  <a href="Javascript: window.location=\'cleanup.php?lng='.$lang[0].'\';">
    <i class="flg-'.$lang[0].'" title="'.$lang[0].'"></i>
  </a>
  &nbsp;&nbsp;&nbsp;&nbsp;
  <a href="Javascript: window.location=\'cleanup.php?lng='.$lang[1].'\';">
    <i class="flg-'.$lang[1].'" title="'.$lang[1].'"></i>
  </a>
</p>';
	DisplayTitre($clean[16], $clean[17].'<br /><br />'.$clean[3]);
	echo '
<form name="instal0" action="cleanup.php?lng='.$lng.'" method="post">
  <input type="hidden" name="form" value="1"/>
  <div style="text-align:center;">'.SubmitButton($clean[4]).'&nbsp;&nbsp;
    <button type="reset" style="cursor:pointer;" title="'.$clean[0].'" onclick="window.location=\'install.php?lng='.$lng.'&form=1\';">'.$clean[0].'</button>
  </div>
</form>';
} elseif ($form == '1') {
    DisplayHeader();
	DisplayTitre($clean[18], $clean[19]);
	echo '
<form name="instal1" action="cleanup.php?lng='.$lng.'" method="post">
  <input type="hidden" name="form" value="2"/>
  <div style="text-align:center;">'.SubmitButton($clean[4]).'&nbsp;&nbsp;
    <button type="reset" style="cursor:pointer;" title="'.$clean[0].'" onclick="window.location=\'install.php?lng='.$lng.'&form=1\';">'.$clean[0].'</button>
  </div>
</form>';
} elseif ($form == '2') {
	if (empty($doing)) {
        DisplayHeader('cleanup.php?lng='.$lng.'&form=2&doing=1');
		CleanDataRep();
		DisplayProcess($clean[18], $clean[20], $clean[21]);
	} elseif ($doing == '1') {
        DisplayHeader('cleanup.php?lng='.$lng.'&form=2&doing=2');
		PrepareDataRep();
		DisplayProcess($clean[18], $clean[20], $clean[21].'<br />'.$clean[22]);
	} elseif ($doing == '2') {
        DisplayHeader('cleanup.php?lng='.$lng.'&form=3');
		DisplayProcess($clean[18], $clean[23], $clean[21].'<br />'.$clean[22]);
	}
} elseif ($form == '3') {
    $DBversion = '';
    include CONFIGREP.'dbversion.php';
    $version = $DBversion;
    if (is_file(CHEMIN.DATAREP.'dbversion.php')) include CHEMIN.DATAREP.'dbversion.php';
    DisplayHeader();
	DisplayTitre($clean[16], $clean[24]);
    if ($version == $DBversion) {
	   echo '
<form name="instal3" action="install.php?lng='.$lng.'" method="post">
  <div style="text-align:center;">'.SubmitButton($clean[25]).'&nbsp;&nbsp;
  </div>
</form>';
    } else {
	   echo '
<form name="instal3" action="migrate46.php?lng='.$lng.'" method="post">
  <div style="text-align:center;">'.SubmitButton($clean[25]).'&nbsp;&nbsp;
    <button type="reset" style="cursor:pointer;" title="'.$clean[0].'" onclick="window.location=\'install.php?lng='.$lng.'&form=1\';">'.$clean[0].'</button>
  </div>
</form>';
    }
}

DisplayFooter();
?>