-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.php
52 lines (48 loc) · 1.99 KB
/
update.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
<?php
// versiyon 2.2
$result = ORM::for_table('user')->raw_query("SELECT name FROM sqlite_master WHERE type='table' AND name='permission'")->find_one();
if (!$result) {
try {
ORM::for_table('user')->raw_execute('ALTER TABLE user ADD gsm_permission INTEGER');
ORM::for_table('user')->raw_execute('ALTER TABLE user ADD email_permission INTEGER');
ORM::for_table('user')->raw_execute("CREATE TABLE 'permission' ('id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, 'user_id' INTEGER, 'gsm' TEXT, 'email' TEXT, 'mac' TEXT, 'ip' TEXT, 'timestamp' INTEGER)");
} catch (Exception $e) {
die('Veritabani guncellemesi sirasinda bir hata olustu: ' .$e->getMessage());
}
foreach(array('tr', 'en') as $code)
{
$lang_sample = include 'lang/' . $code . '.sample.inc';
$lang = include 'lang/' . $code . '.inc';
foreach ($lang_sample as $key => $value) {
if (!array_key_exists($key, $lang)) {
$lang[$key] = $value;
}
}
file_put_contents('lang/' . $code . '.inc', '<?php' . "\n\n" . 'return ' . var_export($lang, true) . ';');
}
}
// Son MAC adresi sütunu eklendi.
$result = ORM::for_table('user')->raw_query("PRAGMA table_info(user)")->find_many();
$last_mac_column_exists = FALSE;
foreach ($result as $column) {
if ($column->name === 'last_mac') {
$last_mac_column_exists = TRUE;
break;
}
}
if (!$last_mac_column_exists) {
try {
ORM::for_table('user')->raw_execute('ALTER TABLE user ADD last_mac TEXT');
} catch (Exception $e) {
die('Veritabani guncellemesi sirasinda bir hata olustu: ' .$e->getMessage());
}
}
// kullanıcı grupları eklendi
$result = ORM::for_table('user')->raw_query("SELECT name FROM sqlite_master WHERE type='table' AND name='group'")->find_one();
if (!$result) {
try {
ORM::for_table('user')->raw_execute("CREATE TABLE 'group' ('id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, 'name' TEXT, 'macs' TEXT)");
} catch (Exception $e) {
die('Veritabani guncellemesi sirasinda bir hata olustu: ' .$e->getMessage());
}
}