Issues (762)

setup/db-repair.php (1 issue)

1
<?php
2
3
/**
4
 * Copyright (c) 2018 Justin Kuenzel (jukusoft.com)
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
20
/**
21
 * This file creates / upgrades database structure
22
 */
23
24
//define root path
25
define('ROOT_PATH', dirname(__FILE__) . "/../");
26
27
define('INSTALL_SCRIPT', true);
28
29
error_reporting(E_ALL);
30
31
if (PHP_MAJOR_VERSION < 7) {
32
	echo "CMS is required PHP 7.0.0 or greater! Please install PHP 7 (current version: " . PHP_VERSION . ").";
33
	exit;
34
}
35
36
//define some constants
37
define('CACHE_PATH', ROOT_PATH . "cache/");
38
define('CONFIG_PATH', ROOT_PATH . "config/");
39
define('STORE_PATH', ROOT_PATH . "store/");
40
41
//include and load ClassLoader
42
require(ROOT_PATH . "system/core/classes/classloader.php");
43
ClassLoader::init();
44
45
//require config
46
require(ROOT_PATH . "config/config.php");
47
48
//initialize cache
49
Cache::init();
50
51
//initialize database
52
Database::getInstance();
53
54
/**
55
 * create database schema here
56
 */
57
58
/**
59
 * test table to check upgrade system
60
 */
61
62
echo "Create / Upgrade table <b>test</b>...<br />";
63
64
//create or upgrade test table
65
$table = new DBTable("test", Database::getInstance());
66
$table->setEngine("InnoDB");
67
$table->setCharset("utf8");
68
69
//add int coloum with length 10, NOT NULL and AUTO_INCREMENT
70
$table->addInt("id", 11, true, true);
71
$table->addVarchar("name", 255, true);
72
$table->addVarchar("value", 255, true);
73
$table->addInt("activated", 10, true, false, "1");
74
75
//add keys to table
76
$table->addPrimaryKey("id");
77
$table->addUnique("name", "UNIQUE_NAME");
78
$table->addIndex("activated", "ix_activated");
79
80
//create or upgrade table
81
$table->upgrade();
82
83
echo "Finished!<br />";
84
85
/**
86
 * test table to check upgrade system with added column, removed column and changed column
87
 */
88
89
echo "Create / Upgrade table <b>test</b>...<br />";
90
91
//create or upgrade test table
92
$table = new DBTable("test", Database::getInstance());
93
$table->setEngine("InnoDB");
94
$table->setCharset("utf8");
95
96
//add int coloum with length 10, NOT NULL and AUTO_INCREMENT
97
$table->addInt("id", 11, true, true);
98
//$table->addVarchar("name", 255, true);
99
$table->addVarchar("name2", 255, true);
100
$table->addVarchar("value", 200, false);
101
$table->addInt("activated", 10, true, false, "1");
102
103
//add keys to table
104
$table->addPrimaryKey("id");
105
$table->addUnique("name", "UNIQUE_NAME");
106
$table->addIndex("activated", "ix_activated");
107
108
//create or upgrade table
109
$table->upgrade();
110
111
echo "Finished!<br />";
112
113
/**
114
 * table EVENTS
115
 */
116
117
echo "Create / Upgrade table <b>events</b>...<br />";
118
119
//create or upgrade test table
120
$table = new DBTable("events", Database::getInstance());
121
$table->setEngine("InnoDB");
122
$table->setCharset("utf8");
123
124
//add int coloum with length 10, NOT NULL and AUTO_INCREMENT
125
$table->addInt("id", 11, true, true);
126
$table->addVarchar("name", 255, true);
127
$table->addEnum("type", array("FILE", "FUNCTION", "CLASS_STATIC_METHOD", ""), true);
128
$table->addVarchar("file", 255, false, "NULL");
129
$table->addVarchar("class_name", 255, true, "");
130
$table->addVarchar("class_method", 255, true, "");
131
$table->addVarchar("created_from", 255, true);
132
$table->addInt("activated", 10, true, false, "1");
133
134
//add keys to table
135
$table->addPrimaryKey("id");
136
$table->addUnique(array("name", "file", "class_name", "class_method"), "UNIQUE_EVENTS");
137
$table->addIndex(array("name", "activated"), "name");
138
139
//create or upgrade table
140
$table->upgrade();
141
142
echo "Finished!<br />";
143
144
/**
145
 * table DOMAIN
146
 */
147
148
echo "Create / Upgrade table <b>domain</b>...<br />";
149
150
//create or upgrade test table
151
$table = new DBTable("domain", Database::getInstance());
152
$table->setEngine("InnoDB");
153
$table->setCharset("utf8");
154
155
//add int coloum with length 10, NOT NULL and AUTO_INCREMENT
156
$table->addInt("id", 10, true, true);
157
$table->addVarchar("domain", 255, true);
158
$table->addInt("alias", 10, true, false, "-1");
159
$table->addVarchar("home_page", 255, true, "home");
160
$table->addEnum("wildcard", array("YES", "NO"), true, "NO");
161
$table->addInt("styleID", 10, true, false, "-1");
162
$table->addVarchar("redirect_url", 255, true, "none");#
163
$table->addInt("redirect_code", 10, true, false, "301");
164
$table->addVarchar("base_dir", 255, true, "/");
165
$table->addInt("force_ssl", 10, true, false, "0");//if 1 then all http urls would be rewritten to https urls
166
$table->addTimestamp("lastUpdate", true, "CURRENT_TIMESTAMP");
167
$table->addInt("activated", 10, true, false, "1");
168
169
//add keys to table
170
$table->addPrimaryKey("id");
171
$table->addUnique("domain");
172
$table->addIndex("alias");
173
174
//create or upgrade table
175
$table->upgrade();
176
177
echo "Finished!<br />";
178
179
/**
180
 * table global_settings
181
 *
182
 * Package: com.jukusoft.cms.settings
183
 */
184
185
echo "Create / Upgrade table <b>global_settings</b>...<br />";
186
187
//create or upgrade test table
188
$table = new DBTable("global_settings", Database::getInstance());
189
$table->setEngine("InnoDB");
190
$table->setCharset("utf8");
191
192
//add int coloum with length 10, NOT NULL and AUTO_INCREMENT
193
$table->addVarchar("key", 255, true);
194
$table->addText("value", true);
195
$table->addVarchar("title", 255, true);
196
$table->addVarchar("description", 600, true);
197
$table->addVarchar("visible_permission", 255, true, "can_see_global_settings");
198
$table->addVarchar("change_permission", 255, true, "can_change_global_settings");
199
$table->addVarchar("owner", 255, true, "system");
200
$table->addInt("order", 10, true, false, 10);
201
$table->addVarchar("icon_path", 600, true, "none");
202
$table->addTimestamp("last_update", true, "0000-00-00 00:00:00", true);
203
$table->addVarchar("datatype", 255, true, "DataType_String");
204
$table->addText("datatype_params", true);
205
$table->addInt("editable", 10, true, false, 1);
206
$table->addVarchar("category", 255, true, "general");
207
$table->addInt("activated", 10, true, false, 1);
208
209
//add keys to table
210
$table->addPrimaryKey("key");
211
$table->addIndex("last_update");
212
$table->addIndex("activated");
213
214
//create or upgrade table
215
$table->upgrade();
216
217
echo "Finished!<br />";
218
219
/**
220
 * table global_settings_category
221
 *
222
 * Package: com.jukusoft.cms.settings
223
 */
224
225
echo "Create / Upgrade table <b>global_settings_category</b>...<br />";
226
227
//create or upgrade test table
228
$table = new DBTable("global_settings_category", Database::getInstance());
229
$table->setEngine("InnoDB");
230
$table->setCharset("utf8");
231
232
//add int coloum with length 10, NOT NULL and AUTO_INCREMENT
233
$table->addVarchar("category", 255, true);
234
$table->addVarchar("title", 255, true);
235
$table->addVarchar("owner", 255, true, "system");
236
$table->addInt("order", 10, true, false, 10);
237
238
//add keys to table
239
$table->addPrimaryKey("category");
240
$table->addIndex("order");
241
242
//create or upgrade table
243
$table->upgrade();
244
245
echo "Finished!<br />";
246
247
/**
248
 * table api_methods
249
 *
250
 * Package: com.jukusoft.cms.apimethods
251
 */
252
253
echo "Create / Upgrade table <b>api_methods</b>...<br />";
254
255
//create or upgrade test table
256
$table = new DBTable("api_methods", Database::getInstance());
257
$table->setEngine("InnoDB");
258
$table->setCharset("utf8");
259
260
//add int coloum with length 10, NOT NULL and AUTO_INCREMENT
261
$table->addVarchar("api_method", 255, true);
262
$table->addVarchar("classname", 255, true);
263
$table->addVarchar("method", 255, true);
264
$table->addVarchar("response_type", 255, true, "application/json");
265
$table->addVarchar("owner", 255, true, "system");
266
$table->addInt("activated", 10, true, false, 1);
267
268
//add keys to table
269
$table->addPrimaryKey("api_method");
270
$table->addIndex("activated");
271
272
//create or upgrade table
273
$table->upgrade();
274
275
echo "Finished!<br />";
276
277
/**
278
 * table robots
279
 *
280
 * Package: com.jukusoft.cms.robots
281
 */
282
283
echo "Create / Upgrade table <b>robots</b>...<br />";
284
285
//create or upgrade test table
286
$table = new DBTable("robots", Database::getInstance());
287
$table->setEngine("InnoDB");
288
$table->setCharset("utf8");
289
290
//add int coloum with length 10, NOT NULL and AUTO_INCREMENT
291
$table->addVarchar("useragent", 255, true);
292
$table->addEnum("option", array("ALLOW", "DISALLOW", "SITEMAP", "CRAWL-DELAY"), true, "ALLOW");
293
$table->addVarchar("value", 255, true);
294
$table->addInt("activated", 10, true, false, 1);
295
296
//add keys to table
297
$table->addPrimaryKey(array("useragent", "value"));
298
$table->addIndex("activated");
299
300
//create or upgrade table
301
$table->upgrade();
302
303
echo "Finished!<br />";
304
305
/**
306
 * table folder
307
 *
308
 * Package: com.jukusoft.cms.folder
309
 */
