|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @file upgrade.ajax.php |
|
4
|
|
|
* @author Nils Laumaillé |
|
5
|
|
|
* @version 2.1.27 |
|
6
|
|
|
* @copyright (c) 2009-2017 Nils Laumaillé |
|
7
|
|
|
* @licensing GNU AFFERO GPL 3.0 |
|
8
|
|
|
* @link http://www.teampass.net |
|
9
|
|
|
* |
|
10
|
|
|
* This library is distributed in the hope that it will be useful, |
|
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
/* |
|
16
|
|
|
** Upgrade script for release 2.1.27 |
|
17
|
|
|
*/ |
|
18
|
|
|
require_once('../sources/SecureHandler.php'); |
|
19
|
|
|
session_start(); |
|
20
|
|
|
error_reporting(E_ERROR | E_PARSE); |
|
21
|
|
|
$_SESSION['db_encoding'] = "utf8"; |
|
22
|
|
|
$_SESSION['CPM'] = 1; |
|
23
|
|
|
|
|
24
|
|
|
require_once '../includes/language/english.php'; |
|
25
|
|
|
require_once '../includes/config/include.php'; |
|
26
|
|
View Code Duplication |
if (!file_exists("../includes/settings.php") && !file_exists("../includes/config/settings.php")) { |
|
27
|
|
|
echo 'document.getElementById("res_step1_error").innerHTML = "";'; |
|
28
|
|
|
echo 'document.getElementById("res_step1_error").innerHTML = '. |
|
29
|
|
|
'"File settings.php does not exist in folder includes/! '. |
|
30
|
|
|
'If it is an upgrade, it should be there, otherwise select install!";'; |
|
31
|
|
|
echo 'document.getElementById("loader").style.display = "none";'; |
|
32
|
|
|
exit; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
// handle file |
|
36
|
|
|
if (file_exists("../includes/settings.php") && !file_exists("../includes/config/settings.php")) { |
|
37
|
|
|
// copy to config/ |
|
38
|
|
|
copy("../includes/settings.php", "../includes/config/settings.php"); |
|
39
|
|
|
unlink("../includes/settings.php"); |
|
40
|
|
|
} else if (file_exists("../includes/settings.php") && file_exists("../includes/config/settings.php")) { |
|
41
|
|
|
// remove as not used anymore |
|
42
|
|
|
unlink("../includes/settings.php"); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
|
|
46
|
|
|
require_once '../includes/config/settings.php'; |
|
47
|
|
|
require_once '../sources/main.functions.php'; |
|
48
|
|
|
|
|
49
|
|
|
$_SESSION['settings']['loaded'] = ""; |
|
50
|
|
|
|
|
51
|
|
|
################ |
|
52
|
|
|
## Function permits to get the value from a line |
|
53
|
|
|
################ |
|
54
|
|
|
/** |
|
55
|
|
|
* @param string $val |
|
56
|
|
|
*/ |
|
57
|
|
|
function getSettingValue($val) |
|
|
|
|
|
|
58
|
|
|
{ |
|
59
|
|
|
$val = trim(strstr($val, "=")); |
|
60
|
|
|
return trim(str_replace('"', '', substr($val, 1, strpos($val, ";") - 1))); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
################ |
|
64
|
|
|
## Function permits to check if a column exists, and if not to add it |
|
65
|
|
|
################ |
|
66
|
|
View Code Duplication |
function addColumnIfNotExist($db, $column, $columnAttr = "VARCHAR(255) NULL") |
|
|
|
|
|
|
67
|
|
|
{ |
|
68
|
|
|
global $dbTmp; |
|
69
|
|
|
$exists = false; |
|
70
|
|
|
$columns = mysqli_query($dbTmp, "show columns from $db"); |
|
71
|
|
|
while ($c = mysqli_fetch_assoc($columns)) { |
|
72
|
|
|
if ($c['Field'] == $column) { |
|
73
|
|
|
$exists = true; |
|
|
|
|
|
|
74
|
|
|
return true; |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
if (!$exists) { |
|
78
|
|
|
return mysqli_query($dbTmp, "ALTER TABLE `$db` ADD `$column` $columnAttr"); |
|
79
|
|
|
} else { |
|
80
|
|
|
return false; |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
View Code Duplication |
function addIndexIfNotExist($table, $index, $sql) { |
|
|
|
|
|
|
85
|
|
|
global $dbTmp; |
|
86
|
|
|
|
|
87
|
|
|
$mysqli_result = mysqli_query($dbTmp, "SHOW INDEX FROM $table WHERE key_name LIKE \"$index\""); |
|
88
|
|
|
$res = mysqli_fetch_row($mysqli_result); |
|
89
|
|
|
|
|
90
|
|
|
// if index does not exist, then add it |
|
91
|
|
|
if (!$res) { |
|
92
|
|
|
$res = mysqli_query($dbTmp, "ALTER TABLE `$table` ".$sql); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
return $res; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
View Code Duplication |
function tableExists($tablename, $database = false) |
|
|
|
|
|
|
99
|
|
|
{ |
|
100
|
|
|
global $dbTmp; |
|
101
|
|
|
|
|
102
|
|
|
$res = mysqli_query($dbTmp, |
|
103
|
|
|
"SELECT COUNT(*) as count |
|
104
|
|
|
FROM information_schema.tables |
|
105
|
|
|
WHERE table_schema = '".$_SESSION['db_bdd']."' |
|
106
|
|
|
AND table_name = '$tablename'" |
|
107
|
|
|
); |
|
108
|
|
|
|
|
109
|
|
|
if ($res > 0) { |
|
110
|
|
|
return true; |
|
111
|
|
|
} else { |
|
112
|
|
|
return false; |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
//define pbkdf2 iteration count |
|
117
|
|
|
@define('ITCOUNT', '2072'); |
|
|
|
|
|
|
118
|
|
|
|
|
119
|
|
|
$return_error = ""; |
|
120
|
|
|
|
|
121
|
|
|
// do initial upgrade |
|
122
|
|
|
|
|
123
|
|
|
//include librairies |
|
124
|
|
|
require_once '../includes/libraries/Tree/NestedTree/NestedTree.php'; |
|
125
|
|
|
|
|
126
|
|
|
//Build tree |
|
127
|
|
|
$tree = new Tree\NestedTree\NestedTree( |
|
128
|
|
|
$_SESSION['pre'].'nested_tree', |
|
129
|
|
|
'id', |
|
130
|
|
|
'parent_id', |
|
131
|
|
|
'title' |
|
132
|
|
|
); |
|
133
|
|
|
|
|
134
|
|
|
// dataBase |
|
135
|
|
|
$res = ""; |
|
136
|
|
|
|
|
137
|
|
|
mysqli_connect( |
|
138
|
|
|
$_SESSION['server'], |
|
139
|
|
|
$_SESSION['user'], |
|
140
|
|
|
$_SESSION['pass'], |
|
141
|
|
|
$_SESSION['database'], |
|
142
|
|
|
$_SESSION['port'] |
|
143
|
|
|
); |
|
144
|
|
|
$dbTmp = mysqli_connect( |
|
145
|
|
|
$_SESSION['server'], |
|
146
|
|
|
$_SESSION['user'], |
|
147
|
|
|
$_SESSION['pass'], |
|
148
|
|
|
$_SESSION['database'], |
|
149
|
|
|
$_SESSION['port'] |
|
150
|
|
|
); |
|
151
|
|
|
|
|
152
|
|
|
// add field timestamp to cache table |
|
153
|
|
|
$res = addColumnIfNotExist( |
|
154
|
|
|
$_SESSION['pre']."cache", |
|
155
|
|
|
"timestamp", |
|
156
|
|
|
"VARCHAR(50) NOT NULL" |
|
157
|
|
|
); |
|
158
|
|
|
if ($res === false) { |
|
159
|
|
|
echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field Timestamp to table Cache! '.mysqli_error($dbTmp).'!"}]'; |
|
160
|
|
|
mysqli_close($dbTmp); |
|
161
|
|
|
exit(); |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
// add field url to cache table |
|
165
|
|
|
$res = addColumnIfNotExist( |
|
166
|
|
|
$_SESSION['pre']."cache", |
|
167
|
|
|
"url", |
|
168
|
|
|
"VARCHAR(500) NOT NULL DEFAULT '0'" |
|
169
|
|
|
); |
|
170
|
|
|
if ($res === false) { |
|
171
|
|
|
echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field Url to table Cache! '.mysqli_error($dbTmp).'!"}]'; |
|
172
|
|
|
mysqli_close($dbTmp); |
|
173
|
|
|
exit(); |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
// add field can_manage_all_users to users table |
|
177
|
|
|
$res = addColumnIfNotExist( |
|
178
|
|
|
$_SESSION['pre']."users", |
|
179
|
|
|
"can_manage_all_users", |
|
180
|
|
|
"tinyint(1) NOT NULL DEFAULT '0'" |
|
181
|
|
|
); |
|
182
|
|
|
if ($res === false) { |
|
183
|
|
|
echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field can_manage_all_users to table Users! '.mysqli_error($dbTmp).'!"}]'; |
|
184
|
|
|
mysqli_close($dbTmp); |
|
185
|
|
|
exit(); |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
// check that API doesn't exist |
|
189
|
|
|
$tmp = mysqli_fetch_row(mysqli_query($dbTmp, "SELECT COUNT(*) FROM `".$_SESSION['pre']."users` WHERE id = '".API_USER_ID."'")); |
|
190
|
|
|
if ($tmp[0] == 0 || empty($tmp[0])) { |
|
191
|
|
|
mysqli_query($dbTmp, |
|
192
|
|
|
"INSERT INTO `".$_SESSION['pre']."users` (`id`, `login`, `read_only`) VALUES ('".API_USER_ID."', 'API', '1')" |
|
193
|
|
|
); |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
// check that SYSLOG doesn't exist |
|
197
|
|
|
$tmp = mysqli_fetch_row(mysqli_query($dbTmp, "SELECT COUNT(*) FROM `".$_SESSION['pre']."misc` WHERE type = 'admin' AND intitule = 'syslog_enable'")); |
|
198
|
|
View Code Duplication |
if ($tmp[0] == 0 || empty($tmp[0])) { |
|
199
|
|
|
mysqli_query($dbTmp, |
|
200
|
|
|
"INSERT INTO `".$_SESSION['pre']."misc` (`type`, `intitule`, `valeur`) VALUES ('admin', 'syslog_enable', '0')" |
|
201
|
|
|
); |
|
202
|
|
|
mysqli_query($dbTmp, |
|
203
|
|
|
"INSERT INTO `".$_SESSION['pre']."misc` (`type`, `intitule`, `valeur`) VALUES ('admin', 'syslog_host', 'localhost')" |
|
204
|
|
|
); |
|
205
|
|
|
mysqli_query($dbTmp, |
|
206
|
|
|
"INSERT INTO `".$_SESSION['pre']."misc` (`type`, `intitule`, `valeur`) VALUES ('admin', 'syslog_port', '514')" |
|
207
|
|
|
); |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
|
|
211
|
|
|
// alter table Items |
|
212
|
|
|
mysqli_query($dbTmp, "ALTER TABLE `".$_SESSION['pre']."items` MODIFY complexity_level VARCHAR(3)"); |
|
213
|
|
|
mysqli_query($dbTmp, "ALTER TABLE `".$_SESSION['pre']."items` MODIFY label VARCHAR(500)"); |
|
214
|
|
|
mysqli_query($dbTmp, "ALTER TABLE `".$_SESSION['pre']."items` MODIFY url VARCHAR(500)"); |
|
215
|
|
|
mysqli_query($dbTmp, "ALTER TABLE `".$_SESSION['pre']."items` MODIFY restricted_to DEFAULT NULL"); |
|
216
|
|
|
mysqli_query($dbTmp, "ALTER TABLE `".$_SESSION['pre']."items` CHANGE `description` `description` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL"); |
|
217
|
|
|
mysqli_query($dbTmp, "ALTER TABLE `".$_SESSION['pre']."items` CHANGE `pw` `pw` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL"); |
|
218
|
|
|
mysqli_query($dbTmp, "ALTER TABLE `".$_SESSION['pre']."items` CHANGE `pw_iv` `pw_iv` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL"); |
|
219
|
|
|
|
|
220
|
|
|
// alter table cache |
|
221
|
|
|
mysqli_query($dbTmp, "ALTER TABLE `".$_SESSION['pre']."cache` MODIFY label VARCHAR(500)"); |
|
222
|
|
|
mysqli_query($dbTmp, "ALTER TABLE `".$_SESSION['pre']."cache` MODIFY restricted_to DEFAULT NULL"); |
|
223
|
|
|
mysqli_query($dbTmp, "ALTER TABLE `".$_SESSION['pre']."cache` MODIFY tags DEFAULT NULL"); |
|
224
|
|
|
mysqli_query($dbTmp, "ALTER TABLE `".$_SESSION['pre']."cache` MODIFY timestamp DEFAULT NULL"); |
|
225
|
|
|
|
|
226
|
|
|
// alter table files |
|
227
|
|
|
mysqli_query($dbTmp, "ALTER TABLE `".$_SESSION['pre']."files` MODIFY type VARCHAR(255)"); |
|
228
|
|
|
|
|
229
|
|
|
// alter table USers |
|
230
|
|
|
mysqli_query($dbTmp, "ALTER TABLE `".$_SESSION['pre']."users` ADD `usertimezone` VARCHAR(50) NOT NULL DEFAULT 'not_defined'"); |
|
231
|
|
|
mysqli_query($dbTmp, "ALTER TABLE `".$_SESSION['pre']."users` MODIFY can_manage_all_users tinyint(1) NOT NULL DEFAULT '0'"); |
|
232
|
|
|
|
|
233
|
|
|
// alter table log_system |
|
234
|
|
|
mysqli_query($dbTmp, "ALTER TABLE `".$_SESSION['pre']."log_system` MODIFY qui VARCHAR(255)"); |
|
235
|
|
|
|
|
236
|
|
|
// create index in log_items - for performance |
|
237
|
|
|
mysqli_query($dbTmp, "CREATE INDEX teampass_log_items_id_item_IDX ON ".$_SESSION['pre']."log_items (id_item,date);"); |
|
238
|
|
|
|
|
239
|
|
|
// change to true setting variable encryptClientServer |
|
240
|
|
|
// this variable is not to be changed anymore |
|
241
|
|
|
mysqli_query($dbTmp, "UPDATE `".$_SESSION['pre']."misc SET `valeur` = 1 WHERE `type` = 'admin' AND `intitule` = 'encryptClientServer'"); |
|
242
|
|
|
|
|
243
|
|
|
// create new table |
|
244
|
|
|
mysqli_query($dbTmp, |
|
245
|
|
|
"CREATE TABLE IF NOT EXISTS `".$_SESSION['pre']."tokens` ( |
|
246
|
|
|
`id` int(12) NOT NULL AUTO_INCREMENT, |
|
247
|
|
|
`user_id` int(10) NOT NULL, |
|
248
|
|
|
`token` varchar(255) NOT NULL, |
|
249
|
|
|
`reason` varchar(255) NOT NULL, |
|
250
|
|
|
`creation_timestamp` varchar(50) NOT NULL, |
|
251
|
|
|
`end_timestamp` varchar(50) NOT NULL, |
|
252
|
|
|
PRIMARY KEY (`id`) |
|
253
|
|
|
) CHARSET=utf8;" |
|
254
|
|
|
); |
|
255
|
|
|
|
|
256
|
|
|
// change to 0 if auto_update_pwd_next_date empty in ITEMS table |
|
257
|
|
|
$result = mysqli_query($dbTmp, "SELECT id FROM `".$_SESSION['pre']."items` WHERE auto_update_pwd_next_date = ''"); |
|
258
|
|
View Code Duplication |
while ($row = mysqli_fetch_assoc($result)) { |
|
259
|
|
|
mysqli_query($dbTmp, |
|
260
|
|
|
"UPDATE `".$_SESSION['pre']."items` |
|
261
|
|
|
SET `auto_update_pwd_next_date` = '0' |
|
262
|
|
|
WHERE id = '".$row['id']."'" |
|
263
|
|
|
); |
|
264
|
|
|
} |
|
265
|
|
|
mysqli_free_result($result); |
|
266
|
|
|
|
|
267
|
|
|
|
|
268
|
|
|
// add Estonian |
|
269
|
|
|
$tmp = mysqli_fetch_row(mysqli_query($dbTmp, "SELECT COUNT(*) FROM `".$_SESSION['pre']."languages` WHERE name = 'estonian'")); |
|
270
|
|
View Code Duplication |
if ($tmp[0] == 0 || empty($tmp[0])) { |
|
271
|
|
|
mysqli_query($dbTmp, "INSERT INTO `".$_SESSION['pre']."languages` VALUES (null, 'estonian', 'Estonian', 'ee', 'ee.png')"); |
|
272
|
|
|
} |
|
273
|
|
|
|
|
274
|
|
|
// remove Estonia |
|
275
|
|
|
$tmp = mysqli_fetch_row(mysqli_query($dbTmp, "SELECT COUNT(*) FROM `".$_SESSION['pre']."languages` WHERE name = 'estonia'")); |
|
276
|
|
View Code Duplication |
if ($tmp[0] == 0 || empty($tmp[0])) { |
|
277
|
|
|
mysqli_query($dbTmp, "DELETE FROM `".$_SESSION['pre']."languages` WHERE name = 'estonia'"); |
|
278
|
|
|
} |
|
279
|
|
|
|
|
280
|
|
|
// ensure CSRFP config file is ready |
|
281
|
|
|
if (!isset($_SESSION['upgrade']['csrfp_config_file']) || $_SESSION['upgrade']['csrfp_config_file'] != 1) { |
|
282
|
|
|
$csrfp_file_sample = "../includes/libraries/csrfp/libs/csrfp.config.sample.php"; |
|
283
|
|
|
$csrfp_file = "../includes/libraries/csrfp/libs/csrfp.config.php"; |
|
284
|
|
|
if (file_exists($csrfp_file)) { |
|
285
|
|
|
if (!copy($csrfp_file, $csrfp_file.'.'.date("Y_m_d", mktime(0, 0, 0, date('m'), date('d'), date('y'))))) { |
|
286
|
|
|
echo '[{"finish":"1" , "next":"", "error" : "csrfp.config.php file already exists and cannot be renamed. Please do it by yourself and click on button Launch."}]'; |
|
287
|
|
|
return false; |
|
288
|
|
|
} else { |
|
|
|
|
|
|
289
|
|
|
// "The file $csrfp_file already exist. A copy has been created.<br />"; |
|
290
|
|
|
} |
|
291
|
|
|
} |
|
292
|
|
|
unlink($csrfp_file); // delete existing csrfp.config file |
|
293
|
|
|
copy($csrfp_file_sample, $csrfp_file); // make a copy of csrfp.config.sample file |
|
294
|
|
|
$data = file_get_contents("../includes/libraries/csrfp/libs/csrfp.config.php"); |
|
295
|
|
|
$newdata = str_replace('"CSRFP_TOKEN" => ""', '"CSRFP_TOKEN" => "'.bin2hex(openssl_random_pseudo_bytes(25)).'"', $data); |
|
296
|
|
|
$newdata = str_replace('"tokenLength" => "25"', '"tokenLength" => "50"', $newdata); |
|
297
|
|
|
$jsUrl = $_SESSION['fullurl'].'/includes/libraries/csrfp/js/csrfprotector.js'; |
|
298
|
|
|
$newdata = str_replace('"jsUrl" => ""', '"jsUrl" => "'.$jsUrl.'"', $newdata); |
|
299
|
|
|
file_put_contents("../includes/libraries/csrfp/libs/csrfp.config.php", $newdata); |
|
300
|
|
|
|
|
301
|
|
|
$_SESSION['upgrade']['csrfp_config_file'] = 1; |
|
302
|
|
|
} |
|
303
|
|
|
|
|
304
|
|
|
/* |
|
305
|
|
|
* Introduce new CONFIG file |
|
306
|
|
|
*/ |
|
307
|
|
|
$tp_config_file = "../includes/config/tp.config.php"; |
|
308
|
|
|
if (file_exists($tp_config_file)) { |
|
309
|
|
|
if (!copy($tp_config_file, $tp_config_file.'.'.date("Y_m_d", mktime(0, 0, 0, date('m'), date('d'), date('y'))))) { |
|
310
|
|
|
echo '[{"error" : "includes/config/tp.config.php file already exists and cannot be renamed. Please do it by yourself and click on button Launch.", "result":"", "index" : "'.$_POST['index'].'", "multiple" : "'.$_POST['multiple'].'"}]'; |
|
|
|
|
|
|
311
|
|
|
return false; |
|
312
|
|
|
} else { |
|
313
|
|
|
unlink($tp_config_file); |
|
314
|
|
|
} |
|
315
|
|
|
} |
|
316
|
|
|
$fh = fopen($tp_config_file, 'w'); |
|
317
|
|
|
$config_text = "<?php |
|
318
|
|
|
global \$SETTINGS; |
|
319
|
|
|
\$SETTINGS = array ("; |
|
320
|
|
|
|
|
321
|
|
|
$result = mysqli_query($dbTmp, "SELECT * FROM `".$_SESSION['pre']."misc` WHERE type = 'admin'"); |
|
322
|
|
|
while ($row = mysqli_fetch_assoc($result)) { |
|
323
|
|
|
// append new setting in config file |
|
324
|
|
|
$config_text .= " |
|
325
|
|
|
'".$row['intitule']."' => '".$row['valeur']."',"; |
|
326
|
|
|
} |
|
327
|
|
|
mysqli_free_result($result); |
|
328
|
|
|
|
|
329
|
|
|
// write to config file |
|
330
|
|
|
$result = fwrite( |
|
331
|
|
|
$fh, |
|
332
|
|
|
utf8_encode( |
|
333
|
|
|
substr_replace($config_text, "", -1)." |
|
334
|
|
|
);" |
|
335
|
|
|
) |
|
336
|
|
|
); |
|
337
|
|
|
fclose($fh); |
|
338
|
|
|
|
|
339
|
|
|
|
|
340
|
|
|
// clean duplicate ldap_object_class from bad update script version |
|
341
|
|
|
$tmp = mysqli_fetch_row(mysqli_query($dbTmp, "SELECT COUNT(*) FROM `".$_SESSION['pre']."misc` WHERE type = 'admin' AND intitule = 'ldap_object_class'")); |
|
342
|
|
View Code Duplication |
if ($tmp[0] > 1) { |
|
343
|
|
|
mysqli_query($dbTmp, "DELETE FROM `".$_SESSION['pre']."misc` WHERE type = 'admin' AND intitule = 'ldap_object_class' AND `valeur` = 0"); |
|
344
|
|
|
} |
|
345
|
|
|
// add new setting - ldap_object_class |
|
346
|
|
|
$tmp = mysqli_fetch_row(mysqli_query($dbTmp, "SELECT COUNT(*) FROM `".$_SESSION['pre']."misc` WHERE type = 'admin' AND intitule = 'ldap_object_class'")); |
|
347
|
|
View Code Duplication |
if ($tmp[0] == 0 || empty($tmp[0])) { |
|
348
|
|
|
mysqli_query($dbTmp, "INSERT INTO `".$_SESSION['pre']."misc` VALUES ('admin', 'ldap_object_class', '0')"); |
|
349
|
|
|
} |
|
350
|
|
|
|
|
351
|
|
|
// convert 2factors_ to google_ due to illegal id, and for clarification of purpose |
|
352
|
|
|
$tmp_googlecount = mysqli_fetch_row(mysqli_query($dbTmp, "SELECT COUNT(*) FROM `".$_SESSION['pre']."misc` WHERE type = 'admin' AND intitule = 'google_authentication'")); |
|
353
|
|
|
$tmp_twocount = mysqli_fetch_row(mysqli_query($dbTmp, "SELECT COUNT(*) FROM `".$_SESSION['pre']."misc` WHERE type = 'admin' AND intitule = '2factors_authentication'")); |
|
354
|
|
|
|
|
355
|
|
|
if ($tmp_googlecount[0] > 0) { |
|
356
|
|
|
mysqli_query($dbTmp, "DELETE FROM `".$_SESSION['pre']."misc` WHERE type = 'admin' AND intitule = '2factors_authentication'"); |
|
357
|
|
|
} else { |
|
358
|
|
|
if ($tmp_twocount[0] > 0) { |
|
359
|
|
|
mysqli_query($dbTmp, "UPDATE `".$_SESSION['pre']."misc` SET intitule = 'google_authentication' WHERE intitule = '2factors_authentication' "); |
|
360
|
|
|
} else { |
|
361
|
|
|
mysqli_query($dbTmp, "INSERT INTO `".$_SESSION['pre']."misc` VALUES ('admin', 'google_authentication', '0')"); |
|
362
|
|
|
} |
|
363
|
|
|
} |
|
364
|
|
|
|
|
365
|
|
|
|
|
366
|
|
|
// Fix for #1510 |
|
367
|
|
|
// change the "personal_folder" field on all named folders back to "0" in nested_tree |
|
368
|
|
|
$result = mysqli_query( |
|
369
|
|
|
$dbTmp, |
|
370
|
|
|
"SELECT title, id |
|
371
|
|
|
FROM `".$_SESSION['pre']."nested_tree` |
|
372
|
|
|
WHERE personal_folder = '1' AND nlevel = '1' AND parent_id = '0'" |
|
373
|
|
|
); |
|
374
|
|
View Code Duplication |
while ($row = mysqli_fetch_assoc($result)) { |
|
375
|
|
|
// only change non numeric folder title |
|
376
|
|
|
if (!is_numeric($row['title'])) { |
|
377
|
|
|
mysqli_query( |
|
378
|
|
|
$dbTmp, |
|
379
|
|
|
"UPDATE `".$_SESSION['pre']."nested_tree` |
|
380
|
|
|
SET personal_folder = '0' |
|
381
|
|
|
WHERE id = '".$row['id']."'" |
|
382
|
|
|
); |
|
383
|
|
|
} |
|
384
|
|
|
} |
|
385
|
|
|
mysqli_free_result($result); |
|
386
|
|
|
|
|
387
|
|
|
|
|
388
|
|
|
// Finished |
|
389
|
|
|
echo '[{"finish":"1" , "next":"", "error":""}]'; |
This check looks for functions that have already been defined in other files.
Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the
@ignoreannotation.See also the PhpDoc documentation for @ignore.