r1511: Don't use PHP short tags because not everybody has them enabled.
[bugdar.git] / install / install.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Blue Static
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 define('STOP_MARK', 7);
23 define('ACTIVE_SITE', 'install.php');
24
25 require_once('./global.php');
26
27 page_start();
28
29 // ###################################################################
30
31 if ($bugsys->in['mark'] == 0)
32 {
33 ?>
34 <h1>Welcome to Bugdar</h1>
35
36 <p>This installer will take you through the procedure of setting up your Bugdar installation. If you are seeing this message, that means that your configuration file was read properly and that your database is accessible.</p>
37
38 <p>The following steps will initialize your database, place the default settings and data in your database, and finally ask you to enter in some settings to allow you to access the system when the installer finishes.</p>
39
40 <p>To begin the installation process, please click the button below.</p>
41 <?php
42 }
43
44 // ###################################################################
45
46 if ($bugsys->in['mark'] == 1)
47 {
48 ?>
49 <h1>Initializing Database</h1>
50
51 <p>This step will load the tables into your database so the rest of the installation can proceed forward.</p>
52
53 <?php
54
55 require_once('./install/schema.php');
56
57 foreach ($schema AS $table => $query)
58 {
59 $db->query($query);
60 echo 'Creating table ' . $table . '<br />' . "\n";
61 }
62 }
63
64 // ###################################################################
65
66 if ($bugsys->in['mark'] == 2)
67 {
68 ?>
69 <h1>Loading Default Data</h1>
70
71 <p>Default table data for usergroups, statuses, priorities, and other various options are being loaded. This will allow you to use Bugdar with minimal setup.</p>
72
73 <?php
74
75 require_once('./install/default_data.php');
76
77 foreach ($data AS $table => $records)
78 {
79 foreach ($records AS $record)
80 {
81 $fields = $values = array();
82 foreach ($record AS $field => $value)
83 {
84 $fields[] = $field;
85 $values[] = addslashes($value);
86 }
87
88 $db->query("INSERT INTO " . TABLE_PREFIX . "$table (" . implode(',', $fields) . ") VALUES ('" . implode("', '", $values) . "')");
89 }
90
91 echo 'Populating table ' . $table . '<br />' . "\n";
92 }
93
94 $db->query("INSERT INTO " . TABLE_PREFIX . "language (title, langcode, charset, direction, userselect) VALUES ('English (US)', 'en_US', 'utf-8', 'ltr', 1)");
95 echo 'Inserting default language<br />' . "\n";
96 }
97
98 // ###################################################################
99
100 if ($bugsys->in['mark'] == 3)
101 {
102 ?>
103 <h1>Loading Settings</h1>
104
105 <p>Default settings are being loaded into the system.</p>
106
107 <?php
108
109 require_once('./install/settings.php');
110
111 foreach ($settings AS $key => $value)
112 {
113 $db->query("INSERT INTO " . TABLE_PREFIX . "setting (varname, value) VALUES ('" . $key . "', '" . $db->escape_string($value) . "')");
114 }
115
116 echo 'Settings loaded...';
117 }
118
119 // ###################################################################
120
121 if ($bugsys->in['mark'] == 4)
122 {
123 $value = 'http' . ($_SERVER['HTTPS'] == 'on' ? 's' : '') . '://' . $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] != '80' ? ':' . $_SERVER['SERVER_PORT'] : '') . str_replace('/install/install.php', '', $_SERVER['SCRIPT_NAME']);
124 ?>
125 <h1>General Settings</h1>
126
127 <p>These three settings are fundamental in setting up your bug tracking system. Please fill them in to proceed with the installation.</p>
128
129 <form name="settings-do" action="install.php" method="post">
130 <input type="hidden" name="mark" value="5" />
131
132 <div><strong>Tracker Name (the name of the entire tracking system, for instance "Acme Inc. Bug Tracker"):</strong> <input type="text" name="trackertitle" size="50" /></div>
133 <div><strong>Tracker URL (the root URL of your tracker, we have tried to guess this for you; <em>it does not end with a trailing slash!</em>):</strong> <input type="text" name="trackerurl" size="50" value="<?php echo $value; ?>" /></div>
134 <div><strong>Webmaster Email:</strong> <input type="text" name="webmasteremail" size="50" /></div>
135
136 <input type="submit" name="submit" value="Next Step" />
137
138 </form>
139
140 <?php
141
142 page_end(false);
143 }
144
145 // ###################################################################
146
147 if ($bugsys->in['mark'] == 5)
148 {
149 ?>
150 <h1>New Administrator</h1>
151
152 <p>Your settings have been saved. Now you must create a new administrative account for yourself. This account will have complete control over the system.</p>
153
154 <form name="user-do" action="install.php" method="post">
155 <input type="hidden" name="mark" value="6" />
156
157 <div><strong>Display Name:</strong> <input type="text" name="displayname" size="50" /></div>
158 <div><strong>Email Address:</strong> <input type="text" name="email" size="50" /></div>
159 <div><strong>Password:</strong> <input type="password" name="password" size="50" /></div>
160
161 <input type="submit" name="submit" value="Next Step" />
162 </form>
163
164 <?php
165
166 $db->query("UPDATE " . TABLE_PREFIX . "setting SET value = '" . $bugsys->input_escape('trackertitle') . "' WHERE varname = 'trackertitle'");
167 $db->query("UPDATE " . TABLE_PREFIX . "setting SET value = '" . $bugsys->input_escape('trackerurl') . "' WHERE varname = 'trackerurl'");
168 $db->query("UPDATE " . TABLE_PREFIX . "setting SET value = '" . $bugsys->input_escape('webmasteremail') . "' WHERE varname = 'webmasteremail'");
169
170 page_end(false);
171 }
172
173 // ###################################################################
174
175 if ($bugsys->in['mark'] == 6)
176 {
177 ?>
178 <h1>User Added</h1>
179
180 <p>Your new user has been added.</p>
181 <?php
182
183 require_once('./includes/api_user.php');
184
185 $user = new UserAPI($bugsys);
186 $user->set('email', $bugsys->in['email']);
187 $user->set('displayname', $bugsys->in['displayname']);
188 $user->set('password', $bugsys->in['password']);
189 $user->set('showcolors', 1);
190 $user->set('usergroupid', 6, true, false); // don't verify because we haven't cached usergroups yet
191 $user->insert();
192 }
193
194 // ###################################################################
195
196 if ($bugsys->in['mark'] == 7)
197 {
198 ?>
199 <h1>Cache Data</h1>
200
201 <p>In order to make Bugdar as efficient as possible, the system caches the portions of data it can. This reduces the load of your server without compromising usability. Currently the caches are being built.</p>
202 <?php
203
204 require_once('./includes/permissions.php');
205
206 build_settings();
207 echo "Cached settings<br />\n";
208
209 build_usergroups();
210 echo "Cached usergroups<br />\n";
211
212 build_statuses();
213 echo "Cached statuses<br />\n";
214
215 build_priorities();
216 echo "Cached priorities<br />\n";
217
218 build_severities();
219 echo "Cached severities<br />\n";
220
221 build_assignedto();
222 echo "Cached assignable users/developers<br />\n";
223
224 build_resolutions();
225 echo "Cached resolutions<br />\n";
226
227 build_products();
228 echo "Cached products<br />\n";
229
230 build_versions();
231 echo "Cached versions<br />\n";
232
233 build_languages();
234 echo "Cached languages<br />\n";
235
236 build_user_help();
237 echo "Cached user help documentation<br />\n";
238 }
239
240 // ###################################################################
241
242 page_end();
243
244 /*=====================================================================*\
245 || ###################################################################
246 || # $HeadURL$
247 || # $Id$
248 || ###################################################################
249 \*=====================================================================*/
250 ?>