310
311
echo "Create / Upgrade table <b>folder</b>...<br />";
312
313
//create or upgrade test table
314
$table = new DBTable("folder", Database::getInstance());
315
$table->setEngine("InnoDB");
316
$table->setCharset("utf8");
317
318
//add int coloum with length 10, NOT NULL and AUTO_INCREMENT
319
$table->addVarchar("folder", 255, true);
320
$table->addVarchar("force_template", 255, true, "none");
321
$table->addInt("main_menu", 10, true, false, -1);
322
$table->addInt("local_menu", 10, true, false, -1);
323
$table->addVarchar("permissions", 600, true, "none");
324
$table->addInt("title_translation_support", 10, true, false, 1);
325
$table->addInt("hidden", 10, true, false, 0);
326
$table->addInt("activated", 10, true, false, 1);
327
328
//add keys to table
329
$table->addPrimaryKey("folder");
330
$table->addIndex("activated");
331
332
//create or upgrade table
333
$table->upgrade();
334
335
echo "Finished!<br />";
336
337
/**
338
 * table style_rules
339
 *
340
 * Package: com.jukusoft.cms.style
341
 */
342
343
echo "Create / Upgrade table <b>style_rules</b>...<br />";
344
345
//create or upgrade test table
346
$table = new DBTable("style_rules", Database::getInstance());
347
$table->setEngine("InnoDB");
348
$table->setCharset("utf8");
349
350
//add int coloum with length 10, NOT NULL and AUTO_INCREMENT
351
$table->addInt("rule_id", 10, true, true);
352
$table->addEnum("type", array("DOMAIN", "FOLDER", "MEDIA", "PREF_LANG", "SUPPORTED_LANG"), true);
353
$table->addVarchar("expected_value", 255, true);
354
$table->addVarchar("style_name", 255, true);
355
$table->addInt("parent", 10, true, false, "-1");
356
$table->addInt("order", 10, true, false, 1);
357
$table->addInt("activated", 10, true, false, 1);
358
359
//add keys to table
360
$table->addPrimaryKey("rule_id");
361
$table->addIndex("activated");
362
363
//create or upgrade table
364
$table->upgrade();
365
366
echo "Finished!<br />";
367
368
/**
369
 * table supported_languages
370
 *
371
 * Package: com.jukusoft.cms.style
372
 */
373
374
echo "Create / Upgrade table <b>supported_languages</b>...<br />";
375
376
//create or upgrade test table
377
$table = new DBTable("supported_languages", Database::getInstance());
378
$table->setEngine("InnoDB");
379
$table->setCharset("utf8");
380
381
//add int coloum with length 10, NOT NULL and AUTO_INCREMENT
382
$table->addVarchar("lang_token", 255, true);
383
$table->addVarchar("title", 255, true);
384
385
//add keys to table
386
$table->addPrimaryKey("lang_token");
387
388
//create or upgrade table
389
$table->upgrade();
390
391
echo "Finished!<br />";
392
393
/**
394
 * table pages
395
 *
396
 * Package: com.jukusoft.cms.page
397
 */
398
399
echo "Create / Upgrade table <b>pages</b>...<br />";
400
401
//create or upgrade test table
402
$table = new DBTable("pages", Database::getInstance());
403
$table->setEngine("InnoDB");
404
$table->setCharset("utf8");
405
406
//add int coloum with length 10, NOT NULL and AUTO_INCREMENT
407
$table->addInt("id", 10, true, true);
408
$table->addVarchar("alias", 255, true);
409
$table->addVarchar("title", 255, true);
410
$table->addText("content", true, "");
411
$table->addVarchar("content_type", 255, true, "text/html");
412
$table->addInt("redirect_code", 10, true, false, "301");
413
$table->addInt("parent", 10, true, false, -1);
414
$table->addVarchar("folder", 255, true, "/");
415
$table->addInt("global_menu", 10, true, false, -1);
416
$table->addInt("local_menu", 10, true, false, -1);
417
$table->addVarchar("page_type", 255, true, "HTMLPage");
418
$table->addVarchar("design", 255, true, "none");
419
$table->addInt("sitemap", 10, true, false, 1);//should page be shown in sitemap?
420
$table->addEnum("sitemap_changefreq", array("ALWAYS", "HOURLY", "DAILY", "WEEKLY", "MONTHLY", "YEARLY", "NEVER"), true, "weekly");
421
$table->addDecimal("sitemap_priority", 5, 2, true, "0.5");
422
$table->addInt("published", 10, true, false, 0);
423
$table->addInt("version", 10, true, false, 1);
424
$table->addTimestamp("last_update", true, "0000-00-00 00:00:00", true);
425
$table->addTimestamp("created", true, "0000-00-00 00:00:00", false);
426
$table->addInt("editable", 10, true, false, 1);
427
$table->addInt("deletable", 10, true, false, 1);
428
$table->addInt("author", 10, true, false, -1);
429
$table->addVarchar("can_see_permissions", 255, true, "none");
430
$table->addVarchar("template", 255, true, "none");
431
$table->addInt("sidebar_left", 10, true, false, -1);
432
$table->addInt("sidebar_right", 10, true, false, -1);
433
$table->addVarchar("meta_description", 600, true, "");
434
$table->addVarchar("meta_keywords", 255, true, "");
435
$table->addVarchar("meta_robots", 255, true, "");//none means not set
436
$table->addVarchar("meta_canonicals", 255, true, "");
437
$table->addInt("locked_by", 10, true, false, -1);
438
$table->addTimestamp("locked_timestamp", true, "0000-00-00 00:00:00");
439
$table->addVarchar("og_type", 50, true, "website");
440
$table->addVarchar("og_title", 50, true, "");
441
$table->addVarchar("og_description", 255, true, "");
442
$table->addVarchar("og_image", 600, true, "");
443
$table->addInt("activated", 10, true, false, 1);
444
445
//add keys to table
446
$table->addPrimaryKey("id");
447
$table->addUnique("alias");
448
$table->addIndex("folder");
449
450
//create or upgrade table
451
$table->upgrade();
452
453
echo "Finished!<br />";
454
455
/**
456
 * table page_types
457
 *
458
 * Package: com.jukusoft.cms.page
459
 */
460
461
echo "Create / Upgrade table <b>page_types</b>...<br />";
462
463
//create or upgrade test table
464
$table = new DBTable("page_types", Database::getInstance());
465
$table->setEngine("InnoDB");
466
$table->setCharset("utf8");
467
468
//fields
469
$table->addVarchar("page_type", 255, true);
470
$table->addVarchar("title", 255, true);
471
$table->addVarchar("create_permissions", 255, true, "none");//list with permissions (OR), one of this permissions is required to create pages with this page type
472
$table->addInt("advanced", 10, true, false, 0);//flag, if page type is only shown in expert (advanced) mode
473
$table->addVarchar("owner", 255, true, "system");
474
$table->addInt("order", 10, true, false, 10);//order in admin area on page creation selection
475
$table->addInt("activated", 10, true, false, 1);
476
477
//add keys to table
478
$table->addPrimaryKey("page_type");
479
$table->addIndex("advanced");
480
$table->addIndex("activated");
481
482
//create or upgrade table
483
$table->upgrade();
484
485
echo "Finished!<br />";
486
487
/**
488
 * table menu_names
489
 *
490
 * Package: com.jukusoft.cms.menu
491
 */
492
493
echo "Create / Upgrade table <b>menu_names</b>...<br />";
494
495
//create or upgrade test table
496
$table = new DBTable("menu_names", Database::getInstance());
497
$table->setEngine("InnoDB");
498
$table->setCharset("utf8");
499
500
//fields
501
$table->addInt("menuID", 10, true, true);
502
$table->addVarchar("title", 255, true);
503
$table->addInt("editable", 10, true, false, 1);
504
$table->addVarchar("unique_name", 255, true);
505
$table->addInt("activated", 10, true, false, 1);
506
507
//add keys to table
508
$table->addPrimaryKey("menuID");
509
$table->addUnique("unique_name");
510
$table->addIndex("activated");
511
512
//create or upgrade table
513
$table->upgrade();
514
515
echo "Finished!<br />";
516
517
/**
518
 * table menu
519
 *
520
 * Package: com.jukusoft.cms.menu
521
 */
522
523
echo "Create / Upgrade table <b>menu</b>...<br />";
524
525
//create or upgrade test table
526
$table = new DBTable("menu", Database::getInstance());
527
$table->setEngine("InnoDB");
528
$table->setCharset("utf8");
529
530
//fields
531
$table->addInt("id", 10, true, true);
532
$table->addInt("menuID", 10, true, false);
533
$table->addVarchar("title", 255, true);
534
$table->addVarchar("url", 600, true);
535
$table->addVarchar("type", 255, true, "page");//page / link / url / external_link / js_link
536
$table->addVarchar("icon", 255, true, "none");
537
$table->addVarchar("permissions", 600, true, "all");
538
$table->addInt("login_required", 10, true, false, 0);
539
$table->addInt("parent", 10, true, false, -1);
540
$table->addVarchar("unique_name", 255, false, "");
541
$table->addVarchar("extensions", 255, true, "none");//for example: private messages
542
$table->addVarchar("owner", 255, true, "user");
543
$table->addInt("order", 10, true, false, 10);
544
$table->addInt("activated", 10, true, false, 1);
545
546
//add keys to table
547
$table->addPrimaryKey("id");
548
$table->addUnique("unique_name");
549
$table->addIndex("menuID");
550
$table->addIndex("order");
551
$table->addIndex("activated");
552
553
//create or upgrade table
554
$table->upgrade();
555
556
echo "Finished!<br />";
557
558
/**
559
 * table user
560
 *
561
 * Package: com.jukusoft.cms.user
562
 */
