-
Notifications
You must be signed in to change notification settings - Fork 2
/
install.php
184 lines (165 loc) · 6.45 KB
/
install.php
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?php
/**
* @version $Header$
* @package install
* @subpackage functions
*/
// hide errors when trying to connect to the database. very unsettling when you
// have pages of errors to scroll through
if( !empty( $_REQUEST['submit_db_info'] ) && !empty( $_REQUEST['step'] ) && $_REQUEST['step'] == 3 ) {
ini_set( 'display_errors', '0' );
}
// here we force the use of adodb during installation
$gForceAdodb = TRUE;
// If we are jumping to start over reset the session
if( !empty( $_REQUEST['step'] ) && $_REQUEST['step'] == 0 ) {
unset( $_REQUEST['BWSESSION'] );
}
// Early check of memory limit just to be sure we can run.
// Set the number '15' to a lower value if you know that the install process can handle it.
if( get_cfg_var( 'memory_limit' ) !== FALSE && preg_replace( '/M/i','',get_cfg_var( 'memory_limit' )) < 15 ) {
$dir = dirname( $_SERVER['SCRIPT_NAME'] );
// We don't use smarty to avoid using any memory since we already know there is a problem.
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Install Bitweaver - Not enough memory!</title>
<style type="text/css">
<!-- @import url( '.$dir.'/style/install.css ); -->
</style>
</head>
<body>
<div id="container">
<div id="header"></div>
<div id="wrapper">
<div id="content">
<div class="bittop"><h1>Bitweaver Installer</h1></div>
<h1>Not enough memory!</h1>
<form action="'.$dir.'/install.php">
<fieldset>
<legend>Unable to run installer</legend>
<p class="alert alert-danger">The memory limit of <strong>"'.get_cfg_var( 'memory_limit' ).'"</strong> is not high enough to run the bitweaver installer. Please up the memory limit in you php.ini to at least 16M to install and run bitweaver.</p>
</fieldset>
<div class="row submit">
<input type="submit" value="Reload" size="20"/>
</div>
</form>
</div>
</div>
</div>
</body>
</html>';
die;
}
/**
* required setup
*/
require_once( 'includes/install_inc.php' );
if( $gBitInstaller->isInstalled() && is_object( $gBitUser ) ) {
//$gBitUser->verifyAdmin();
} else {
require_once( THEMES_PKG_CLASS_PATH.'BitThemes.php' );
BitThemes::loadSingleton();
$gBitThemes->setStyle( 'basic' );
require_once( LANGUAGES_PKG_CLASS_PATH.'BitLanguage.php' );
BitLanguage::loadSingleton();
}
// this variable will be appended to the template file called - useful for displaying messages after data input
$app = '';
// work out where in the installation process we are
if( !isset( $_REQUEST['step'] )) {
$_REQUEST['step'] = 0;
}
$step = $_REQUEST['step'];
if( !empty( $_REQUEST['reload'] )) {
header( "Location: ".$_SERVER['HTTP_REFERER'] );
}
// for pages that should only be shown during a first install
if( ( empty( $gBitDbType ) || !$gBitUser->isAdmin() ) || ( $_SESSION['first_install'] ) ) {
$onlyDuringFirstInstall = TRUE;
$_SESSION['first_install'] = TRUE;
} else {
$onlyDuringFirstInstall = FALSE;
}
// For MySql only, and if server supports InnoDB Engine
// we catch here if it was selected as storage type and
// set a session var for use in install_packages.php
if( isset( $_REQUEST['use_innodb'] ) ) {
$_SESSION['use_innodb'] = TRUE;
}
// updating $install_file name
$i = 0;
$install_file[$i]['file'] = 'welcome';
$install_file[$i++]['name'] = 'Welcome';
$install_file[$i]['file'] = 'checks';
$install_file[$i++]['name'] = 'Server';
// Upgrading of a database can only occur during a first install
if( $onlyDuringFirstInstall ) {
$install_file[$i]['file'] = 'options';
$install_file[$i++]['name'] = 'Options';
}
// make it possible to reset the config/kernel/config_inc.php file if it's already filled with data
if( $onlyDuringFirstInstall ) {
$install_file[$i]['file'] = 'database';
$install_file[$i++]['name'] = 'Database';
} else {
$install_file[$i]['file'] = 'database_reset';
$install_file[$i++]['name'] = 'Database';
}
// if the admin is already set up and we are not installing for the first time, we skip admin creation page
if( $onlyDuringFirstInstall ) {
$install_file[$i]['file'] = 'admin_inc';
$install_file[$i++]['name'] = 'Admin';
}
$install_file[$i]['file'] = 'packages';
$install_file[$i++]['name'] = 'Packages';
if( !$onlyDuringFirstInstall ) {
$install_file[$i]['file'] = 'upgrade';
$install_file[$i++]['name'] = 'Upgrade';
}
$install_file[$i]['file'] = 'cleanup';
$install_file[$i++]['name'] = 'Cleanup';
// these settings should only be present when we are installing for the first time
if( $onlyDuringFirstInstall ) {
$install_file[$i]['file'] = 'bit_settings';
$install_file[$i++]['name'] = 'Settings';
// only show db population page when we haven't just done an upgrade
if( !isset( $_SESSION['upgrade'] ) ) {
$install_file[$i]['file'] = 'datapump';
$install_file[$i++]['name'] = 'Content';
}
} else {
$install_file[$i]['file'] = 'version';
$install_file[$i++]['name'] = 'Update';
}
$install_file[$i]['file'] = 'final';
$install_file[$i]['name'] = 'Done';
//don't increment last $i since it's used later on
// Needed for version number
$gBitSmarty->assignByRef( 'gBitSystem', $gBitSystem );
if( !empty( $_POST['signin'] ) ) {
$gBitUser->login( $_POST['user'], $_POST['pass'] );
if( !$gBitUser->isRegistered() ) {
$gBitSmarty->assign( 'error', current( $gBitUser->mErrors ) );
}
}
// if we have to log in, call login template and die
if( !empty( $gBitDbType ) && !empty( $gBitInstaller->mPackages['users']['installed'] ) && !$gBitUser->isAdmin() && !$_SESSION['first_install'] ) {
$install_file = 'login';
$gBitSmarty->assign( 'install_file', INSTALL_PKG_PATH."templates/install_".$install_file.".tpl" );
$gBitSmarty->display( INSTALL_PKG_PATH.'templates/install.tpl' );
die;
}
// if the page has been renamed to anything else than 'install.php' we send it to the last installation stage
if( !strpos( $_SERVER['SCRIPT_NAME'],'install/install.php' ) ) {
$step = $i;
$gBitSmarty->assign( 'renamed',basename( $_SERVER['SCRIPT_NAME'] ) );
}
// finally we are ready to include the actual php file
include_once( INSTALL_PKG_INCLUDE_PATH.'install_'.$install_file[$step]['file'].'.php' );
$install_file = set_menu( $install_file, $step );
$gBitSmarty->assign_by_ref( 'gBitInstaller', $gBitInstaller );
$gBitSmarty->assign( 'install_file', INSTALL_PKG_PATH."templates/install_".$install_file[$step]['file'].$app.".tpl" );
$gBitInstaller->in_display( $install_file[$step]['name'], INSTALL_PKG_PATH.'templates/install.tpl' );
?>