r559: Most of the installer is now done
[bugdar.git] / install / install.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]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', 7);
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 BugStrike</h1>
26
27 <p>This installer will take you through the procedure of setting up your BugStrike 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 BugStrike 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 . "product (componentmother, shortname, displayorder, title, description) VALUES (0, 'main', 10, 'Main Product', 'Default product from installer')");
86 $db->query("INSERT INTO " . TABLE_PREFIX . "version (productid, version, displayorder) VALUES (1, 'Main Version', 100)");
87
88 echo 'Inserting default product and version<br />' . "\n";
89 }
90
91 // ###################################################################
92
93 if ($bugsys->in['mark'] == 3)
94 {
95 ?>
96 <h1>Loading Settings</h1>
97
98 <p>Default settings are being loaded into the system.</p>
99
100 <?php
101
102 class dummy { function string() {} }
103 $lang = new dummy();
104
105 require_once('./includes/settings.php');
106
107 foreach ($config AS $varname => $setting)
108 {
109 $db->query("INSERT INTO " . TABLE_PREFIX . "setting (varname, value) VALUES ('" . $varname . "', '" . addslashes($setting[3]) . "')");
110 }
111
112 echo 'Settings loaded...';
113 }
114
115 // ###################################################################
116
117 if ($bugsys->in['mark'] == 4)
118 {
119 ?>
120 <h1>General Settings</h1>
121
122 <p>These three settings are fundamental in setting up your bug tracking system. Please fill them in to proceed with the installation.</p>
123
124 <form name="settings-do" action="install.php" method="post">
125 <input type="hidden" name="mark" value="5" />
126
127 <div><strong>Tracker Name:</strong> <input type="text" name="trackertitle" size="50" /></div>
128 <div><strong>Tracker URL (<em>does not end with a trailing slash!</em>):</strong> <input type="text" name="trackerurl" size="50" /></div>
129 <div><strong>Webmaster Email:</strong> <input type="text" name="webmasteremail" size="50" /></div>
130
131 <input type="submit" name="submit" value="Next Step" />
132
133 </form>
134
135 <?php
136
137 page_end(false);
138 }
139
140 // ###################################################################
141
142 if ($bugsys->in['mark'] == 5)
143 {
144 ?>
145 <h1>New Administrator</h1>
146
147 <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>
148
149 <form name="user-do" action="install.php" method="post">
150 <input type="hidden" name="mark" value="6" />
151
152 <div><strong>Display Name:</strong> <input type="text" name="displayname" size="50" /></div>
153 <div><strong>Email Address:</strong> <input type="text" name="email" size="50" /></div>
154 <div><strong>Password:</strong> <input type="password" name="password" size="50" /></div>
155
156 <input type="submit" name="submit" value="Next Step" />
157 </form>
158
159 <?php
160
161 $db->query("UPDATE " . TABLE_PREFIX . "setting SET value = '" . $bugsys->in['trackertitle'] . "' WHERE varname = 'trackertitle'");
162 $db->query("UPDATE " . TABLE_PREFIX . "setting SET value = '" . $bugsys->in['trackerurl'] . "' WHERE varname = 'trackerurl'");
163 $db->query("UPDATE " . TABLE_PREFIX . "setting SET value = '" . $bugsys->in['webmasteremail'] . "' WHERE varname = 'webmasteremail'");
164
165 page_end(false);
166 }
167
168 // ###################################################################
169
170 if ($bugsys->in['mark'] == 6)
171 {
172 ?>
173 <h1>User Added</h1>
174
175 <p>Your new user has been added.</p>
176 <?php
177
178 $bugsys->load('functions');
179
180 $salt = $funct->rand(15);
181
182 $db->query("
183 INSERT INTO " . TABLE_PREFIX . "user
184 (email, displayname, password, salt, authkey, showemail, showcolours, usergroupid)
185 VALUES
186 ('" . $bugsys->in['email'] . "', '" . $bugsys->in['displayname'] . "',
187 '" . md5(md5($bugsys->in['password']) . md5($salt)) . "', '$salt',
188 '" . $funct->rand() . "', 1, 1, 6
189 )"
190 );
191 }
192
193 // ###################################################################
194
195 if ($bugsys->in['mark'] == 7)
196 {
197 ?>
198 <h1>Cache Data</h1>
199
200 <p>In order to make BugStrike the most efficient possible, the system caches the maximum amount of data it can. This reduces the load of your server without compromising usability. Currently the caches are being built.</p>
201 <?php
202
203 build_settings();
204 echo "Cached settings<br />\n";
205
206 build_usergroups();
207 echo "Cached usergroups<br />\n";
208
209 build_statuses();
210 echo "Cached statuses<br />\n";
211
212 build_priorities();
213 echo "Cached priorities<br />\n";
214
215 build_assignedto();
216 echo "Cached assignable users/developers<br />\n";
217
218 build_resolutions();
219 echo "Cached resolutions<br />\n";
220
221 build_products();
222 echo "Cached products<br />\n";
223
224 build_versions();
225 echo "Cached versions<br />\n";
226 }
227
228 // ###################################################################
229
230 page_end();
231
232 /*=====================================================================*\
233 || ###################################################################
234 || # $HeadURL$
235 || # $Id$
236 || ###################################################################
237 \*=====================================================================*/
238 ?>