563
564
echo "Create / Upgrade table <b>user</b>...<br />";
565
566
//create or upgrade test table
567
$table = new DBTable("user", Database::getInstance());
568
$table->setEngine("InnoDB");
569
$table->setCharset("utf8");
570
571
//fields
572
$table->addInt("userID", 10, true, true);
573
$table->addVarchar("username", 255, true);
574
$table->addVarchar("password", 255, true);
575
$table->addVarchar("salt", 255, true);
576
$table->addVarchar("mail", 255, true);
577
$table->addVarchar("ip", 255, true);
578
$table->addInt("main_group", 10, true, false, "2");
579
$table->addVarchar("specific_title", 255, true, "none");
580
$table->addInt("online", 10, true, false, "0");
581
$table->addTimestamp("last_online", true, "0000-00-00 00:00:00");
582
$table->addVarchar("authentificator", 255, true, "LocalAuthentificator");
583
$table->addVarchar("owner", 255, true, "system");
584
$table->addTimestamp("registered", true, "CURRENT_TIMESTAMP");
585
$table->addInt("activated", 10, true, false, 1);
586
587
//add keys to table
588
$table->addPrimaryKey("userID");
589
$table->addUnique("username");
590
$table->addIndex("mail");
591
$table->addIndex("activated");
592
593
//create or upgrade table
594
$table->upgrade();
595
596
echo "Finished!<br />";
597
598
/**
599
 * table groups
600
 *
601
 * Package: com.jukusoft.cms.groups
602
 */
603
604
echo "Create / Upgrade table <b>groups</b>...<br />";
605
606
//create or upgrade test table
607
$table = new DBTable("groups", Database::getInstance());
608
$table->setEngine("InnoDB");
609
$table->setCharset("utf8");
610
611
//fields
612
$table->addInt("groupID", 10, true, true);
613
$table->addVarchar("name", 255, true);
614
$table->addText("description", true);
615
$table->addVarchar("color", 50, true, "#0066ff");
616
$table->addVarchar("rank_title", 255, true, "none");
617
$table->addVarchar("rank_image", 255, true, "none");
618
$table->addInt("auto_assign_regist", 10, true, false, "0");//flag, if group is automatically assigned to registered users
619
$table->addInt("system_group", 10, true, false, "0");
620
$table->addInt("show", 10, true, false, "1");//show group name on index page
621
$table->addInt("activated", 10, true, false, "1");
622
623
//https://www.w3schools.com/colors/colors_picker.asp
624
625
//add keys to table
626
$table->addPrimaryKey("groupID");
627
$table->addIndex("auto_assign_regist");
628
$table->addIndex("activated");
629
630
//create or upgrade table
631
$table->upgrade();
632
633
echo "Finished!<br />";
634
635
/**
636
 * table group_members
637
 *
638
 * Package: com.jukusoft.cms.groups
639
 */
640
641
echo "Create / Upgrade table <b>group_members</b>...<br />";
642
643
//create or upgrade test table
644
$table = new DBTable("group_members", Database::getInstance());
645
$table->setEngine("InnoDB");
646
$table->setCharset("utf8");
647
648
//fields
649
$table->addInt("groupID", 10, true, false);
650
$table->addInt("userID", 10, true, false);
651
$table->addInt("group_leader", 10, true, false, "0");
652
$table->addInt("activated", 10, false, false, "1");
653
654
//https://www.w3schools.com/colors/colors_picker.asp
655
656
//add keys to table
657
$table->addPrimaryKey(array("groupID", "userID"));
658
$table->addIndex("groupID");
659
$table->addIndex("userID");
660
$table->addIndex("group_leader");
661
$table->addIndex("activated");
662
663
//create or upgrade table
664
$table->upgrade();
665
666
echo "Finished!<br />";
667
668
/**
669
 * table css_files
670
 *
671
 * Package: com.jukusoft.cms.cssbuilder
672
 */
673
674
echo "Create / Upgrade table <b>css_files</b>...<br />";
675
676
//create or upgrade test table
677
$table = new DBTable("css_files", Database::getInstance());
678
$table->setEngine("InnoDB");
679
$table->setCharset("utf8");
680
681
//fields
682
$table->addVarchar("style", 255, true);
683
$table->addVarchar("css_file", 255, true);
684
$table->addVarchar("media", 255, true, "ALL");
685
$table->addVarchar("style_json_name", 255, true, "header");
686
$table->addInt("activated", 10, true, false, 1);
687
688
//https://www.w3schools.com/colors/colors_picker.asp
689
690
//add keys to table
691
$table->addPrimaryKey(array("style", "css_file"));
692
$table->addIndex("css_file");
693
$table->addIndex("activated");
694
695
//create or upgrade table
696
$table->upgrade();
697
698
echo "Finished!<br />";
699
700
/**
701
 * table js_files
702
 *
703
 * Package: com.jukusoft.cms.jsbuilder
704
 */
705
706
echo "Create / Upgrade table <b>js_files</b>...<br />";
707
708
//create or upgrade test table
709
$table = new DBTable("js_files", Database::getInstance());
710
$table->setEngine("InnoDB");
711
$table->setCharset("utf8");
712
713
//fields
714
$table->addVarchar("style", 255, true);
715
$table->addVarchar("js_file", 255, true);
716
$table->addVarchar("media", 255, true, "ALL");
717
$table->addVarchar("position", 255, true, "FOOTER");
718
$table->addInt("activated", 10, true, false, 1);
719
720
//https://www.w3schools.com/colors/colors_picker.asp
721
722
//add keys to table
723
$table->addPrimaryKey(array("style", "js_file"));
724
$table->addIndex("js_file");
725
$table->addIndex("activated");
726
727
//create or upgrade table
728
$table->upgrade();
729
730
echo "Finished!<br />";
731
732
/**
733
 * table permission_category
734
 *
735
 * Package: com.jukusoft.cms.permissions
736
 */
737
738
echo "Create / Upgrade table <b>permission_category</b>...<br />";
739
740
//create or upgrade test table
741
$table = new DBTable("permission_category", Database::getInstance());
742
$table->setEngine("InnoDB");
743
$table->setCharset("utf8");
744
745
//fields
746
$table->addVarchar("category", 255, true);
747
$table->addVarchar("title", 255, true);
748
$table->addVarchar("area", 255, true, "global");
749
$table->addInt("show", 10, true, false, 1);
750
$table->addInt("order", 10, true, false, 100);
751
$table->addInt("activated", 10, false, false, 1);
752
753
//https://www.w3schools.com/colors/colors_picker.asp
754
755
//add keys to table
756
$table->addPrimaryKey("category");
757
$table->addIndex("area");
758
$table->addIndex("order");
759
$table->addIndex("activated");
760
761
//create or upgrade table
762
$table->upgrade();
763
764
echo "Finished!<br />";
765
766
/**
767
 * table permissions
768
 *
769
 * Package: com.jukusoft.cms.permissions
770
 */
771
772
echo "Create / Upgrade table <b>permissions</b>...<br />";
773
774
//create or upgrade test table
775
$table = new DBTable("permissions", Database::getInstance());
776
$table->setEngine("InnoDB");
777
$table->setCharset("utf8");
778
779
//fields
780
$table->addVarchar("token", 255, true);
781
$table->addVarchar("title", 255, true);
782
$table->addVarchar("description", 600, true);
783
$table->addVarchar("category", 255, true, "general");
784
$table->addVarchar("owner", 255, true, "system");
785
$table->addInt("show", 10, true, false, 1);//flag, if permission is shown on permissions page
786
$table->addInt("order", 10, true, false, 100);
787
$table->addInt("activated", 10, true, false, 1);
788
789
//add keys to table
790
$table->addPrimaryKey("token");
791
$table->addIndex("category");
792
$table->addIndex("order");
793
$table->addIndex("activated");
794
795
//create or upgrade table
796
$table->upgrade();
797
798
echo "Finished!<br />";
799
800
/**
801
 * table group_rights
802
 *
803
 * Package: com.jukusoft.cms.permissions
804
 */
805
806
echo "Create / Upgrade table <b>group_rights</b>...<br />";
807
808
//create or upgrade test table
809
$table = new DBTable("group_rights", Database::getInstance());
810
$table->setEngine("InnoDB");
811
$table->setCharset("utf8");
812
813
//fields
814
$table->addInt("groupID", 10, true, false);
815
$table->addVarchar("token", 255, true);
816
$table->addInt("value", 10, true, false);
817
818
//add keys to table
819
$table->addPrimaryKey(array("groupID", "token"));
820
821
//create or upgrade table
822
$table->upgrade();
823
824
echo "Finished!<br />";
825
826
/**
827
 * table user_rights
828
 *
829
 * Package: com.jukusoft.cms.permissions
830
 */
831
832
echo "Create / Upgrade table <b>user_rights</b>...<br />";
833
834
//create or upgrade test table
835
$table = new DBTable("user_rights", Database::getInstance());
836
$table->setEngine("InnoDB");
837
$table->setCharset("utf8");
838
839
//fields
840
$table->addInt("userID", 10, true, false);
841
$table->addVarchar("token", 255, true);
842
$table->addInt("value", 10, true, false);
843
844
//add keys to table
845
$table->addPrimaryKey(array("userID", "token"));
846
847
//create or upgrade table
848
$table->upgrade();
849
850
echo "Finished!<br />";
851
852
/**
853
 * table page_rights
854
 *
855
 * Package: com.jukusoft.cms.page
856
 */
857
858
echo "Create / Upgrade table <b>page_rights</b>...<br />";
859
860
//create or upgrade test table
861
$table = new DBTable("page_rights", Database::getInstance());
862
$table->setEngine("InnoDB");
863
$table->setCharset("utf8");
864
865
//fields
866
$table->addInt("groupID", 10, true, false);
867
$table->addInt("pageID", 10, true, false);
868
$table->addVarchar("token", 255, true);
869
$table->addInt("value", 10, true, false);
870
871
//add keys to table
872
$table->addPrimaryKey(array("groupID", "pageID", "token"));
873
874
//create or upgrade table
875
$table->upgrade();
876
877
echo "Finished!<br />";
878
879
/**
880
 * table page_user_rights
881
 *
882
 * Package: com.jukusoft.cms.page
883
 */
884
885
echo "Create / Upgrade table <b>page_user_rights</b>...<br />";
886
887
//create or upgrade test table
888
$table = new DBTable("page_user_rights", Database::getInstance());
889
$table->setEngine("InnoDB");
890
$table->setCharset("utf8");
891
892
//fields
893
$table->addInt("userID", 10, true, false);
894
$table->addInt("pageID", 10, true, false);
895
$table->addVarchar("token", 255, true);
896
$table->addInt("value", 10, true, false);
897
898
//add keys to table
899
$table->addPrimaryKey(array("userID", "pageID", "token"));
900
901
//create or upgrade table
902
$table->upgrade();
903
904
echo "Finished!<br />";
905
906
/**
907
 * table register_mail_verification
908
 *
909
 * Package: com.jukusoft.cms.user
910
 */
