forked from philippK-de/Collabtive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_mysql.php
274 lines (254 loc) · 9.28 KB
/
install_mysql.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
<?php
if($installer_include != "yes")
{
die("this file can only be included");
}
$conn = new PDO("mysql:host=$db_host;dbname=$db_name", $db_user, $db_pass);
if (!($conn)) {
$template->assign("errortext", "Database connection could not be established. <br>Please check if database exists and check if login credentials are correct.");
$template->display("error.tpl");
die();
}
// Create MySQL Tables
$table1 = $conn->query("CREATE TABLE IF NOT EXISTS `company` (
`ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`company` varchar(255) NOT NULL,
`contact` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`phone` varchar(64) NOT NULL,
`mobile` varchar(64) NOT NULL,
`url` varchar(255) NOT NULL,
`address` varchar(255) NOT NULL,
`zip` varchar(16) NOT NULL,
`city` varchar(255) NOT NULL,
`country` varchar(255) NOT NULL,
`state` varchar(255) NOT NULL,
`desc` text NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$table2 = $conn->query("CREATE TABLE IF NOT EXISTS `customers_assigned` (
`ID` int(10) NOT NULL AUTO_INCREMENT,
`customer` int(10) NOT NULL,
`project` int(10) NOT NULL,
PRIMARY KEY (`ID`),
UNIQUE KEY `ID` (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$table3 = $conn->query("CREATE TABLE `files` (
`ID` int(10) NOT NULL auto_increment,
`name` varchar(255) NOT NULL default '',
`desc` varchar(255) NOT NULL default '',
`project` int(10) NOT NULL default '0',
`milestone` int(10) NOT NULL default '0',
`user` int(10) NOT NULL default '0',
`added` varchar(255) NOT NULL default '',
`datei` varchar(255) NOT NULL default '',
`type` varchar(255) NOT NULL default '',
`title` varchar(255) NOT NULL default '',
`folder` int(10) NOT NULL,
`visible` text NOT NULL,
PRIMARY KEY (`ID`),
KEY `name` (`name`),
KEY `datei` (`datei`),
KEY `added` (`added`),
KEY `project` (`project`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$table4 = $conn->query("CREATE TABLE `log` (
`ID` int(10) NOT NULL auto_increment,
`user` int(10) NOT NULL default '0',
`username` varchar(255) NOT NULL default '',
`name` varchar(255) NOT NULL default '',
`type` varchar(255) NOT NULL default '',
`action` int(1) NOT NULL default '0',
`project` int(10) NOT NULL default '0',
`datum` varchar(255) NOT NULL default '',
PRIMARY KEY (`ID`),
KEY `datum` (`datum`),
KEY `type` (`type`),
KEY `action` (`action`),
FULLTEXT KEY `username` (`username`),
FULLTEXT KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$table5 = $conn->query("CREATE TABLE `messages` (
`ID` int(10) NOT NULL auto_increment,
`project` int(10) NOT NULL default '0',
`title` varchar(255) NOT NULL default '',
`text` text NOT NULL,
`tags` varchar(255) NOT NULL,
`posted` varchar(255) NOT NULL default '',
`user` int(10) NOT NULL default '0',
`username` varchar(255) NOT NULL default '',
`replyto` int(11) NOT NULL default '0',
`milestone` int(10) NOT NULL,
PRIMARY KEY (`ID`),
KEY `project` (`project`),
KEY `user` (`user`),
KEY `replyto` (`replyto`),
KEY `tags` (`tags`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$table6 = $conn->query("CREATE TABLE `milestones` (
`ID` int(10) NOT NULL auto_increment,
`project` int(10) NOT NULL default '0',
`name` varchar(255) NOT NULL default '',
`desc` text NOT NULL,
`start` varchar(255) NOT NULL default '',
`end` varchar(255) NOT NULL default '',
`status` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`ID`),
KEY `name` (`name`),
KEY `end` (`end`),
KEY `project` (`project`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$table7 = $conn->query("CREATE TABLE `milestones_assigned` (
`ID` int(10) NOT NULL auto_increment,
`user` int(10) NOT NULL default '0',
`milestone` int(10) NOT NULL default '0',
PRIMARY KEY (`ID`),
KEY `user` (`user`),
KEY `milestone` (`milestone`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$table8 = $conn->query("CREATE TABLE `projekte` (
`ID` int(10) NOT NULL auto_increment,
`name` varchar(255) NOT NULL default '',
`desc` text NOT NULL,
`start` varchar(255) NOT NULL default '',
`end` varchar(255) NOT NULL default '',
`status` tinyint(1) NOT NULL default '0',
`budget` float NOT NULL default '0',
PRIMARY KEY (`ID`),
KEY `status` (`status`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$table9 = $conn->query("CREATE TABLE `projekte_assigned` (
`ID` int(10) NOT NULL auto_increment,
`user` int(10) NOT NULL default '0',
`projekt` int(10) NOT NULL default '0',
PRIMARY KEY (`ID`),
KEY `user` (`user`),
KEY `projekt` (`projekt`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$table10 = $conn->query("CREATE TABLE `settings` (
`ID` int(10) NOT NULL auto_increment,
`settingsKey` varchar(50) NOT NULL,
`settingsValue` varchar(50) NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$table11 = $conn->query("CREATE TABLE `tasklist` (
`ID` int(10) NOT NULL auto_increment,
`project` int(10) NOT NULL default '0',
`name` varchar(255) NOT NULL default '',
`desc` text NOT NULL,
`start` varchar(255) NOT NULL default '',
`status` tinyint(1) NOT NULL default '0',
`access` tinyint(4) NOT NULL default '0',
`milestone` int(10) NOT NULL default '0',
PRIMARY KEY (`ID`),
KEY `status` (`status`),
KEY `milestone` (`milestone`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 DEFAULT CHARSET=utf8");
$table12 = $conn->query("CREATE TABLE `tasks` (
`ID` int(10) NOT NULL auto_increment,
`start` varchar(255) NOT NULL default '',
`end` varchar(255) NOT NULL default '',
`title` varchar(255) NOT NULL default '',
`text` text NOT NULL,
`liste` int(10) NOT NULL default '0',
`status` tinyint(1) NOT NULL default '0',
`project` int(10) NOT NULL default '0',
PRIMARY KEY (`ID`),
KEY `liste` (`liste`),
KEY `status` (`status`),
KEY `end` (`end`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$table13 = $conn->query("CREATE TABLE `tasks_assigned` (
`ID` int(10) NOT NULL auto_increment,
`user` int(10) NOT NULL default '0',
`task` int(10) NOT NULL default '0',
PRIMARY KEY (`ID`),
KEY `user` (`user`),
KEY `task` (`task`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$table14 = $conn->query("
CREATE TABLE `user` (
`ID` int(10) auto_increment,
`name` varchar(255) default '',
`email` varchar(255) default '',
`tel1` varchar(255),
`tel2` varchar(255) ,
`pass` varchar(255) default '',
`company` varchar(255) default '',
`lastlogin` varchar(255) default '',
`zip` varchar(10) ,
`gender` char(1) default '',
`url` varchar(255) default '',
`adress` varchar(255) default '',
`adress2` varchar(255) default '',
`state` varchar(255) default '',
`country` varchar(255) default '',
`tags` varchar(255) default '',
`locale` varchar(6) default '',
`avatar` varchar(255) default '',
`rate` varchar(10) ,
PRIMARY KEY (`ID`),
UNIQUE KEY `name` (`name`),
KEY `pass` (`pass`),
KEY `locale` (`locale`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$table16 = $conn->query("CREATE TABLE `files_attached` (
`ID` int(10) unsigned NOT NULL auto_increment,
`file` int(10) unsigned NOT NULL default '0',
`message` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`ID`),
KEY `file` (`file`,`message`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$table17 = $conn->query("CREATE TABLE `timetracker` (
`ID` int(10) NOT NULL auto_increment,
`user` int(10) NOT NULL default '0',
`project` int(10) NOT NULL default '0',
`task` int(10) NOT NULL default '0',
`comment` text NOT NULL,
`started` varchar(255) NOT NULL default '',
`ended` varchar(255) NOT NULL default '',
`hours` float NOT NULL default '0',
`pstatus` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`ID`),
KEY `user` (`user`,`project`,`task`),
KEY `started` (`started`),
KEY `ended` (`ended`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$table18 = $conn->query("CREATE TABLE `projectfolders` (
`ID` int(10) unsigned NOT NULL auto_increment,
`parent` int(10) unsigned NOT NULL default '0',
`project` int(11) NOT NULL default '0',
`name` text NOT NULL,
`description` varchar(255) NOT NULL,
`visible` text NOT NULL,
PRIMARY KEY (`ID`),
KEY `project` (`project`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$table19 = $conn->query("
CREATE TABLE `roles` (
`ID` int(10) NOT NULL auto_increment,
`name` varchar(255) NOT NULL,
`projects` text NOT NULL,
`tasks` text NOT NULL,
`milestones` text NOT NULL,
`messages` text NOT NULL,
`files` text NOT NULL,
`chat` text NOT NULL,
`timetracker` text NOT NULL,
`admin` text NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$table20 = $conn->query("
CREATE TABLE `roles_assigned` (
`ID` int(10) NOT NULL auto_increment,
`user` int(10) NOT NULL,
`role` int(10) NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
// Checks if tables could be created
if (!$table1 or !$table2 or !$table3 or !$table4 or !$table5 or !$table6 or !$table7 or !$table8 or !$table9 or !$table10 or !$table11 or !$table12 or !$table13 or !$table14 or !$table16 or !$table17 or !$table18 or !$table19 or !$table20) {
$template->assign("errortext", "Error: Tables could not be created.");
$template->display("error.tpl");
die();
}
?>