r705: We need to build the localizations table... so we now do :)
[bugdar.git] / install / install.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # Bugdar [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
12
13 define('STOP_MARK', 8);
14 define('ACTIVE_SITE', 'install.php');
15
16 require_once('./global.php');
17
18 page_start();
19
20 // ###################################################################
21
22 if ($bugsys->in['mark'] == 0)
23 {
24 ?>
25 <h1>Welcome to Bugdar</h1>
26
27 <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>
28
29 <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>
30
31 <p>To begin the installation process, please click the button below.</p>
32 <?php
33 }
34
35 // ###################################################################
36
37 if ($bugsys->in['mark'] == 1)
38 {
39 ?>
40 <h1>Initializing Database</h1>
41
42 <p>This step will load the tables into your database so the rest of the installation can proceed forward.</p>
43
44 <?php
45
46 require_once('./install/schema.php');
47
48 foreach ($query AS $table => $query)
49 {
50 $db->query($query);
51 echo 'Creating table ' . $table . '<br />' . "\n";
52 }
53 }
54
55 // ###################################################################
56
57 if ($bugsys->in['mark'] == 2)
58 {
59 ?>
60 <h1>Loading Default Data</h1>
61
62 <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>
63
64 <?php
65
66 require_once('./install/default_data.php');
67
68 foreach ($data AS $table => $records)
69 {
70 foreach ($records AS $record)
71 {
72 $fields = $values = array();
73 foreach ($record AS $field => $value)
74 {
75 $fields[] = $field;
76 $values[] = addslashes($value);
77 }
78
79 $db->query("INSERT INTO " . TABLE_PREFIX . "$table (" . implode(',', $fields) . ") VALUES ('" . implode("', '", $values) . "')");
80 }
81
82 echo 'Populating table ' . $table . '<br />' . "\n";
83 }
84
85 $db->query("INSERT INTO " . TABLE_PREFIX . "language (title, languagecode, charset, direction, filename, userselect, debug) VALUES ('English (US)', 'en', 'utf-8', 'ltr', './includes/strings/english-us.strings.xml', 1, 0)");
86 echo 'Inserting default language<br />' . "\n";
87 }
88
89 // ###################################################################
90
91 if ($bugsys->in['mark'] == 3)
92 {
93 ?>
94 <h1>Loading Settings</h1>
95
96 <p>Default settings are being loaded into the system.</p>
97
98 <?php
99
100 class dummy { function string() {} }
101 $lang = new dummy();
102
103 require_once('./includes/settings.php');
104
105 foreach ($config AS $varname => $setting)
106 {
107 $db->query("INSERT INTO " . TABLE_PREFIX . "setting (varname, value) VALUES ('" . $varname . "', '" . addslashes($setting[3]) . "')");
108 }
109
110 echo 'Settings loaded...';
111 }
112
113 // ###################################################################
114
115 if ($bugsys->in['mark'] == 4)
116 {
117 $value = 'http' . ($_SERVER['HTTPS'] == 'on' ? 's' : '') . '://' . $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] != '80' ? ':' . $_SERVER['SERVER_PORT'] : '') . str_replace('/install/install.php', '', $_SERVER['SCRIPT_NAME']);
118 ?>
119 <h1>General Settings</h1>
120
121 <p>These three settings are fundamental in setting up your bug tracking system. Please fill them in to proceed with the installation.</p>
122
123 <form name="settings-do" action="install.php" method="post">
124 <input type="hidden" name="mark" value="5" />
125
126 <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>
127 <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="<?= $value ?>" /></div>
128 <div><strong>Webmaster Email:</strong> <input type="text" name="webmasteremail" size="50" /></div>
129
130 <input type="submit" name="submit" value="Next Step" />
131
132 </form>
133
134 <?php
135
136 page_end(false);
137 }
138
139 // ###################################################################
140
141 if ($bugsys->in['mark'] == 5)
142 {
143 ?>
144 <h1>New Administrator</h1>
145
146 <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>
147
148 <form name="user-do" action="install.php" method="post">
149 <input type="hidden" name="mark" value="6" />
150
151 <div><strong>Display Name:</strong> <input type="text" name="displayname" size="50" /></div>
152 <div><strong>Email Address:</strong> <input type="text" name="email" size="50" /></div>
153 <div><strong>Password:</strong> <input type="password" name="password" size="50" /></div>
154
155 <input type="submit" name="submit" value="Next Step" />
156 </form>
157
158 <?php
159
160 $db->query("UPDATE " . TABLE_PREFIX . "setting SET value = '" . $bugsys->in['trackertitle'] . "' WHERE varname = 'trackertitle'");
161 $db->query("UPDATE " . TABLE_PREFIX . "setting SET value = '" . $bugsys->in['trackerurl'] . "' WHERE varname = 'trackerurl'");
162 $db->query("UPDATE " . TABLE_PREFIX . "setting SET value = '" . $bugsys->in['webmasteremail'] . "' WHERE varname = 'webmasteremail'");
163
164 page_end(false);
165 }
166
167 // ###################################################################
168
169 if ($bugsys->in['mark'] == 6)
170 {
171 ?>
172 <h1>User Added</h1>
173
174 <p>Your new user has been added.</p>
175 <?php
176
177 $bugsys->load('functions');
178
179 $salt = $funct->rand(15);
180
181 $db->query("
182 INSERT INTO " . TABLE_PREFIX . "user
183 (email, displayname, password, salt, authkey, showemail, showcolours, usergroupid)
184 VALUES
185 ('" . $bugsys->in['email'] . "', '" . $bugsys->in['displayname'] . "',
186 '" . md5(md5($bugsys->in['password']) . md5($salt)) . "', '$salt',
187 '" . $funct->rand() . "', 1, 1, 6
188 )"
189 );
190 }
191
192 // ###################################################################
193
194 if ($bugsys->in['mark'] == 7)
195 {
196 ?>
197 <h1>Cache Data</h1>
198
199 <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>
200 <?php
201
202 require_once('./includes/permissions.php');
203
204 build_settings();
205 echo "Cached settings<br />\n";
206
207 build_usergroups();
208 echo "Cached usergroups<br />\n";
209
210 build_statuses();
211 echo "Cached statuses<br />\n";
212
213 build_priorities();
214 echo "Cached priorities<br />\n";
215
216 build_severities();
217 echo "Cached severities<br />\n";
218
219 build_assignedto();
220 echo "Cached assignable users/developers<br />\n";
221
222 build_resolutions();
223 echo "Cached resolutions<br />\n";
224
225 build_products();
226 echo "Cached products<br />\n";
227
228 build_versions();
229 echo "Cached versions<br />\n";
230
231 build_user_help();
232 echo "Cached user help documentation<br />\n";
233 }
234
235 // ###################################################################
236
237 if ($bugsys->in['mark'] == 8)
238 {
239 ?>
240 <h1>Load Language Strings</h1>
241
242 <p>Bugdar's flexible language system caches all of the strings in the database. Currently, the strings are being read from the raw file into the cache.</p>
243 <?php
244
245 class dummy { function setlex() {} function string() {} }
246 $lang = new dummy();
247
248 $bugsys->load('xml', 'xml');
249
250 build_languages();
251
252 require_once('./includes/language.php');
253 build_language_cache(1);
254 }
255
256 // ###################################################################
257
258 page_end();
259
260 /*=====================================================================*\
261 || ###################################################################
262 || # $HeadURL$
263 || # $Id$
264 || ###################################################################
265 \*=====================================================================*/
266 ?>