911
912
echo "Create / Upgrade table <b>register_mail_verification</b>...<br />";
913
914
//create or upgrade test table
915
$table = new DBTable("register_mail_verification", Database::getInstance());
916
$table->setEngine("InnoDB");
917
$table->setCharset("utf8");
918
919
//fields
920
$table->addInt("userID", 10, true, false);
921
$table->addVarchar("token", 255, true);
922
923
//add keys to table
924
$table->addPrimaryKey("userID");
925
$table->addUnique("token");
926
927
//create or upgrade table
928
$table->upgrade();
929
930
echo "Finished!<br />";
931
932
/**
933
 * table installed_plugins
934
 *
935
 * Package: com.jukusoft.cms.plugin
936
 */
937
938
echo "Create / Upgrade table <b>plugins</b>...<br />";
939
940
//create or upgrade test table
941
$table = new DBTable("plugins", Database::getInstance());
942
$table->setEngine("InnoDB");
943
$table->setCharset("utf8");
944
945
//fields
946
$table->addVarchar("name", 255, true);//directory name of plugin
947
$table->addVarchar("version", 255, true, "1.0.0");//installed version of plugin
948
//$table->addInt("build", 10, true, false, 1);//optional: build number of plugin
949
$table->addInt("installed", 10, true, false, 1);//flag, if plugin is installed
950
$table->addInt("activated", 10, true, false, 1);//flag, if plugin is activated
951
952
//add keys to table
953
$table->addPrimaryKey("name");
954
$table->addIndex("installed");
955
$table->addIndex("activated");
956
957
//create or upgrade table
958
$table->upgrade();
959
960
echo "Finished!<br />";
961
962
/**
963
 * table plugin_installer_plugins
964
 *
965
 * Package: com.jukusoft.cms.plugin
966
 */
967
968
echo "Create / Upgrade table <b>plugin_installer_plugins</b>...<br />";
969
970
//create or upgrade test table
971
$table = new DBTable("plugin_installer_plugins", Database::getInstance());
972
$table->setEngine("InnoDB");
973
$table->setCharset("utf8");
974
975
//fields
976
$table->addVarchar("class_name", 255, true);//directory name of plugin
977
$table->addVarchar("path", 600, true);
978
979
//add keys to table
980
$table->addPrimaryKey("class_name");
981
982
//create or upgrade table
983
$table->upgrade();
984
985
echo "Finished!<br />";
986
987
/**
988
 * table tasks
989
 *
990
 * Package: com.jukusoft.cms.tasks
991
 */
992
993
echo "Create / Upgrade table <b>tasks</b>...<br />";
994
995
//create or upgrade test table
996
$table = new DBTable("tasks", Database::getInstance());
997
$table->setEngine("InnoDB");
998
$table->setCharset("utf8");
999
1000
//fields
1001
$table->addInt("id", 10, true, true);
1002
$table->addVarchar("title", 255, true);
1003
$table->addVarchar("unique_name", 255, true, "");//unique name, so plugins or upgrade can find task easier
1004
$table->addEnum("type", array("FILE", "FUNCTION", "CLASS_STATIC_METHOD", ""), true);
1005
$table->addVarchar("type_params", 255, false, "NULL");
1006
$table->addText("params", true);
1007
$table->addVarchar("owner", 255, true, "system");
1008
$table->addInt("delete_after_execution", 10, true, false, 0);
1009
$table->addInt("interval", 10, true, false, 60);
1010
$table->addTimestamp("last_execution", true, "0000-00-00 00:00:00");
1011
$table->addInt("activated", 10, true, false, 1);
1012
1013
//add keys to table
1014
$table->addPrimaryKey("id");
1015
$table->addUnique("unique_name");
1016
$table->addIndex("last_execution");
1017
$table->addIndex("activated");
1018
1019
//create or upgrade table
1020
$table->upgrade();
1021
1022
echo "Finished!<br />";
1023
1024
/**
1025
 * table preferences
1026
 *
1027
 * Package: com.jukusoft.cms.preferences
1028
 */
1029
1030
echo "Create / Upgrade table <b>preferences</b>...<br />";
1031
1032
//create or upgrade test table
1033
$table = new DBTable("preferences", Database::getInstance());
1034
$table->setEngine("InnoDB");
1035
$table->setCharset("utf8");
1036
1037
//fields
1038
$table->addVarchar("key", 255, true);
1039
$table->addVarchar("area", 255, true);
1040
$table->addText("value");
1041
1042
//add keys to table
1043
$table->addPrimaryKey(array("key", "area"));
1044
1045
//create or upgrade table
1046
$table->upgrade();
1047
1048
echo "Finished!<br />";
1049
1050
/**
1051
 * table api_apps
1052
 *
1053
 * Package: com.jukusoft.cms.api
1054
 */
1055
1056
echo "Create / Upgrade table <b>api_apps</b>...<br />";
1057
1058
//create or upgrade test table
1059
$table = new DBTable("api_apps", Database::getInstance());
1060
$table->setEngine("InnoDB");
1061
$table->setCharset("utf8");
1062
1063
//fields
1064
$table->addInt("app_id", 10, true, true);
1065
$table->addVarchar("app_name", 255, true);
1066
1067
//add keys to table
1068
$table->addPrimaryKey(array("app_id"));
1069
$table->addUnique("app_name");
1070
1071
//create or upgrade table
1072
$table->upgrade();
1073
1074
echo "Finished!<br />";
1075
1076
/**
1077
 * table api_keys
1078
 *
1079
 * Package: com.jukusoft.cms.api
1080
 */
1081
1082
echo "Create / Upgrade table <b>api_keys</b>...<br />";
1083
1084
//create or upgrade test table
1085
$table = new DBTable("api_keys", Database::getInstance());
1086
$table->setEngine("InnoDB");
1087
$table->setCharset("utf8");
1088
1089
//fields
1090
$table->addInt("key_id", 10, true, true);
1091
$table->addVarchar("secret", 255, true);
1092
$table->addInt("app_id", 10, true, false);
1093
1094
//add keys to table
1095
$table->addPrimaryKey(array("key_id"));
1096
$table->addIndex("app_id");
1097
1098
//create or upgrade table
1099
$table->upgrade();
1100
1101
echo "Finished!<br />";
1102
1103
/**
1104
 * table api_oauth
1105
 *
1106
 * Package: com.jukusoft.cms.api
1107
 */
1108
1109
echo "Create / Upgrade table <b>api_oauth</b>...<br />";
1110
1111
//create or upgrade test table
1112
$table = new DBTable("api_oauth", Database::getInstance());
1113
$table->setEngine("InnoDB");
1114
$table->setCharset("utf8");
1115
1116
//fields
1117
$table->addVarchar("secret_key", 255, true);
1118
$table->addInt("userID", 10, true, false);
1119
$table->addTimestamp("created", true, "CURRENT_TIMESTAMP", false);//to check, if secret key is valide
1120
$table->addTimestamp("expires", true, "0000-00-00 00:00:00", false);
1121
1122
//add keys to table
1123
$table->addPrimaryKey(array("secret_key"));
1124
1125
//create or upgrade table
1126
$table->upgrade();
1127
1128
echo "Finished!<br />";
1129
1130
/**
1131
 * table widget_types
1132
 *
1133
 * Package: com.jukusoft.cms.widgets
1134
 */
1135
1136
echo "Create / Upgrade table <b>widget_types</b>...<br />";
1137
1138
//create or upgrade test table
1139
$table = new DBTable("widget_types", Database::getInstance());
1140
$table->setEngine("InnoDB");
1141
$table->setCharset("utf8");
1142
1143
//fields
1144
$table->addInt("id", 10, true, true);
1145
$table->addVarchar("name", 255, true);
1146
$table->addVarchar("description", 600, true, "");
1147
$table->addVarchar("class_name", 255, true);
1148
$table->addInt("editable", 10, true, false, 1);//flag, if widget type is editable (this means added widgets with this type can be edited)
1149
$table->addVarchar("owner", 255, true, "system");
1150
1151
//add keys to table
1152
$table->addPrimaryKey(array("id"));
1153
$table->addUnique("class_name");
1154
1155
//create or upgrade table
1156
$table->upgrade();
1157
1158
echo "Finished!<br />";
1159
1160
/**
1161
 * table sidebars
1162
 *
1163
 * Package: com.jukusoft.cms.sidebar
1164
 */
1165
1166
echo "Create / Upgrade table <b>sidebars</b>...<br />";
1167
1168
//create or upgrade test table
1169
$table = new DBTable("sidebars", Database::getInstance());
1170
$table->setEngine("InnoDB");
1171
$table->setCharset("utf8");
1172
1173
//fields
1174
$table->addInt("sidebar_id", 10, true, true);
1175
$table->addVarchar("unique_name", 255, true);
1176
$table->addVarchar("title", 255, true, "");
1177
$table->addInt("deletable", 10, true, false, 1);
1178
1179
//add keys to table
1180
$table->addPrimaryKey(array("sidebar_id"));
1181
$table->addUnique("unique_name");
1182
1183
//create or upgrade table
1184
$table->upgrade();
1185
1186
echo "Finished!<br />";
1187
1188
/**
1189
 * table sidebar_widgets
1190
 *
1191
 * Package: com.jukusoft.cms.sidebar
1192
 */
