<?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 ("iniVenues.php");
  include ("iniArtists.php");
  include ("iniOrganizers.php");
  include ("iniGuestbook.php");
  include ("iniNews.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.png" alt="GigKalender-Logo" /></div>
      </div>';
      clearCache ();
      $MySQLVersion = mysql_get_server_info();
      $MySQLVersionShort = str_replace('.', '', substr($MySQLVersion, 0, 3));
      if ( $MySQLVersionShort>=41 )
      {
        $installationOK = true;
        if ( !getDatabasePresent() )
        {
          $sql = 'CREATE DATABASE `'.$DB_NAME.'`';
          $result = mysql_query($sql);
          if (!$result)
          {
            echo '<span class="ERROR">'.$L_ERROR_Database_not_found.' ('.$DB_NAME.')</span><br /><br />';
            die('<span class="ERROR">'.$L_ERROR.': '. mysql_error().'</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="ERROR">'.$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="ERROR">'.$L_ERROR_Installation_failed.' </span><br />'; }
      include ('../includes/footer.php');
    
    echo '</div>
  </body>
</html>';  ?>