-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.php
145 lines (131 loc) · 2.79 KB
/
install.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
<?php
if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
{
$ssi = true;
require_once(dirname(__FILE__) . '/SSI.php');
}
elseif (!defined('SMF'))
exit('<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.');
if (!array_key_exists('db_add_column', $smcFunc))
db_extend('packages');
$columns = array(
array(
'name' => 'id_target',
'type' => 'mediumint',
'size' => 8,
'unsigned' => true,
),
array(
'name' => 'id_executor',
'type' => 'mediumint',
'size' => 8,
'unsigned' => true,
),
array(
'name' => 'log_time',
'type' => 'int',
'size' => 10,
'unsigned' => true,
),
array(
'name' => 'action',
'type' => 'tinyint',
'size' => 3,
),
);
$indexes = array(
array(
'type' => 'primary',
'columns' => array('id_target', 'id_executor'),
),
array(
'type' => 'unique',
'columns' => array('log_time'),
),
);
$smcFunc['db_create_table']('{db_prefix}log_karma', $columns, $indexes, array(), 'update_remove');
$perms = array('karma_edit');
$request = $smcFunc['db_query'](
'',
'
SELECT id_group
FROM {db_prefix}permissions
WHERE permission IN ({array_string:perms})',
array(
'perms' => $perms,
)
);
$num = $smcFunc['db_num_rows']($request);
$smcFunc['db_free_result']($request);
if (empty($num))
{
$request = $smcFunc['db_query'](
'',
'
SELECT id_group
FROM {db_prefix}membergroups
WHERE id_group NOT IN ({array_int:exclude_groups})' . (empty($modSettings['permission_enable_postgroups']) ? '
AND min_posts = {int:min_posts}' : ''),
array(
'exclude_groups' => array(1, 3),
'min_posts' => -1,
)
);
$groups = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
foreach ($perms as $perm)
$groups[] = array($row['id_group'], $perm, empty($modSettings['permission_enable_deny']) ? 1 : -1);
foreach ($perms as $perm)
{
$groups[] = array(-1, $perm, !empty($modSettings['permission_enable_deny']) ? 1 : -1);
$groups[] = array(0, $perm, !empty($modSettings['permission_enable_deny']) ? 1 : -1);
}
$smcFunc['db_insert'](
'ignore',
'{db_prefix}permissions',
array('id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int'),
$groups,
array('id_group', 'permission')
);
}
$smcFunc['db_insert'](
'ignore',
'{db_prefix}custom_fields',
array(
'col_name' => 'string',
'field_type' => 'string',
'show_profile' => 'string',
'private' => 'int',
'mask' => 'string',
'placement' => 'int',
),
array(
array(
'karma_good',
'text',
'none',
3,
'number',
6,
),
array(
'karma_bad',
'text',
'none',
3,
'number',
6,
),
),
array('id_field')
);
updateSettings(
array(
'karmaMode' => '0',
'karmaTimeRestrictAdmins' => '1',
'karmaWaitTime' => '1',
'karmaMinPosts' => '0',
)
);
if (!empty($ssi))
echo 'Database installation complete!';