<?php
/*
  $Id: install_3.php,v 1.1.1.1 2005/06/30 05:04:24 ryu Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2002 osCommerce

  Released under the GNU General Public License
  
  modified for Koshoten.net2
  http://www.koshoten.net/
*/
?>
<p><span class="pageHeading">Koshoten.net2インストール</span><br><font color="#9a9a9a">powered by osCommerce</font></p>

<p class="pageTitle">新規インストール</p>

<p><b>Step 1: データベース・インポート</b></p>

<?php
  if (osc_in_array('database', $_POST['install'])) {
    $db = array();
    $db['DB_SERVER'] = trim(stripslashes($_POST['DB_SERVER']));
    $db['DB_SERVER_USERNAME'] = trim(stripslashes($_POST['DB_SERVER_USERNAME']));
    $db['DB_SERVER_PASSWORD'] = trim(stripslashes($_POST['DB_SERVER_PASSWORD']));
    $db['DB_DATABASE'] = trim(stripslashes($_POST['DB_DATABASE']));

    osc_db_connect($db['DB_SERVER'], $db['DB_SERVER_USERNAME'], $db['DB_SERVER_PASSWORD']);

    $db_error = false;
    $sql_file = $_POST['DIR_FS_DOCUMENT_ROOT'] . $_POST['DIR_FS_CATALOG'] . 'install/oscommerce.sql';
//    $script_filename = (($SCRIPT_FILENAME) ? $SCRIPT_FILENAME : $_SERVER['SCRIPT_FILENAME']);
//    $script_directory = dirname($script_filename);
//    $sql_file = $script_directory . '/oscommerce.sql';

    osc_set_time_limit(0);
    osc_db_install($db['DB_DATABASE'], $sql_file);

    if ($db_error) {
?>

<p>次のエラーが発生しました:</p>

<p class="boxme"><?php echo $db_error; ?></p>

<form name="install" action="install.php?step=3" method="post">

<?php
      reset($_POST);
      while (list($key, $value) = each($_POST)) {
        if ($key != 'x' && $key != 'y') {
          if (is_array($value)) {
            for ($i=0; $i<sizeof($value); $i++) {
              echo osc_draw_hidden_field($key . '[]', $value[$i]);
            }
          } else {
            echo osc_draw_hidden_field($key, $value);
          }
        }
      }
?>

<table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center"><a href="index.php"><img src="images/button_cancel.gif" border="0" alt="Cancel"></a></td>
    <td align="キャンセル"><input type="image" src="images/button_retry.gif" border="0" alt="再試行"></td>
  </tr>
</table>

</form>

<?php
    } else {
?>

<p>データベースのインポートに成功しました。</p>

<form name="install" action="install.php?step=4" method="post">

<?php
      reset($_POST);
      while (list($key, $value) = each($_POST)) {
        if ($key != 'x' && $key != 'y') {
          if (is_array($value)) {
            for ($i=0; $i<sizeof($value); $i++) {
              echo osc_draw_hidden_field($key . '[]', $value[$i]);
            }
          } else {
            echo osc_draw_hidden_field($key, $value);
          }
        }
      }
?>

<table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
<?php
      if (osc_in_array('configure', $_POST['install'])) {
?>
    <td align="center"><input type="image" src="images/button_continue.gif" border="0" alt="次へ"></td>
<?php
      } else {
?>
    <td align="center"><a href="index.php"><img src="images/button_continue.gif" border="0" alt="次へ"></a></td>
<?php
      }
?>
  </tr>
</table>

</form>

<?php
    }
  }
?>