1193
1194
echo "Create / Upgrade table <b>sidebar_widgets</b>...<br />";
1195
1196
//create or upgrade test table
1197
$table = new DBTable("sidebar_widgets", Database::getInstance());
1198
$table->setEngine("InnoDB");
1199
$table->setCharset("utf8");
1200
1201
//fields
1202
$table->addInt("id", 10, true, true);
1203
$table->addInt("sidebar_id", 10, true, false);
1204
$table->addVarchar("title", 255, true, "");
1205
$table->addText("content", true, "");
1206
$table->addVarchar("class_name", 255, true, "");
1207
$table->addText("widget_params", true);//json encoded string, e.q. "{}"
1208
$table->addVarchar("css_id", 255, true, "");
1209
$table->addVarchar("css_class", 255, true, "");
1210
$table->addVarchar("before_widget", 600, true, "");
1211
$table->addVarchar("after_widget", 600, true, "");
1212
//$table->addVarchar("before_title", 600, true, "");
1213
//$table->addVarchar("after_title", 600, true, "");
1214
$table->addVarchar("unique_name", 255, true);
1215
$table->addInt("order", 10, true, false, 10);
1216
1217
//add keys to table
1218
$table->addPrimaryKey(array("id"));
1219
$table->addUnique("unique_name");
1220
$table->addIndex("sidebar_id");
1221
1222
//create or upgrade table
1223
$table->upgrade();
1224
1225
echo "Finished!<br />";
1226
1227
//create default wildcard domain, if absent
1228
Domain::createWildcardDomain();
1229
1230
echo "Create folder...<br />";
1231
1232
echo "Create default (supported) languages...<br />";
1233
1234
//add supported languages
1235
Lang::addLangOrUpdate("de", "German");
1236
Lang::addLangOrUpdate("en", "English");
1237
1238
echo "Create default sidebars...<br />";
1239
1240
Sidebar::create("Left sidebar", "sidebar_left", false);
1241
Sidebar::create("Right sidebar", "sidebar_right", false);
1242
1243
echo "Create default global setting categories...<br />";
1244
1245
SettingsCategory::createIfAbsent("general", "General", 1, "system");
1246
SettingsCategory::createIfAbsent("sidebar", "Sidebar", 2, "system");
1247
SettingsCategory::createIfAbsent("mail", "Mail", 15, "system");
1248
SettingsCategory::createIfAbsent("user", "User", 16, "system");
1249
SettingsCategory::createIfAbsent("api", "API", 17, "system");
1250
SettingsCategory::createIfAbsent("logging", "Logging", 18, "system");
1251
SettingsCategory::createIfAbsent("tools", "Tools", 19, "system");
1252
SettingsCategory::createIfAbsent("tasks", "Tasks", 20, "system");
1253
1254
echo "Create default global settings...<br />";
1255
1256
//create or update default settings (value will be only set, if key doesnt exists)
1257
Settings::create("default_lang", "de", "Default Language", "Default (fallback) language, if no other languages are supported", "system", "general", "DataType_LangChooser");
1258
Settings::create("default_style_name", "texturedblue", "Default Style", "Default (fallback) style name, which will be used, if no other design was set by style rules.", "system", "general", "DataType_StyleChooser");
1259
Settings::create("default_mobile_style_name", "texturedblue", "Default mobile Style", "Like default style name, but for mobiledevices", "system", "general", "DataType_StyleChooser");
1260
Settings::create("guest_userid", -1, "Guest UserID", "UserID of not-logged-in users (default: -1).", "system", "general", "DataType_Integer", array("min" => -1));
1261
Settings::create("guest_username", "Guest", "Guest Username", "Username of not-logged-in users (default: Guest).", "system", "general", "DataType_Username");
1262
Settings::create("online_interval", 5, "Online Interval", "Interval in minues, how long a user is set as online (since last page request). IMPORTANT: This is independent from login interval!", "system", "general", "DataType_Integer");
1263
Settings::create("x_frame_options", "DENY", "X-Frame-Options header value (none = dont set header).", "values: DENY, SAMEORIGIN, ALLOW-FROM https://example.com/, none", "system", "security", "DataType_String");
1264
Settings::create("login_page","login", "Alias of Login Page (incl. directory, if necessary)", "Alias of Login Page (incl. directory, if necessary). Default: login", "system", "general", "DataType_String");
1265
Settings::create("logout_page", "logout", "Alias of Logout Page (incl. directory, if necessary)", "Alias of Logout Page (incl. directory, if necessary). Default: logout", "system", "general", "DataType_String");
1266
//Settings::create("base_dir", "/", "Base directory", "Base directory (if this CMS is installed in root directory, the right option is '/', but if it is installed in a sub directory, the right option is '/sub-dir/'). Default: /", "system", "general");
1267
Settings::create("css_cache_strategy", "expires_header", "CSS Browser Cache Strategy", "CSS Browser Cache Strategy, values: expires_header, etag_header, none", "system", "general", "DataType_SelectBox", array("expires_header", "etag_header", "none"));
1268
Settings::create("css_cache_expires_header_ttl", "31536000", "CSS Expires Header Seconds to cache", "Seconds to cache (on client browser). Only used, if cache strategy 'expired_header' is used! Default: 31536000 seconds (1 year)", "system", "general", "DataType_Integer");
1269
Settings::create("js_cache_strategy", "expires_header", "JS Browser Cache Strategy", "JS Browser Cache Strategy, values: expires_header, etag_header, none", "system", "general", "DataType_SelectBox", array("expires_header", "etag_header", "none"));
1270
Settings::create("js_cache_expires_header_ttl", "31536000", "JS Expires Header Seconds to cache", "Seconds to cache (on client browser). Only used, if cache strategy 'expired_header' is used! Default: 31536000 seconds (1 year)", "system", "general", "DataType_Integer");
1271
Settings::create("title_praefix", "", "Title Praefix", "Title Praefix", "system", "general", "DataType_String");
1272
Settings::create("title_suffix", "", "Title Suffix", "Title Suffix", "system", "general", "DataType_String");
1273
Settings::create("copyright", "<strong>Copyright &copy; 2018 <a href=\"http://jukusoft.com\">JuKuSoft.com</a></strong>, All Rights Reserved.", "Copyright Notice on page", "Copyright notice on every page", "system", "general", "DataType_HTML");
1274
Settings::create("website_name", "" . DomainUtils::getDomain(), "Website name", "Name of your website, e.q. used for mail templates", "system", "general", "DataType_String");
1275
1276
Settings::create("gzip_compression", true, "GZip compression enabled", "GZip compression enabled", "system", "general", "DataType_Boolean");
1277
Settings::create("session_ttl", 3600, "Session TTL", "Session Time-To-Live in seconds, default: 3600 seconds", "system", "general", "DataType_Integer", array("unit" => "seconds"));
1278
1279
//maintenance mode
1280
Settings::create("maintenance_mode_enabled", false, "Maintenance Mode enabled (boolean)", "Maintenance Mode enabled (boolean), Default: false", "system", "general", "DataType_Boolean");
1281
Settings::create("maintenance_text", "This domain is currently under scheduled maintenance mode. Sorry for the inconvenience! Look in a few minutes over again!", "Maintenance Text", "Text which is shown, if maintenance mode is enabled", "system", "general", "DataType_HTML");
1282
1283
//external tools
1284
Settings::create("phpmyadmin_link", "#", "Link to PhpMyAdmin", "Link to PhpMyAdmin", "system", "tools", "DataType_URL");
1285
Settings::create("webmail_link", "#", "Link to Webmail", "Link to Webmail", "system", "tools", "DataType_URL");
1286
1287
//send mail
1288
Settings::create("send_mails_enabled", true, "Enable send mails from CMS", "Enable send mails from CMS - if disabled no mails can be sended! If deactivated, it can influence other features like registration.", "system", "mail", "DataType_Boolean");
1289
Settings::create("sendmail_method", "PHPMail", "Method for sending mails", "Method for sending mails (class name of send mail implementation)", "system", "mail", "DataType_SelectBox", array("PHPMail", "SMTPMail"));
1290
Settings::create("mail_sender_address", "none", "Sender mail address", "sender mail address, e.q. [email protected]", "system", "mail", "DataType_Mail");
1291
Settings::create("mail_sender_name", "", "Sender name", "Name of mail sender, e.q. John Doe", "system", "mail", "DataType_String");
1292
Settings::create("mail_reply_to", "", "Reply-to mail address", "Reply-to mail address, e.q. [email protected]", "system", "mail", "DataType_Mail");
1293
Settings::create("mail_signature", "", "Mail Signature", "This text will be added as footer on all mails.", "system", "mail", "DataType_Text");
1294
Settings::create("mail_default_charset", "utf-8", "Default mail charset", "Default mail charset, default: utf-8", "system", "mail", "DataType_String");
1295
1296
//registration
1297
Settings::create("registration_enabled", false, "Registration enabled", "Registration enabled", "system", "general", "DataType_Boolean");
1298
Settings::create("agb_page", "agb", "Terms of use Page", "Terms of use page", "system", "general", "DataType_String");
1299
Settings::create("username_min_length", 4, "Minimal length (characters) of allowed username", "Minimal length (characters) of allowed username", "general", "general", "DataType_Integer");
1300
Settings::create("username_max_length", 20, "Maximal length (characters) of allowed usernames", "Maximal length (characters) of allowed usernames", "general", "general", "DataType_Integer");
1301
Settings::create("username_regex", "a-zA-Z0-9\.\-", "Username Regex", "Allowed characters of usernames (regex)", "system", "general", "DataType_String");
1302
Settings::create("password_min_length", 6, "Minimal password length", "Minimal password length, default: 8", "system", "general", "DataType_Integer");
1303
Settings::create("password_max_length", 64, "Maximal password length", "Maximal password length, default: 8", "system", "general", "DataType_Integer");
1304
Settings::create("register_activation_method", "auto", "Register Activation Method", "Activation method for new user accounts, Default: auto (which means, that users are automatically activated)", "system", "general", "DataType_SelectBox", array("auto", "mail_verification", "manual_verification"));
1305
Settings::create("default_main_group", 2, "Default main group ID", "ID of default main group, Default: 2 (registered users)", "system", "general", "DataType_Integer");
1306
1307
//captcha
1308
Settings::create("captcha_enabled", true, "Captcha enabled", "Option, if captcha is enabled on forms", "system", "general", "DataType_Boolean");
1309
Settings::create("captcha_class_name", "ReCaptcha", "Captcha Classname", "Captcha Classname", "system", "general", "DataType_String");
1310
Settings::create("recaptcha_website_key", "", "reCAPTCHA website key", "reCAPTCHA website key, provided by google", "system", "general", "DataType_String");
1311
Settings::create("recaptcha_secret_key", "", "reCAPTCHA secret key", "reCAPTCHA secret key, provided by google", "system", "general", "DataType_String");
1312
1313
//cronjob
1314
Settings::create("cronjob_enabled", true, "Cronjob enabled", "Option if cronjob is enabled", "system", "tasks", "DataType_Boolean");
1315
Settings::create("cronjob_auth_key", "", "Cronjob Auth Key", "Only set this key, if you want, that only a restricted source can call cronjob.php file.", "owner", "tasks", "DataType_String");
1316
1317
//menuID
1318
Settings::create("menu_plugin_settings_id", -1, "id of plugin settings menu", "id of plugin settings menu - Dont change this value manually!", "system", "hidden", "DataType_Integer", array(), false);
1319
1320
//user / ldap authentification
1321
Settings::create("default_authentificator", "LocalAuthentificator", "Authentificator Class", "Classname of Authentificator method", "system", "user", "DataType_String", array(""), true);
1322
Settings::create("user_default_title", "Registered User", "Default User Title", "default user title, shown on pages", "system", "user", "DataType_String", array(), true);
1323
1324
//oauth
1325
Settings::create("oauth_key_length", 255, "oAuth key length", "Length of oauth key in characters", "system", "api", "DataType_Integer", array("unit" => "characters"), true);
1326
Settings::create("oauth_expire_seconds", 86400, "oAuth key Validity", "oAuth key Validity in seconds", "system", "api", "DataType_Integer", array("unit" => "seconds"), true);
1327
1328
//logging
1329
Settings::create("logging_provider", "EmptyLogProvider", "Class name of logging provider", "full class name of logging provider", "system", "logging", "DataType_String", array(), false);
1330
1331
//sidebar
1332
Settings::create("default_sidebar_left", 1, "ID of default left sidebar", "ID of default left sidebar", "system", "sidebar", "DataType_SidebarChooser", array(), false);
1333
Settings::create("default_sidebar_right", 2, "ID of default right sidebar", "ID of default right sidebar", "system", "sidebar", "DataType_SidebarChooser", array(), false);
1334
1335
$main_menuID = -1;
1336
$local_menuID = -1;
1337
$admin_menuID = -1;
1338
1339
//get main menuID
1340
if (!Settings::contains("main_menuID")) {
1341
	//create menu_names if absent
1342
	$main_menuID = Menu::createMenuName("Main Menu", "main_menu");
1343
1344
	//set setting
1345
	Settings::create("main_menuID", $main_menuID, "Main MenuID", "id of main menu (in menu area)", "system", "general", "DataType_MenuSelector", "", true, "none", "none", 1);
1346
} else {
1347
	$main_menuID = Settings::get("main_menuID");
1348
}
1349
1350
//get admin area menuID
1351
if (!Settings::contains("admin_menuID")) {
1352
	//create menu_names if absent
1353
	$admin_menuID = Menu::createMenuName("Admin Menu", "admin_menu");
1354
1355
	//set setting
1356
	Settings::create("admin_menuID", $admin_menuID, "Admin MenuID", "id of admin menu (in admin area)", "system", "general", "DataType_MenuSelector", "", true, "none", "none", 2);
1357
} else {
1358
	$admin_menuID = Settings::get("admin_menuID");
1359
}
1360
1361
//get local menuID
1362
if (!Settings::contains("local_menuID")) {
1363
	//create menu_names if absent
1364
	$local_menuID = Menu::createMenuName("Default Local Menu", "local_menu");
1365
1366
	//set setting
1367
	Settings::create("local_menuID", $local_menuID, "Default Local MenuID", "id of default local menu (in menu area)", "system", "general", "DataType_MenuSelector", "", true, "none", "none", 3);
1368
} else {
1369
	$local_menuID = Settings::get("local_menuID");
1370
}
1371
1372
//create default folders, if absent
1373
Folder::createFolderIfAbsent("/", false);
1374
Folder::createFolderIfAbsent("/admin/", true, array("can_access_admin_area"), $admin_menuID, -1);
1375
1376
echo "Create default menu if absent...<br />";
1377
1378
//create menus if absent
1379
Menu::createMenu(1, $main_menuID, "Home", "home", -1, "home", "page", "all", false, "none", 1, "user");
1380
Menu::createMenu(2, $admin_menuID, "Dashboard", "admin/home", -1, "admin_home", "page", array("can_access_admin_area"), true, "fa fa-tachometer-alt", 1, "system");
1381
Menu::createMenu(3, $admin_menuID, "Dashboard", "admin/home", 2, "", "page", array("can_access_admin_area"), true, "fa fa-tachometer-alt", 1, "system");
1382
Menu::createMenu(4, $admin_menuID, "Settings", "admin/settings", 2, "", "page", array("can_see_global_settings"), true, "fa fa-cog", 2, "system");
1383
Menu::createMenu(5, $admin_menuID, "Website", "", 2, "", "page", "none", false, "fa fa-desktop", 3, "system");
1384
Menu::createMenu(6, $admin_menuID, "Updates", "admin/update", 2, "updates", "page", array("can_see_cms_version", "can_update_cms"), true, "fa fa-download", 4, "system");
1385
Menu::createMenu(7, $admin_menuID, "Posts", "#", -1, "posts", "no_link", array("can_see_all_pages"), true, "fa fa-list-alt", 2, "system");
1386
Menu::createMenu(8, $admin_menuID, "Pages", "admin/pages", -1, "pages", "page", array("can_see_all_pages"), true, "fa fa-file", 3, "system");
1387
Menu::createMenu(9, $admin_menuID, "All Pages", "admin/pages", 8, "all_pages", "page", array("can_see_all_pages"), true, "fa fa-list", 1, "system");
1388
Menu::createMenu(10, $admin_menuID, "Create page", "admin/create_page", 8, "create_page", "page", array("can_create_pages"), true, "fa fa-plus-circle", 2, "system");
1389
Menu::createMenu(11, $admin_menuID, "Media", "admin/media", -1, "media", "page", array("can_see_all_media", "can_upload_media"), true, "fa fa-file-image", 3, "system");
1390
Menu::createMenu(12, $admin_menuID, "All Media", "admin/media", 11, "all_media", "page", array("can_see_all_media"), true, "fa fa-file-image", 1, "system");
1391
Menu::createMenu(14, $admin_menuID, "Upload Media", "admin/media/upload", 11, "upload_media", "page", array("can_upload_media"), true, "fa fa-upload", 4, "system");
1392
Menu::createMenu(15, $admin_menuID, "Menu", "admin/menu", -1, "menu", "page", array("can_see_menus", "can_edit_menus"), true, "fa fa-anchor", 5, "system");
1393
Menu::createMenu(16, $admin_menuID, "Users", "#", -1, "admin_users", "no_link", array("can_see_all_users", "can_create_user", "can_edit_users"), true, "fa fa-users", 6, "system");
1394
1395
Menu::createMenu(17, $admin_menuID, "All Users", "admin/users", 16, "all_users", "page", array("can_see_all_users"), true, "fa fa-id-card", 1, "system");
1396
Menu::createMenu(18, $admin_menuID, "Create User", "admin/create_user", 16, "create_user", "page", array("can_create_user"), true, "fa fa-user-plus", 2, "system");
1397
Menu::createMenu(19, $admin_menuID, "Groups", "admin/groups", 16, "groups", "page", array("can_see_all_groups"), true, "fa fa-users", 3, "system");
1398
Menu::createMenu(20, $admin_menuID, "My groups", "admin/my_groups", 16, "admin_own_groups", "page", array("can_see_own_groups"), true, "fa fa-id-badge", 4, "system");
1399
Menu::createMenu(21, $admin_menuID, "My profile", "admin/profile", 16, "admin_own_profile", "page", array("can_see_own_profile", "can_edit_own_profile"), true, "fa fa-user-circle", 5, "system");
1400
Menu::createMenu(22, $admin_menuID, "Change password", "admin/change_password", 16, "admin_password", "page", array("can_edit_own_password"), true, "fa fa-key", 6, "system");
1401
1402
Menu::createMenu(25, $admin_menuID, "Design", "admin/design", -1, "design", "page", array("can_see_global_settings"), true, "fa fa-paint-brush", 7, "system");
1403
1404
Menu::createMenu(35, $admin_menuID, "Plugins", "admin/plugins", -1, "plugins", "no_link", array("can_see_installed_plugins"), true, "fa fa-cubes", 8, "system");
1405
Menu::createMenu(36, $admin_menuID, "Plugins", "admin/plugins", 35, "plugins_page", "page", array("can_see_installed_plugins"), true, "fa fa-cubes", 1, "systen");
1406
Menu::createMenu(37, $admin_menuID, "Settings", "#", 35, "plugins_settings", "no_link", array("can_see_installed_plugins"), true, "fa fa-cogs", 100, "system");
1407
1408
Settings::set("menu_plugin_settings_id", 37);
1409
1410
Menu::createMenu(45, $admin_menuID, "Tools", "#", -1, "tools", "no_link", array("none"), true, "fa fa-wrench", 9, "system");
1411
1412
Menu::createMenu(53, $admin_menuID, "phpinfo()", "admin/phpinfo", 45, "phpinfo", "page", array("can_see_phpinfo"), true, "fab fa-php", 9, "system");
1413
Menu::createMenu(54, $admin_menuID, "PhpMyAdmin", "settings:phpmyadmin_link", 45, "phpmyadmin", "dynamic_link", array("can_see_phpmyadmin_menu"), true, "fa fa-laptop", 10, "system");
1414
Menu::createMenu(55, $admin_menuID, "Webmail", "settings:webmail_link", 45, "webmail", "dynamic_link", array("can_see_webmail_menu"), true, "fa fa-envelope", 11, "system");
1415
Menu::createMenu(56, $admin_menuID, "Send Mail", "admin/sendmail", 45, "sendmail", "page", array("can_send_board_mails"), true, "fa fa-envelope-open", 12, "system");
1416
Menu::createMenu(57, $admin_menuID, "Clear Cache", "admin/clearcache", 45, "clear_cache", "page", array("can_clear_cache"), true, "fa fa-trash", 12, "system");
1417
1418
Menu::createMenu(60, $admin_menuID, "Settings", "#", -1, "settings", "no_link", array("can_see_global_settings"), true, "fa fa-cogs", 10, "system");
1419
Menu::createMenu(61, $admin_menuID, "Settings", "admin/settings", 60, "", "page", array("can_see_global_settings", "can_edit_global_settings"), true, "fa fa-cog", 1, "system");
1420
1421
Menu::createMenu(100, $main_menuID, "lang_Admin Area", "admin/home", -1, "", "page", array("can_access_admin_area"), true, "none", 2, "user");
1422
Menu::createMenu(101, $main_menuID, "lang_Login", "LOGIN_URL", -1, "login", "external_link", "not_logged_in", false, "none", 3, "user");
1423
Menu::createMenu(102, $main_menuID, "lang_Logout", "LOGOUT_URL", -1, "logout", "external_link", "all", true, "none", 100, "user");
1424
1425
//privacy policy & imprint
1426
Menu::createMenu(200, $main_menuID, "lang_Privacy Policy", "privacy-policy", -1, "privacy_policy", "page", array("none"), false, "none", 101, "system");
1427
Menu::createMenu(201, $main_menuID, "lang_Imprint", "imprint", -1, "imprint", "page", array("none"), false, "none", 102, "system");
1428
1429
echo "Create default pages if absent...<br />";
1430
1431
Page::createIfAbsent("home", "Home", "IndexPage", "Home page", "/");
1432
Page::createIfAbsent("error404", "Error 404", "Error404Page", "Error 404 - Couldn't find this page.", "/", -1, -1, -1, false, true, true, false);
1433
Page::createIfAbsent("login", "Login", "LoginPage", "", "/", -1, -1, -1, false, true, true, false);
1434
Page::createIfAbsent("logout", "Logout", "LogoutPage", "", "/", -1, -1, -1, false, true, false);
1435
Page::createIfAbsent("register", "Registration", "RegisterPage", "", "/", -1, -1, -1, false, true, false, false);
1436
1437
//only at installation process
1438
Page::createIfAbsent("privacy-policy", "lang_Privacy Policy", "HTMLPage", "Private Policy - Add privaty policy here", "/", -1, -1, -1, false, true, true, true);
1439
Page::createIfAbsent("imprint", "lang_Imprint", "HTMLPage", "Imprint - Add contact data here", "/", -1, -1, -1, false, true, true, true);
1440
1441
Page::createIfAbsent("user/verify_mail", "Mail Verification", "MailVerifyPage", "", "/user/", -1, -1, -1, false, true, false, false);
1442
1443
//create robots.txt page
1444
Page::createIfAbsent("robots.txt", "Robots.txt", "RobotsPage", "", "/", -1, -1, -1, false, true, false, false);
1445
1446
//create sitemap page
1447
Page::createIfAbsent("sitemap.xml", "Sitemap", "SitemapPage", "", "/", -1, -1, -1, false, true, false, false);
1448
1449
//create forbidden pages
1450
Page::createIfAbsent("error403", "Error 403", "Error403Page", "Error 403 - Forbidden!<br /> You dont have permissions to access this page or folder. Maybe you have to login.", "/", -1, -1, -1, false, true, true, false);
1451
1452
echo "Create admin pages if absent...<br />";
1453
Page::createIfAbsent("admin/home", "Admin Dashboard", "Admin_Dashboard", "", "/admin/", -1, -1, -1, false, true, false, false);
1454
Page::createIfAbsent("admin/plugins", "lang_Plugins", "PluginsPage", "", "/admin/", -1, -1, -1, false, true, false, false);
1455
Page::createIfAbsent("admin/plugin_installer", "lang_Plugin Installer", "PluginInstallerPage", "", "/admin/", -1, -1, -1, false, true, false, false);
1456
Page::createIfAbsent("admin/change_password", "lang_Change password", "ChangePasswordPage", "", "/admin/", -1, -1, -1, false, true, false, false);
1457
Page::createIfAbsent("admin/sendmail", "lang_Send Mail", "SendMailPage", "", "/admin/", -1, -1, -1, false, true, false, false);
1458
Page::createIfAbsent("admin/clearcache", "lang_Clear cache", "ClearCachePage", "", "/admin/", -1, -1, -1, false, true, false, false);
1459
1460
//create some tool pages
1461
Page::createIfAbsent("admin/phpinfo", "phpinfo()", "PHPInfoPage", "", "/admin/", -1, -1, -1, false, true, false, false);
1462
1463
//admin pages
1464
Page::createIfAbsent("admin/settings", "Settings", "SettingsPage", "", "/admin/", -1, -1, -1, false, true, false, false);
1465
Page::createIfAbsent("admin/pages", "Pages", "PageListPage", "", "/admin/", -1, -1, -1, false, true, false, false);
1466
Page::createIfAbsent("admin/create_page", "Create new page", "CreatePagePage", "", "/admin/", -1, -1, -1, false, true, false, false);
1467
Page::createIfAbsent("admin/edit_page", "Edit page", "PageEditPage", "", "/admin/", -1, -1, -1, false, true, false, false);
1468
1469
echo "Create default page types if absent...<br />";
1470
1471
PageType::createPageType("HTMLPage", "HTML page", false, 1);//order 1 - so show as first page type in admin area
1472
PageType::createPageType("Error404Page", "Error 404 page", true);
1473
PageType::createPageType("Error403Page", "Error 403 page", true);
1474
PageType::createPageType("IndexPage", "index page (supports extra template)", true);
1475
PageType::createPageType("LoginPage", "Login page", true);
1476
PageType::createPageType("LogoutPage", "Logout page", true);
1477
PageType::createPageType("SitemapPage", "Sitemap page", true);
1478
PageType::createPageType("ChangePasswordPage", "Change password", true);
1479
1480
echo "Create style rule for admin area if absent...<br />";
1481
StyleRules::createRuleWithPredefinedID(1, "FOLDER", "/admin/", "admin", -1, 1);
1482
1483
//create groups
1484
echo "Create default groups if absent...<br />";
1485
1486
//#0099cc
1487
Groups::createGroupIfIdAbsent(1, "Administrator", "Administrator group with full permissions", "#cc0000", true, true, false);
1488
Groups::createGroupIfIdAbsent(2, "Registered Users", "Registered users (every new user is automatically added to this group on registration process)", "#33cc33", false, true, true);
1489
Groups::createGroupIfIdAbsent(3, "Guests", "Not-logged-in users", "#669999", false, true, false);
1490
Groups::createGroupIfIdAbsent(4, "Bots", "Bots (Google bot and so on)", "#cc00ff", false, true, false);
1491
1492
//Redakteur
1493
Groups::createGroupIfIdAbsent(5, "Editor", "Editors (can create & edit every post and every page, can publish and delete pages)", "#ff9933", true, true, false);
1494
Groups::createGroupIfIdAbsent(6, "Author", "Authors (can create & edit OWN posts and OWN pages, can publish and delete OWN pages)", "#ffcc00", true, true, false);
1495
1496
echo "Assign default users to default groups...<br />";
1497
1498
Groups::addGroupToUser(1, 1, true);
1499
Groups::addGroupToUser(2, 1, true);
1500
Groups::addGroupToUser(3, -1);
1501
1502
echo "Create default permission categories...<br />";
1503
Permissions::createOrUpdateCategory("general", "General", 1);
1504
Permissions::createOrUpdateCategory("users", "Users", 2);//user permissions, like "can_create_user"
1505
Permissions::createOrUpdateCategory("groups", "Groups", 3);
1506
Permissions::createOrUpdateCategory("pages", "Pages", 4);
1507
Permissions::createOrUpdateCategory("media", "Media", 5);
1508
Permissions::createOrUpdateCategory("permissions", "Permissions", 6);
1509
Permissions::createOrUpdateCategory("plugins", "Plugins", 7);
1510
Permissions::createOrUpdateCategory("admin", "Admin", 8);
1511
1512
echo "Create default permissions...<br />";
1513
//general permissions
1514
Permissions::createPermission("can_access_admin_area", "Can access admin area", "Can access admin area", "admin", "system", 1);
1515
Permissions::createPermission("can_edit_own_password", "Can edit own password", "Can edit own password", "general", "system", 2);
1516
Permissions::createPermission("can_edit_own_mail", "Can edit his own mail address", "Can edit his own mail address", "general", 3);
1517
Permissions::createPermission("can_edit_own_profile", "Can edit own profile", "Can edit own profile (except mail & password)", "general", 4);
1518
1519
//permissions
1520
Permissions::createPermission("can_see_own_permissions", "Can see own permissions", "User can see his own permissions", "permissions", "system", 1);
1521
Permissions::createPermission("can_see_permissions", "Can see permissions of other users", "Can see permissions of other users", "permissions", "system", 2);
1522
Permissions::createPermission("can_edit_group_permissions", "Can edit group permissions", "Can edit group permissions (expect administrator group)", "permissions", "system", 3);
1523
Permissions::createPermission("can_edit_administrator_group_permissions", "Can edit administrator group permissions", "Can edit administrator group permissions", "permissions", "system", 4);//can edit permissions of group "administrator"
1524
1525
//user permissions
1526
Permissions::createPermission("can_see_all_users", "Can see all users", "Can see all users and see their private information like mail address, ip address and so on", "users", "system", 1);
1527
Permissions::createPermission("can_create_user", "Can create new user", "Can create new user", "users", "system", 2);
1528
Permissions::createPermission("can_edit_users", "Can edit users", "Can edit users", "users", "system", 3);
1529
Permissions::createPermission("can_edit_users_password", "Can edit password of users", "Can edit password of users (without super-admin with userID 1)", "users", "system", 4);
1530
1531
//group permissions
1532
Permissions::createPermission("can_see_all_groups", "Can see all groups", "Can see list with all groups", "groups", "system", 1);
1533
Permissions::createPermission("can_see_own_groups", "Can see own groups", "Can see list with own groups", "groups", "system", 2);
1534
Permissions::createPermission("can_edit_all_groups", "Can edit all groups", "Can edit all groups", "groups", "system", 3);
1535
Permissions::createPermission("can_edit_own_groups", "Can edit own groups", "Can edit own groups, where user is group leader", "groups", "system", 4);
1536
1537
//page permissions
1538
Permissions::createPermission("can_see_all_pages", "Can see all pages in admin area", "pages", "pages", "system", 1);
1539
Permissions::createPermission("can_create_pages", "Can create pages", "Can create pages", "pages", "system", 2);
1540
Permissions::createPermission("can_edit_own_pages", "Can edit own pages", "Can edit pages which was created by user", "pages", "system", 3);
1541
Permissions::createPermission("can_edit_all_pages", "Can edit all pages", "Can edit all pages, including pages which was created by other users", "pages", "system", 4);
1542
Permissions::createPermission("can_publish_own_pages", "Can publish his own pages", "Can publish his own pages", "pages", "system", 5);
1543
Permissions::createPermission("can_publish_all_pages", "Can publish all pages", "Can publish all pages, including pages which was created by other users", "pages", "system", 6);
1544
Permissions::createPermission("can_unlock_all_pages", "Can unlock all pages", "Can unlock all pages from every user", "pages", "system", 7);
1545
Permissions::createPermission("can_delete_own_pages", "Can delete own pages", "Can move pages to trash which was created by user", "pages", "system", 8);
1546
Permissions::createPermission("can_delete_all_pages", "Can delete all pages", "Can move all pages to trash, including pages which was created by other users", "pages", "system", 9);
1547
Permissions::createPermission("can_see_trash_pages", "Can see all deleted pages in trash", "Can see all deleted pages in trash", "pages", "system", 10);
1548
Permissions::createPermission("can_delete_all_pages_permanently", "Can delete all pages from trash permanently", "Can delete all pages from trash permanently, so you couldn't restore them anymore.", "pages", "system", 11);
1549
Permissions::createPermission("can_restore_trash_pages", "Can restore all pages in trash", "Can restore all pages in trash", "pages", "system", 12);
1550
Permissions::createPermission("can_change_page_owner", "Can change page owner of all pages", "Can change page owner of all pages", "pages", "system", 14);
1551
1552
//media permissions
1553
Permissions::createPermission("can_see_all_media", "Can see all media", "Can see all media files", "media", "system", 1);
1554
Permissions::createPermission("can_see_own_media", "Can see own media", "Can see own media files", "media", "system", 2);
1555
Permissions::createPermission("can_upload_media", "Can upload media", "Can upload media files", "media", "system", 3);
1556
1557
//menu permissions
1558
Permissions::createPermission("can_see_menus", "Can see menus", "Can see menus", "menu", "system", 1);
1559
Permissions::createPermission("can_edit_menus", "Can edit menus", "Can edit menus", "menu", "system", 2);
1560
1561
//plugin permissions
1562
Permissions::createPermission("can_see_installed_plugins", "Can see installed plugins", "Can see installed plugins", "plugins", "system", 1);
1563
Permissions::createPermission("can_install_plugins", "Can install plugins", "User is allowed to install plugins", "plugins", "system", 2);
1564
1565
//admin permissions
1566
Permissions::createPermission("can_see_cms_version", "Can see version of CMS system", "Can see version of CMS system", "admin", "system", 1);
1567
Permissions::createPermission("can_update_cms", "Can update CMS system", "Can update CMS system", "admin", "system", 2);
1568
Permissions::createPermission("can_see_global_settings", "Can see global CMS settings", "Can see global CMS settings", "admin", "system", 3);
1569
Permissions::createPermission("can_edit_global_settings", "Can edit global settings", "Can edit global settings", "admin", "system", 4);
1570
Permissions::createPermission("can_see_phpinfo", "Can see phpinfo()", "Can see phpinfo()", "admin", "system", 5);
1571
Permissions::createPermission("can_see_system_info", "Can see system information", "Can see system information, like os or opcache information", "admin", "system", 6);
1572
Permissions::createPermission("can_see_phpmyadmin_menu", "Can see PhpMyAdmin menu", "Can see PhpMyAdmin menu", "admin", "system", 7);
1573
Permissions::createPermission("can_see_webmail_menu", "Can see Webmail menu", "Can see Webmail menu", "admin", "system", 8);
1574
Permissions::createPermission("can_send_board_mails", "Can send mails to users", "Can send mails to users", "admin", "system", 9);
1575
Permissions::createPermission("can_clear_cache", "Can clear cache", "Can clear cache", "admin", "system", 10);
1576
Permissions::createPermission("super_admin", "Is super admin and CAN EVERYTHING", "Is super admin and CAN EVERYTHING (overrides all other values!)", "admin", "system", 11);
1577
1578
echo "Set default permissions for userID 1...<br />";
1579
$user_rights = new UserRights(1);
1580
1581
//userID 1 should be super_admin
1582
$user_rights->setRight("super_admin", 1);
1583
1584
echo "Set default permissions for userID -1 (guest)...<br />";
1585
$user_rights = new UserRights(-1);
1586
$user_rights->setRight("not_logged_in", 1);
1587
1588
echo "Create default robots.txt rules...<br />";
1589
Robots::addRule("DISALLOW", "/system/*");
1590
Robots::addRule("DISALLOW", "/cache/*");
1591
Robots::addRule("DISALLOW", "/docs/*");
1592
Robots::addRule("DISALLOW", "/plugins/*");
1593
Robots::addRule("DISALLOW", "/styles/*");
1594
Robots::addRule("DISALLOW", "/admin/*");
1595
1596
//dont allow indexing of privacy policy and imprint pages, because they can contain sensitive information
1597
Robots::addRule("DISALLOW", "/privacy-policy");
1598
Robots::addRule("DISALLOW", "/imprint");
1599
1600
echo "Create default administrator user if absent...<br />";
1601
//User::createIfIdAbsent(0, "system", md5(time() . "test_"), "[email protected]", 1, "System", 1);
1602
User::createIfIdAbsent(1, "admin", "admin", "[email protected]", 1, "Administrator", 1);
1603
1604
echo "Add PluginInstaller plugins...<br />";
1605
PluginInstaller::addInstallerPluginIfAbsent("EventInstaller", "system/packages/com.jukusoft.cms.plugin/extensions/eventinstaller.php");
1606
PluginInstaller::addInstallerPluginIfAbsent("PermissionInstaller", "system/packages/com.jukusoft.cms.plugin/extensions/permissioninstaller.php");
1607
PluginInstaller::addInstallerPluginIfAbsent("PageTypeInstaller", "system/packages/com.jukusoft.cms.plugin/extensions/pagetypeinstaller.php");
1608
PluginInstaller::addInstallerPluginIfAbsent("PageInstaller", "system/packages/com.jukusoft.cms.plugin/extensions/pageinstaller.php");
1609
PluginInstaller::addInstallerPluginIfAbsent("StoreInstaller", "system/packages/com.jukusoft.cms.plugin/extensions/storeinstaller.php");
1610
PluginInstaller::addInstallerPluginIfAbsent("FilePermissionsInstaller", "system/packages/com.jukusoft.cms.plugin/extensions/filepermissionsinstaller.php");
1611
PluginInstaller::addInstallerPluginIfAbsent("ApiMethodInstaller", "system/packages/com.jukusoft.cms.plugin/extensions/apimethodinstaller.php");
1612
PluginInstaller::addInstallerPluginIfAbsent("MenuInstaller", "system/packages/com.jukusoft.cms.plugin/extensions/menuinstaller.php");
1613
PluginInstaller::addInstallerPluginIfAbsent("SettingsInstaller", "system/packages/com.jukusoft.cms.plugin/extensions/settingsinstaller.php");
1614
1615
echo "Add apimethod 'oauth'...<br />";
1616
ApiMethod::addMethod("oauth", "ApiOAuth", "apiOAuth", "package_com.jukusoft.cms.api");
1617
1618
echo "Add default tasks...<br />";
1619
Task::createStaticMethodTask("Cleanup outdated oauth tokens", "ApiOAuth", "removeAllOutdatedTokens", 1440, "oauth_cleanup_tokens", "system", array(), false);//cleanup outdated oauth tokens every day
1620
1621
echo "Add default widgets...<br />";
1622
WidgetType::register("TextWidget", "Text Widget", "Widget which shows text without html code.", true, "system");
1623
WidgetType::register("HTMLWidget", "HTML Widget", "Widget which shows html code.", true, "system");
1624
1625
//TODO: remove this lines
1626
echo "Add default sidebar widgets...<br />";
1627
HTMLWidget::create(2, "Latest News", "<h4>New Website Launched</h4>
1628
            <h5>August 1st, 2013</h5>
1629
            <p>2013 sees the redesign of our website. Take a look around and let us know what you think.<br /><a href=\"#\">Read more</a></p>
1630
            <p></p>
1631
            <h4>New Website Launched</h4>
1632
            <h5>August 1st, 2013</h5>
1633
            <p>2013 sees the redesign of our website. Take a look around and let us know what you think.<br /><a href=\"#\">Read more</a></p>", "default_right_widget_1");
