forked from jjeroennl/quantiweb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.php
executable file
·326 lines (301 loc) · 9.75 KB
/
setup.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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
<?php
SESSION_START();
$url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
$url = str_replace("setup.php", "", $url);
//defaults
define('OFFICIAL_WEBSITE', 'localhost');
define('OFFICIAL_NAME', 'Quantiweb');
define('FORK_NAME', 'Quantiweb');
define('OFFICIAL_VERSION', '0.02');
define('INSTALL_LOCATION', $url);
define('LOCAL_INSTALL_LOCATION', dirname("__FILENAME__"));
$pagename = "Setup";
include("themes/admin/header.php");
if(isset($_GET['db'])){
unset($_SESSION['db']);
if(!isset($status)){
$status = 3;
}
?>
<div class="section section-breadcrumbs">
<div class="container">
<div class="row">
<div class="col-md-12">
<h1>Setup</h1>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="service-wrapper left-align">
<b>Welcome to the instalation process of <?php echo OFFICIAL_NAME;?>. This setup will let you configure and install your website in a few easy steps.</b>
<h2>Database setup</h2>
<p>This is the most complex part of the setup. For this you will need to setup a database. How to do that depends of your hosting provider. If you don't know your database configuration, contact your hosting provider.</p>
<?php if($status == 0){
echo '
<div class="alert alert-danger" role="alert">
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
<span class="sr-only">Error:</span>
Something in your configuration isn\'t right.
</div>';
}
?>
<form method="post" action="setup.php?set_db">
<input type="text" class="form-control" required name="db_name" placeholder="Database name"
<?php if($status == 0){ echo 'value="' . $_POST['db_name'] . '"';}?>
><br>
<input type="text" class="form-control" required name="db_user" placeholder="Database username"
<?php if($status == 0){ echo 'value="' . $_POST['db_user'] . '"';}?>><br>
<input type="password" class="form-control" required name="db_pass" placeholder="Database password" ><br>
<input type="text" class="form-control" required name="db_host" placeholder="Database hostname"
<?php if($status == 0){ echo 'value="' . $_POST['db_host'] . '"';}?>
<small style="color: grey;">If you don't know which hostname you have to enter than it's usually localhost.</small><br>
<input type="text" class="form-control" required name="f_location" placeholder="Instalation URL" value="<?php echo $url;?>"><br>
<input class="btn btn-grey" value="Send" type="submit">
</form>
</div>
</div>
</div>
</div>
<?php
}
elseif(isset($_GET['set_db'])){
//Databaseconfig
//databasename
define('DB_NAME', $_POST['db_name']);
//username
define('DB_USER', $_POST['db_user']);
//password
define('DB_PASSWORD', $_POST['db_pass']);
//hostname
define('DB_HOST', $_POST['db_host']);
include 'plugins/system/db/_db.php';
if(db_check() == 1){
$status = 1;
$data = "<?php
//Databaseconfig
//databasename
define('DB_NAME', '" . DB_NAME . "');
//username
define('DB_USER', '" . DB_USER ."');
//password
define('DB_PASSWORD', '". DB_PASSWORD ."');
//hostname
define('DB_HOST', '" . DB_HOST . "');
//frameworkconfig
define('OFFICIAL_WEBSITE', '". OFFICIAL_WEBSITE ."');
define('OFFICIAL_NAME', '". OFFICIAL_NAME ."');
define('FORK_NAME', '". FORK_NAME ."');
define('OFFICIAL_VERSION', '". OFFICIAL_VERSION ."');
define('INSTALL_LOCATION', '" . $_POST['f_location'] . "');
define('LOCAL_INSTALL_LOCATION', '../" . LOCAL_INSTALL_LOCATION . "');
\$navpage = array();
?>";
$file = fopen("config.php", "w");
if(fwrite($file, $data)){
$db_status = 1;
$_SESSION['db'] = 1;
}
else{
$db_status = 2;
$_SESSION['db'] = 1;
}
fclose($file);
}
else{
$status = 0;
echo "something went wrong!";
}
if($db_status == 2){
?>
<div class="section section-breadcrumbs">
<div class="container">
<div class="row">
<div class="col-md-12">
<h1>Setup</h1>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="service-wrapper left-align">
<h2>Finalizing database setup</h2>
It seems that the setup doesn't have rights over the config.php file. You need to manualy copy and paste this into config.php, then click the next button.
<textarea class="form-control" style = "height: 300px;"><?php echo $data;?></textarea>
<a href="setup.php?user_setup">Next</a>
</div>
</div>
</div>
</div>
<?php
}
elseif($status == 1){
header("Location: setup.php?user_setup");
}
}
elseif(isset($_GET['user_setup']) && isset($_SESSION['db'])){
?>
<div class="section section-breadcrumbs">
<div class="container">
<div class="row">
<div class="col-md-12">
<h1>Setup</h1>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="service-wrapper left-align">
<h2>Finalizing setup</h2>
<p>Now it's time to setup the nice (and last) part: your website! Tell us what you want to call your site, and which username and password you want to manage it.</p>
<form method="post" action="setup.php?finish">
<hr>
<input type="text" class="form-control" name="websitename" required placeholder="Websitename"><br>
<input type="text" class="form-control" name="websiteslogan" placeholder="Slogan">
<hr>
<input type="text" class="form-control" name="register-username" required placeholder="Username"><br>
<input type="password" class="form-control" name="register-password" required placeholder="Password"><br>
<input type="email" class="form-control" name="register-email" required placeholder="Email adress"><br>
<input type="submit" class="btn btn-grey" value="Setup!">
</form>
</div>
</div>
</div>
</div>
<?php
}
elseif(isset($_GET['finish']) && isset($_SESSION['db']) && isset($_POST['websitename']) && isset($_POST['register-username']) && isset($_POST['register-password'])){
//grab database system
include 'config.php';
include 'plugins/system/db/_db.php';
include 'plugins/system/system/_system.php';
//create system settings DB
db_create("system_settings", array(
"setting" => "TEXT",
"value" => "TEXT",
"setting_id" => "INT NOT NULL AUTO_INCREMENT "
), "setting_id");
db_insert("system_settings", array(
"setting" => "websitename",
"value" => $_POST['websitename']
));
db_insert("system_settings", array(
"setting" => "websiteslogan",
"value" => $_POST['websiteslogan']
));
db_insert("system_settings", array(
"setting" => "default_db",
"value" => "SYSTEM"
));
db_insert("system_settings", array(
"setting" => "plugins",
"value" => "!system,!admin,!settings,!content,!theme"
));
db_insert("system_settings", array(
"setting" => "index",
"value" => ""
));
db_insert("system_settings", array(
"setting" => "wantindex",
"value" => ""
));
db_insert("system_settings", array(
"setting" => "c_perpage",
"value" => "10"
));
db_insert("system_settings", array(
"setting" => "allow_registration",
"value" => "0"
));
db_insert("system_settings", array(
"setting" => "default_role",
"value" => "0"
));
db_insert("system_settings", array(
"setting" => "theme",
"value" => "solid"
));
db_insert("system_settings", array(
"setting" => "timeformat",
"value" => "H:i:s"
));
db_insert("system_settings", array(
"setting" => "dateformat",
"value" => "Y-m-d"
));
//create content DB
db_create("content", array(
"title" => "TEXT",
"author" => "INT",
"content" => "TEXT",
"type" => "INT",
"status" => "INT DEFAULT 0",
"date" => "TIMESTAMP DEFAULT CURRENT_TIMESTAMP",
"views" => "INT",
"content_id" => "INT NOT NULL AUTO_INCREMENT "
), "content_id");
//create users DB
db_create("users", array(
"username" => "TEXT",
"password" => "TEXT",
"email" => "TEXT",
"role" => "INT",
"registrationdate" => "DATETIME",
"user_id" => "INT NOT NULL AUTO_INCREMENT "
), "user_id");
//register admin user
system_register($_POST['register-username'], $_POST['register-password'], $_POST['register-email'], "ADMIN");
//create admin DB
db_create("admin", array(
"name" => "TEXT",
"function" => "TEXT",
"admin_id" => "INT NOT NULL AUTO_INCREMENT "
), "admin_id");
db_insert("admin", array(
"name" => "Plugins",
"function" => "plugins_config",
"admin_id" => 2
));
db_insert("admin", array(
"name" => "Settings",
"function" => "settings_admin",
"admin_id" => 3
));
db_insert("admin", array(
"name" => "Settings",
"function" => "theme_admin",
"admin_id" => 4
));
//create roles DB
db_create("role", array(
"role" => "TEXT",
"role_id" => "INT NOT NULL AUTO_INCREMENT "
), "role_id");
//create content type database
db_create("content_types", array(
"type" => "TEXT",
"menu" => "INT",
"way" => "INT",
"aditional" => "TEXT",
"type_id" => "INT NOT NULL AUTO_INCREMENT "
), "type_id");
//create content metadata
db_create("content_metadata", array(
"content" => "INT",
"metadata" => "TEXT",
"value" => "TEXT",
"meta_id" => "INT NOT NULL AUTO_INCREMENT "
), "meta_id");
header("Location: index.php");
}
else{
header("Location: setup.php?db");
}
include("themes/admin/footer.php");
?>