Location: PHPKode > projects > QuickTicket > quickticket/quickticket/install/qti_setup_1.php
<?php

// QuickTicket 1.9.0.3 build:20081001

session_start();

if ( isset($_GET['language']) ) $_SESSION['qti_setup_lang']=$_GET['language'];
if ( !isset($_SESSION['qti_setup_lang']) ) $_SESSION['qti_setup_lang']='en';
if ( !file_exists('qti_lang_'.$_SESSION['qti_setup_lang'].'.php') ) $_SESSION['qti_setup_lang']='en';

include('qti_lang_'.$_SESSION['qti_setup_lang'].'.php');
include('../bin/config.php');

$strAppl = 'QuickTicket 1.9';
$strPrevUrl = 'qti_setup.php';
$strNextUrl = 'qti_setup_2.php';
$strPrevLabel= $L['Back'];
$strNextLabel= $L['Next'];
$strError = '';

// --------
// HTML START
// --------

include('qti_setup_hd.php');

echo '
<table cellspacing="0">
<tr valign="top">
<td width="475" style="padding:0px">';

// --------
// SUBMITTED
// --------

if ( isset($_POST['ok']) )
{
  include('../bin/qt_lib_db.php');

  $qti_dbsystem = strip_tags(trim($_POST['qti_dbsystem']));
  $qti_host     = strip_tags(trim($_POST['qti_host']));
  $qti_database = strip_tags(trim($_POST['qti_database']));
  $qti_prefix   = strip_tags(trim($_POST['qti_prefix']));
  $qti_user     = strip_tags(trim($_POST['qti_user']));
  $qti_pwd      = strip_tags(trim($_POST['qti_pwd']));
  $qti_port     = strip_tags(trim($_POST['qti_port']));
  $qti_dsn      = strip_tags(trim($_POST['qti_dsn']));
  $str = strip_tags(trim($_POST['qti_dbo_login']));
  if ( $str!='') $_SESSION['qti_dbologin'] = $str;
  $str = strip_tags(trim($_POST['qti_dbo_pswrd']));
  if ( $str!='') $_SESSION['qti_dbopwd'] = $str;

  // Test Connection

  if ( isset($_SESSION['qti_dbologin']) )
  {
    $oDB = new cDB($qti_dbsystem,$qti_host,$qti_database,$_SESSION['qti_dbologin'],$_SESSION['qti_dbopwd'],$qti_port,$qti_dsn);
  }
  else
  {
    $oDB = new cDB($qti_dbsystem,$qti_host,$qti_database,$qti_user,$qti_pwd,$qti_port,$qti_dsn);
  }

  if ( empty($oDB->error) )
  {
    echo '<div class="div_setup_ok">',$L['S_connect'],'</div>';
  }
  else
  {
    echo '<div class="div_setup_err">',sprintf ($L['E_connect'],$qti_database,$qti_host),'</div>';
  }

  // Save Connection

  $strFilename = '../bin/config.php';
  $content = '<?php
  $qti_dbsystem = "'.$qti_dbsystem.'";
  $qti_host = "'.$qti_host.'";
  $qti_database = "'.$qti_database.'";
  $qti_prefix = "'.$qti_prefix.'";
  $qti_user = "'.$qti_user.'";
  $qti_pwd = "'.$qti_pwd.'";
  $qti_port = "'.$qti_port.'";
  $qti_dsn = "'.$qti_dsn.'";
  $qti_install = "'.date('Y-m-d').'";
  ?>';

  if (!is_writable($strFilename)) $strError="Impossible to write into the file [$strFilename].";
  if ( empty($strError) )
  {
  if (!$handle = fopen($strFilename, 'w')) $strError="Impossible to open the file [$strFilename].";
  }
  if ( empty($strError) )
  {
  if ( fwrite($handle, $content)===FALSE ) $strError="Impossible to write into the file [$strFilename].";
  fclose($handle);
  }

  if ( empty($strError) )
  {
    echo '<div class="div_setup_ok">',$L['S_save'],'</div>';
  }
  else
  {
    echo '<div class="div_setup_err">',$strError,$L['E_save'],'</div>';
  }
}

