1 | <?php |
---|
2 | options::cat('Maintenance', 'Database', 'Table checks'); |
---|
3 | options::fadd('This checks automatically your database', 'none', 'custom', array('admin_db', 'checkDatabase'), array('admin_db', 'none')); |
---|
4 | options::fadd('Current SQL cache size', 'none', 'custom', array('admin_db', 'checkCache'), array('admin_db', 'killCache')); |
---|
5 | |
---|
6 | class admin_db |
---|
7 | { |
---|
8 | function checkDatabase() |
---|
9 | { |
---|
10 | require_once('common/includes/autoupgrade.php'); |
---|
11 | |
---|
12 | // todo: write functions to take care of this |
---|
13 | // based on a database description file |
---|
14 | check_pilots(); |
---|
15 | check_invdetail(); |
---|
16 | check_contracts(); |
---|
17 | check_index(); |
---|
18 | check_tblstrct1(); |
---|
19 | check_tblstrct2(); |
---|
20 | check_tblstrct3(); |
---|
21 | check_tblstrct4(); |
---|
22 | check_tblstrct5(); |
---|
23 | chk_kb3_items(); |
---|
24 | chk_kb3_items2(); |
---|
25 | check_tblstrct6(); |
---|
26 | |
---|
27 | return 'Maintenance complete.<br/>'; |
---|
28 | } |
---|
29 | |
---|
30 | function none() |
---|
31 | { |
---|
32 | // do nothing on submit |
---|
33 | } |
---|
34 | |
---|
35 | function checkCache() |
---|
36 | { |
---|
37 | $size = 0; |
---|
38 | $dir = opendir(KB_CACHEDIR); |
---|
39 | while ($line = readdir($dir)) |
---|
40 | { |
---|
41 | if (strstr($line, 'qcache_qry') !== false) |
---|
42 | { |
---|
43 | $size += filesize(KB_CACHEDIR.'/'.$line); |
---|
44 | } |
---|
45 | } |
---|
46 | |
---|
47 | return round($size/1024, 2).' KB <input type="checkbox" name="option[sql_clearcache]">Clear cache ?'; |
---|
48 | } |
---|
49 | |
---|
50 | function killCache() |
---|
51 | { |
---|
52 | if ($_POST['option']['sql_clearcache'] != 'on') |
---|
53 | { |
---|
54 | return; |
---|
55 | } |
---|
56 | |
---|
57 | $dir = opendir(KB_CACHEDIR); |
---|
58 | while ($line = readdir($dir)) |
---|
59 | { |
---|
60 | if (strstr($line, 'qcache_qry') !== false) |
---|
61 | { |
---|
62 | @unlink(KB_CACHEDIR.'/'.$line); |
---|
63 | } |
---|
64 | elseif (strstr($line, 'qcache_tbl') !== false) |
---|
65 | { |
---|
66 | @unlink(KB_CACHEDIR.'/'.$line); |
---|
67 | } |
---|
68 | } |
---|
69 | } |
---|
70 | } |
---|
71 | ?> |
---|