1 | <?php |
---|
2 | /* |
---|
3 | * This file contains the generic admin options in the new format |
---|
4 | * look here for some examples. |
---|
5 | */ |
---|
6 | |
---|
7 | options::cat('Advanced', 'Cache', 'Cache Control'); |
---|
8 | options::fadd('Caching enabled', 'cache_enabled', 'checkbox'); |
---|
9 | options::fadd('Cache directory', 'cache_dir', 'edit:size:40'); |
---|
10 | options::fadd('Ignore pages', 'cache_ignore', 'edit:size:60'); |
---|
11 | options::fadd('Cache times', 'cache_times', 'edit:size:60'); |
---|
12 | |
---|
13 | options::cat('Advanced', 'Cache', 'Killmail Cache'); |
---|
14 | options::fadd('Killmail Caching enabled','km_cache_enabled','checkbox'); |
---|
15 | options::fadd('Killmail Cache directory', 'km_cache_dir', 'edit:size:40'); |
---|
16 | options::fadd('Cached Killmails', 'none', 'custom', array('admin_acache', 'getKillmails')); |
---|
17 | |
---|
18 | options::cat('Advanced', 'Cache', 'Reinforced'); |
---|
19 | options::fadd('Enable Reinforced Management', 'auto_reinforced', 'checkbox'); |
---|
20 | options::fadd('Current Load', 'none', 'custom', array('admin_acache', 'showLoad')); |
---|
21 | options::fadd('Reinforcement threshold', 'reinforced_threshold', 'edit:size:4'); |
---|
22 | options::fadd('Disabling threshold', 'reinforced_disable_threshold', 'edit:size:4'); |
---|
23 | options::fadd('Reinforcement chance', 'reinforced_prob', 'edit:size:4'); |
---|
24 | options::fadd('Reinforcement end chance', 'reinforced_rf_prob', 'edit:size:4'); |
---|
25 | |
---|
26 | class admin_acache |
---|
27 | { |
---|
28 | function showLoad() |
---|
29 | { |
---|
30 | $load = @file_get_contents('/proc/loadavg'); |
---|
31 | if (false === $load) |
---|
32 | { |
---|
33 | return "Your web host does not allow access to the load metric. Reinforced mode will not work."; |
---|
34 | } |
---|
35 | else |
---|
36 | { |
---|
37 | $array = explode(' ', $load); |
---|
38 | return (float)$array[0]; |
---|
39 | } |
---|
40 | } |
---|
41 | |
---|
42 | function getKillmails() |
---|
43 | { |
---|
44 | if (config::get('km_cache_dir')) |
---|
45 | { |
---|
46 | $dir = config::get('km_cache_dir'); |
---|
47 | $count = 0; |
---|
48 | if(is_dir($dir)) |
---|
49 | { |
---|
50 | if($handle = opendir($dir)) |
---|
51 | { |
---|
52 | while(($file = readdir($handle)) !== false) |
---|
53 | { |
---|
54 | $count++; |
---|
55 | } |
---|
56 | closedir($handle); |
---|
57 | } |
---|
58 | } |
---|
59 | return $count - 2; |
---|
60 | } |
---|
61 | else |
---|
62 | { |
---|
63 | return 0; |
---|
64 | } |
---|
65 | } |
---|
66 | } |
---|
67 | ?> |
---|