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 | //check if navigation table filled with default links |
---|
11 | require_once('common/includes/autoupgrade.php'); |
---|
12 | check_navigationtable(); |
---|
13 | } |
---|
14 | |
---|
15 | function none() |
---|
16 | { |
---|
17 | // do nothing on submit |
---|
18 | } |
---|
19 | |
---|
20 | function checkCache() |
---|
21 | { |
---|
22 | $size = 0; |
---|
23 | $dir = opendir(KB_CACHEDIR); |
---|
24 | while ($line = readdir($dir)) |
---|
25 | { |
---|
26 | if (strstr($line, 'qcache_qry') !== false) |
---|
27 | { |
---|
28 | $size += filesize(KB_CACHEDIR.'/'.$line); |
---|
29 | } |
---|
30 | } |
---|
31 | |
---|
32 | // GB |
---|
33 | if (($size / 1073741824) > 1){ |
---|
34 | return round($size/1073741824, 4).' GB <input type="checkbox" name="option[sql_clearcache]">Clear cache ?'; |
---|
35 | // MB |
---|
36 | }elseif (($size / 1048576) > 1){ |
---|
37 | return round($size/1048576, 4).' MB <input type="checkbox" name="option[sql_clearcache]">Clear cache ?'; |
---|
38 | // KB |
---|
39 | }else{ |
---|
40 | return round($size/1024, 2).' KB <input type="checkbox" name="option[sql_clearcache]">Clear cache ?'; |
---|
41 | } |
---|
42 | } |
---|
43 | |
---|
44 | function killCache() |
---|
45 | { |
---|
46 | if ($_POST['option']['sql_clearcache'] != 'on') |
---|
47 | { |
---|
48 | return; |
---|
49 | } |
---|
50 | |
---|
51 | $dir = opendir(KB_CACHEDIR); |
---|
52 | while ($line = readdir($dir)) |
---|
53 | { |
---|
54 | if (strstr($line, 'qcache_qry') !== false) |
---|
55 | { |
---|
56 | @unlink(KB_CACHEDIR.'/'.$line); |
---|
57 | } |
---|
58 | elseif (strstr($line, 'qcache_tbl') !== false) |
---|
59 | { |
---|
60 | @unlink(KB_CACHEDIR.'/'.$line); |
---|
61 | } |
---|
62 | } |
---|
63 | } |
---|
64 | } |
---|
65 | ?> |
---|