1634
HTMLWidget::create(2, "Useful links", "<ul>
1635
                <li><a href=\"#\">link 1</a></li>
1636
                <li><a href=\"#\">link 2</a></li>
1637
                <li><a href=\"#\">link 3</a></li>
1638
                <li><a href=\"#\">link 4</a></li>
1639
            </ul>", "default_right_widget_2");
1640
HTMLWidget::create(2, "Search", "<form method=\"post\" action=\"#\" id=\"search_form\">
1641
                <p>
1642
                    <input class=\"search\" type=\"text\" name=\"search_field\" placeholder=\"Enter keywords\" />
1643
                    <input class=\"search_button\" name=\"search\" type=\"submit\" value=\"&#x1f50d;\" />
1644
                </p>
1645
            </form>", "default_right_widget_3");
1646
1647
echo "Clear gettext cache<br />";
1648
PHPUtils::clearGetTextCache();
1649
1650
echo "Clear cache<br />";
1651
Cache::clear();
1652
1653
echo "<br /><br />Finished DB Upgrade!";
1654
1655
if (file_exists(ROOT_PATH . "setup/add-install.php")) {
1656
	echo "<br />Call add-install.php...<br />";
1657
1658
	require(ROOT_PATH . "setup/add-install.php");
1659
1660
	echo "<br /><br />Finished additional Upgrade!";
1661
}
1662
1663
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
1664