forked from GDRCD/GDRCD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupgrade_details.php
69 lines (55 loc) · 1.91 KB
/
upgrade_details.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
<?php
/** * Questo files contiene i dettagli per l'upgrade del database della vecchia versione alla nuova.
* Il modulo è riutilizzabile anche per il futuro, i campi vengono aggiunti solo se non ci sono nel db
* @author Blancks
*/
$tablelist = gdrcd_query("SHOW TABLES", 'result');
$table = gdrcd_query($tablelist, 'num_rows');
if ($table > 0)
{
$tables_list=array();
while($row=gdrcd_query($tablelist,'fetch')){
$tables_list[]=$row[0];
}
gdrcd_query($tablelist,'free');
$updating_queryes = array();
$updating_password = false;
/** * Elenco dei campi da aggiornare
* @author Blancks
*/
$tables = array();
require 'upgrade_list.php';
foreach ($tables as $tablename => $newfields)
{
if(in_array($tablename, $tables_list)){//Facciamo il controllo solo se la tabella esiste per davvero
$fields = gdrcd_check_tables($tablename);
foreach ($newfields as $newfield_name => $newfield_info)
{
$match = false;
foreach ($fields as $field)
{
if ($field->Field == $newfield_name)
$match = true;
}
if (!$match)
$updating_queryes[] = "ALTER TABLE `$tablename` ADD `$newfield_name` $newfield_info";
}
}
else{
//TODO rilevazione di un'installazione parziale o un db con tabelle non di gdrcd...dovrei lanciare qualche tipo di errore?
}
}
/** * Controllo se da configurazione è abilitato l'encript delle password e se le password non sono criptate nel db
* @author Blancks
*/
if ($PARAMETERS['mode']['encriptpassword']=='ON')
{
if(in_array('personaggio', $tables_list)){
$check_record = gdrcd_query("SELECT pass FROM personaggio LIMIT 1");
$password_len = strlen($check_record['pass']);
if ($password_len < 32)
$updating_password = true;
}
}
}
?>