Location: PHPKode > projects > QuickTalk Forum > quicktalk/install/qtf_setup_1.php
<?php

// QuickTalk 2.5 build:20100924

session_start();

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

include('qtf_lang_'.$_SESSION['qtf_setup_lang'].'.php');
include('../bin/config.php');

$strAppl = 'QuickTalk 2.5';
$strPrevUrl = 'qtf_setup.php';
$strNextUrl = 'qtf_setup_2.php';
$strPrevLabel= $L['Back'];
$strNextLabel= $L['Next'];
$strError = '';

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

include('qtf_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');

  $qtf_dbsystem = strip_tags(trim($_POST['qtf_dbsystem']));
  $qtf_host     = strip_tags(trim($_POST['qtf_host']));
  $qtf_database = strip_tags(trim($_POST['qtf_database']));
  if ( $qtf_dbsystem=='sqlite' && substr($qtf_database,-3,3)!='.db' ) $qtf_database .= '.db';
  $qtf_prefix   = strip_tags(trim($_POST['qtf_prefix']));
  $qtf_user     = strip_tags(trim($_POST['qtf_user']));
  $qtf_pwd      = strip_tags(trim($_POST['qtf_pwd']));
  $qtf_port     = strip_tags(trim($_POST['qtf_port']));
  $qtf_dsn      = strip_tags(trim($_POST['qtf_dsn']));
  $str = strip_tags(trim($_POST['qtf_dbo_login']));
  if ( $str!='') $_SESSION['qtf_dbologin'] = $str;
  $str = strip_tags(trim($_POST['qtf_dbo_pswrd']));
  if ( $str!='') $_SESSION['qtf_dbopwd'] = $str;

  // Test Connection

  if ( isset($_SESSION['qtf_dbologin']) )
  {
    $oDB = new cDB($qtf_dbsystem,$qtf_host,$qtf_database,$_SESSION['qtf_dbologin'],$_SESSION['qtf_dbopwd'],$qtf_port,$qtf_dsn);
  }
  else
  {
    $oDB = new cDB($qtf_dbsystem,$qtf_host,$qtf_database,$qtf_user,$qtf_pwd,$qtf_port,$qtf_dsn);
  }

  if ( empty($oDB->error) )
  {
    echo '<div class="setup_ok">',$L['S_connect'],'</div>';    
  }
  else
  {
    echo '<div class="setup_err">',sprintf ($L['E_connect'],$qtf_database,$qtf_host),'</div>';
  }
 
  // Save Connection

  $strFilename = '../bin/config.php';
  $content = '<?php  
  $qtf_dbsystem = "'.$qtf_dbsystem.'";
  $qtf_host = "'.$qtf_host.'";
  $qtf_database = "'.$qtf_database.'";
  $qtf_prefix = "'.$qtf_prefix.'";
  $qtf_user = "'.$qtf_user.'";
  $qtf_pwd = "'.$qtf_pwd.'";
  $qtf_port = "'.$qtf_port.'";
  $qtf_dsn = "'.$qtf_dsn.'";
  $qtf_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);
  }
  
  // End message
  if ( empty($strError) )
  {
    echo '<div class="setup_ok">',$L['S_save'],'</div>';
  }
  else
  {
    echo '<div class="setup_err">',$strError,$L['E_save'],'</div>';
  }
}

// --------
// FORM
// --------

echo '<form method="post" name="install" action="qtf_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="qtf_dbsystem">
<option value="mysql4"',($qtf_dbsystem=='mysql4' ? ' selected="selected"' : ''),'>MySQL 4</option>
<option value="mysql"',($qtf_dbsystem=='mysql' ? ' selected="selected"' : ''),'>MySQL 5 or next</option>
<option value="mssql"',($qtf_dbsystem=='mssql' ? ' selected="selected"' : ''),'>Microsoft SQL server</option>
<option value="pg"'.($qtf_dbsystem=='pg' ? 'selected="selected"' : ''),'>PostgreSQL</option>
<option value="ibase"'.($qtf_dbsystem=='ibase' ? 'selected="selected"' : ''),'>FireBird</option>
<option value="sqlite"'.($qtf_dbsystem=='sqlite' ? 'selected="selected"' : ''),'>SQLite</option>
<option value="db2"',($qtf_dbsystem=='db2' ? ' selected="selected"' : ''),'>IBM DB2</option>
<option value="oci"',($qtf_dbsystem=='oci' ? ' selected="selected"' : ''),'>Oracle</option>
</select></td>
</tr>
';
echo '<tr>
<td>',$L['Database_host'],'</td>
<td>
<input type="text" name="qtf_host" value="',$qtf_host,'" size="15" maxlength="100"/>
<input type="text" name="qtf_port" value="',$qtf_port,'" size="5" maxlength="20"/>
<input type="text" name="qtf_dsn" value="',$qtf_dsn,'" size="8" maxlength="100"/>
</td>
</tr>
<tr>
<td>',$L['Database_name'],'</td>
<td><input type="text" name="qtf_database" value="',$qtf_database,'" size="15" maxlength="100"/></td>
</tr>
<tr>
<td>',$L['Table_prefix'],'</td>
<td><input type="text" name="qtf_prefix" value="',$qtf_prefix,'" size="15" maxlength="100"/></td>
</tr>
<tr>
<td>',$L['Database_user'],'</td>
<td>
<input name="qtf_user" value="',$qtf_user,'" size="15" maxlength="100"/>
<input type="password" name="qtf_pwd" value="',$qtf_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="qtf_dbo_login" value="',(isset($_SESSION['qtf_dbologin']) ? $_SESSION['qtf_dbologin'] : ''),'" size="15" maxlength="100"/>
<input type="password" name="qtf_dbo_pswrd" value="',(isset($_SESSION['qtf_dbopwd']) ? $_SESSION['qtf_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'],'</a></span>';

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

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

include('qtf_setup_ft.php');

?>
Return current item: QuickTalk Forum