<?php
/*
    CREATIVE COMMONS - Attribution-No Derivative Works 3.0 Germany:
    - You may not alter, transform, or build upon this work.
    - Dieses Werk darf nicht bearbeitet oder in anderer Weise verändert werden.
*/
  include ("../includes/error_reporting.php");  
  header("content-type: text/html; charset=utf-8");
  include ("../gigkalender.ini.php");  
  include ("../functions/standard.php");
  $timer = startTime();
  include ('install_language_selector.php');
  include ("iniUser.php");
  include ("iniSetup.php");
  include ("iniGigs.php");
  include ("iniGuestbook.php");
  include ("iniNews.php");
  include_once ("../news/functions.php");
  include ("iniMenu.php");
  include ('../includes/header.php');
  echo '</head>';
  echo '<body>
    <div id="Install">
      <div class="Head">
        <div class="Title"><img src="../images/gigkalender-logo.gif" alt="GigKalender-Logo" /></div>
      </div>
      <p class="Headline">'.$L_Headline39.'</p>';
      clearCache ();
      $MySQLVersion = mysqli_get_server_info($db);
      $MySQLVersionShort = str_replace('.', '', substr($MySQLVersion, 0, 3));
      if ( $MySQLVersionShort>=55 )
      {
        $installationOK = true;
        if ( !isDatabasePresent() )
        {
          $SQLQuery = 'CREATE DATABASE `'.$db_name.'`';
          $Result = mysqli_query($db, $SQLQuery);
          if (!$Result)
          {
            echo '<span class="ErrorMessage">'.$L_ERROR_Database_not_found.' ('.$db_name.')(39)</span><br /><br />';
            die('<span class="ErrorMessage">'.$L_ERROR.': '. mysqli_error($db).'(40)</span><br />');
            $installationOK = false;
          }
          else
          {
            echo $L_Database_added.'<br />';
            include ('iniTables.php');
          }
        }
        else
        {
          echo $L_Found_Database.'<br />';
          include ('iniTables.php');
        }
      }
      else
      {
        echo '<span class="ErrorMessage">'.$L_ERROR_Wrong_MySQL_Version.' ('.$MySQLVersion.')</span><br />';
        $installationOK = false;
      }
      //Ergebnis der Installation ausgeben
      if ($installationOK)
      {
        echo '<br /><br /><b>'.$L_Installation_successful.'</b><br />
              <br />
              <form method="post" action="index3.php" accept-charset="UTF-8">
                <fieldset>
                  <input type="submit" value="'.$L_Button26.'" class="button" />
                </fieldset>
              </form>';
      }
      else { echo '<br /><span class="ErrorMessage">'.$L_ERROR_Installation_failed.' </span><br />'; }
      include ('../includes/footer.php');
    
    echo '</div>
  </body>
</html>';  ?>