echo '<form method="post" name="install" action="qti_setup_1.php">
<table cellspacing="0" cellpadding="5">
<tr>
<td colspan="2"><h2>',$L['Connection_db'],'</h2><br/></td>
</tr>
';
echo '<tr>
<td>',$L['Database_type'],'</td>
<td><select name="qti_dbsystem">
<option value="mysql4"',($qti_dbsystem=='mysql4' ? ' selected="selected"' : ''),'>MySQL 4</option>
<option value="mysql"',($qti_dbsystem=='mysql' ? ' selected="selected"' : ''),'>MySQL 5 or next</option>
<option value="mssql"',($qti_dbsystem=='mssql' ? ' selected="selected"' : ''),'>Microsoft SQL server</option>
<option value="pg"'.($qti_dbsystem=='pg' ? 'selected="selected"' : ''),'>PostgreSQL</option>
<option value="ibase"'.($qti_dbsystem=='ibase' ? 'selected="selected"' : ''),'>Firebird</option>
<option value="sqlite"'.($qti_dbsystem=='sqlite' ? 'selected="selected"' : ''),'>SQLite</option>
<option value="db2"',($qti_dbsystem=='db2' ? ' selected="selected"' : ''),'>IBM DB2</option>
<option value="ifx"',($qti_dbsystem=='ifx' ? ' selected="selected"' : ''),'>Informix</option>
<option value="oci"',($qti_dbsystem=='oci' ? ' selected="selected"' : ''),'>Oracle</option>
<option value="access"'.($qti_dbsystem=='access' ? ' selected="selected"' : ''),'>MS-Access via ODBC</option>
</select></td>
</tr>
';
echo '<tr>
<td>',$L['Database_host'],'</td>
<td>
<input type="text" name="qti_host" value="',$qti_host,'" size="15" maxlength="100"/>
<input type="text" name="qti_port" value="',$qti_port,'" size="5" maxlength="20"/>
<input type="text" name="qti_dsn" value="',$qti_dsn,'" size="8" maxlength="100"/>
</td>
</tr>
<tr>
<td>',$L['Database_name'],'</td>
<td><input type="text" name="qti_database" value="',$qti_database,'" size="15" maxlength="100"/></td>
</tr>
<tr>
<td>',$L['Table_prefix'],'</td>
<td><input type="text" name="qti_prefix" value="',$qti_prefix,'" size="15" maxlength="100"/></td>
</tr>
<tr>
<td>',$L['Database_user'],'</td>
<td>
<input name="qti_user" value="',$qti_user,'" size="15" maxlength="100"/>
<input type="password" name="qti_pwd" value="',$qti_pwd,'" size="15" maxlength="100"/>
</td>
</tr>
<tr>
<td colspan="2" style="background-color:#CCCCCC"><span class="small">',$L['Htablecreator'],'</span></td>
</tr>
<tr>
<td style="background-color:#CCCCCC">Table creator (login/password)</td>
<td style="background-color:#CCCCCC">
<input type="text" name="qti_dbo_login" value="',(isset($_SESSION['qti_dbologin']) ? $_SESSION['qti_dbologin'] : ''),'" size="15" maxlength="100"/>
<input type="password" name="qti_dbo_pswrd" value="',(isset($_SESSION['qti_dbopwd']) ? $_SESSION['qti_dbopwd'] : ''),'" size="15" maxlength="100"/>
</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2" style="text-align:center"><input type="submit" name="ok" value="',$L['Save'],'"/></td>
</tr>

</table>
</form>
<span class="small">',$L['Upgrade'],'</span>';

echo '
</td>
<td class="td_hidden"><div class="div_setup_help">',$L['Help_1'],'</div></td>
</tr>
</table>
';

// --------
// HTML END
// --------

include('qti_setup_ft.php');

?>
Return current item: QuickTicket