summaryrefslogtreecommitdiff
path: root/install_database.php
blob: ead28920c24e5c04ff79061320f9cee3cfc9cc06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
 * @version $Header: /cvsroot/bitweaver/_bit_install/install_database.php,v 1.19 2007/12/12 01:05:56 joasch Exp $
 * @package install
 * @subpackage functions
 */

/**
 * assign next step in installation process
 */
$gBitSmarty->assign( 'next_step',$step );

require_once( "get_databases_inc.php" );

// next block checks if there is a config_inc.php and if we can connect through this.
if( isset( $_REQUEST['submit_db_info'] )) {
	if( $gBitDbType == 'sybase' ) {
		// avoid database change messages
		ini_set( 'sybct.min_server_severity', '11' );
	}

	$gBitDb = &ADONewConnection( $gBitDbType );

	if( $gBitDb->Connect( $gBitDbHost, $gBitDbUser, $gBitDbPassword, $gBitDbName )) {
		// display success page when done
		$app = '_done';
		$gBitSmarty->assign( 'next_step',$step + 1 );
		// this is where we tell the installer that this is the first install
		// if so, clear out session variables
		// if we are coming here from the upgrade process, don't change any value
		if( isset( $_SESSION['first_install'] ) && $_SESSION['first_install'] == TRUE && isset( $_SESSION['upgrade'] ) && $_SESSION['upgrade'] == TRUE ) {
			// nothing to do
		} elseif( !$gBitUser->isAdmin() ) {
			$_SESSION = NULL;
			$_SESSION['first_install'] = TRUE;
		} else {
			$_SESSION['first_install'] = FALSE;
		}

		if( $_SESSION['first_install'] == TRUE ) {
			// For MySql only, on first install check if server support
			// InnoDB and set a smarty var for template to offer using
			// the transaction safe storage engine
			if( preg_match( '/mysql/', $gBitDbType )) {
				$_SESSION['use_innodb'] = FALSE;
				$rs = $gBitDb->Execute('SHOW ENGINES');
				while ( !$rs->EOF) {
					$row = $rs->GetRowAssoc(false);
					switch( isset( $row['Engine'] ) ? strtoupper( $row['Engine'] ) : strtoupper( $row['Type'] )) {
						case 'INNODB':
						case 'INNOBASE':
							if( strtoupper( $row['Support'] ) == 'YES' || strtoupper( $row['Support'] ) == 'DEFAULT' ) {
								$gBitSmarty->assign( 'has_innodb_support',strtoupper( $row['Support'] ) );
								break 2;
							}
					}

					$rs->MoveNext();
				}
				$rs->Close();
			}
		}
	} else {
		$gBitSmarty->assign( 'error', TRUE );
		$gBitSmarty->assign( 'errorMsg', $gBitDb->_errorMsg );
		$error = TRUE;
	}
}
?>