-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.php
More file actions
91 lines (81 loc) · 2.79 KB
/
install.php
File metadata and controls
91 lines (81 loc) · 2.79 KB
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
<?php
/**
* install.php
*
* This file will CREATE TABLE in the DB while installation
* The TABLE will provide configuration settings needed for the Admin-Tool
*
* @platform WBCE CMS
* @package GlobalStrings
* @author Christian M. Stefan (Stefek)
* @copyright Christian M. Stefan
* @license http://www.gnu.org/licenses/gpl-2.0.html
*/
//no direct file access
if(count(get_included_files())==1) die(header("Location: ../index.php", TRUE, 301));
// install Droplet
include __DIR__.'/functions/droplets.functions.php';
$sDropletFile = __DIR__.'/droplets/string.php';
if(is_readable($sDropletFile)){
if(importDropletFromFile($sDropletFile)){
echo 'Droplet <b>string</b> installed successfully.<br>';
}
}
// get functions file
require __DIR__.'/functions.php';
// check if we should install any DB TABLE's or if this is an upgrade
if(db_table_exists(STRINGS_CFG_TBL) == true) {
exit;
}
$aQueries = array();
// _cfg table
$aQueries[] = "CREATE TABLE IF NOT EXISTS `".STRINGS_CFG_TBL."` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL DEFAULT '',
`value` text NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyIsam AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ;";
// _fields table
$aQueries[] = "CREATE TABLE IF NOT EXISTS `".STRINGS_FIELDS_TBL."` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL DEFAULT '',
`type` varchar(32) NOT NULL DEFAULT '',
`tpl` text NOT NULL,
`add_when` int(12) NOT NULL DEFAULT '0',
`add_by` int(11) NOT NULL DEFAULT '0',
`edit_when` int(12) NOT NULL DEFAULT '0',
`edit_by` int(11) NOT NULL DEFAULT '0',
`display` int(1) NOT NULL DEFAULT '1',
`restricted` int(1) NOT NULL DEFAULT '0',
PRIMARY KEY (id)
) ENGINE=MyIsam AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ;";
// display (0 = deleted, 1= visible)
// restricted (0 = no,anyone may edit content; 1= only users of group_id = 1 have access)
// _contents table
$aQueries[] = "CREATE TABLE IF NOT EXISTS `".STRINGS_CONTENTS_TBL."` (
`unique_id` int(11) NOT NULL AUTO_INCREMENT,
`id` int(11) NOT NULL DEFAULT '0',
`language` varchar(3) NOT NULL DEFAULT '',
`content` text NOT NULL,
PRIMARY KEY (unique_id)
) ENGINE=MyIsam AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ;";
echo '<br>Installing: ';
foreach($aQueries as $sSql){
$database->query($sSql);
echo '. . . ';
}
// add config settings
$aConfig = array(
'string_types' => 'textarea,shorttext',
'lang_fallback' => 'no',
'use_tpl' => 'no',
'use_trash' => 'yes',
'use_restrictions' => 'no',
'fe_edit' => 'no',
'order_by' => 'add_when-desc',
);
foreach($aConfig as $name=>$value){
if(createCfg($name, $value)){
echo '<br><span style="color:green;font-weight:bold">'.$name.' => '.$value.'</span>';
}
}