diff --git a/admin/common.php b/admin/common.php index 127f8ac..77a3517 100644 --- a/admin/common.php +++ b/admin/common.php @@ -108,5 +108,8 @@ include(get_language_file("common")); if (!isset($lang)) { $lang = 'en-us'; } +if (!isset($free_graph_width)) { + $free_graph_width = 120; +} ?> diff --git a/admin/config.php.example b/admin/config.php.example index a8b9358..8598703 100644 --- a/admin/config.php.example +++ b/admin/config.php.example @@ -11,6 +11,9 @@ $charset = "UTF-8"; // developers only $show_todo_strings = false; +// width of graph for free blocks +$free_graph_width = 120; + // this function is detected by xcache.tpl.php, and enabled if function_exists // this ob filter is applied for the cache list, not the whole page function ob_filter_path_nicer($o) diff --git a/admin/xcache.css b/admin/xcache.css index b648254..43ec67b 100644 --- a/admin/xcache.css +++ b/admin/xcache.css @@ -19,9 +19,15 @@ span.sortarrow { color: white; text-decoration: none; } .freeblocks { float: left; margin-right: 4px;} .freeblocks td { text-align: right; } form {margin: 0; padding: 0} -.percent { border: 1px solid black; width: 80%; height: 20px; } -.percent div { font-size: 1px; line-height: 1px; width: 100%;} -.percent .pavail { background: blue; } + +.percent { height: 3px; margin-bottom: 1px; background: gray; border: 1px solid gray; border-top: 0px; border-bottom: 0px; } +.percent div { float: left; height: 100%; } +.percent .pavail { background: green; } + +.usagegraph { height: 16px; } +.usagegraph div { float: left; height: 3px; width: 4px; border: solid gray; border-width: 0 0px 1px 0; } +.usagegraph { border: 1px solid gray; border-bottom: 0px; } + .switcher, h1, h2 { text-align: center; display: block; } .switcher * { color: blue; } .switcher a.active { font-weight: bold; font-size: 130%; color: black; } diff --git a/admin/xcache.php b/admin/xcache.php index ffaf8b5..b319c35 100644 --- a/admin/xcache.php +++ b/admin/xcache.php @@ -74,6 +74,39 @@ function age($time) return '0 s'; } +function freeblock_to_graph($freeblocks, $size) +{ + global $free_graph_width; + + // cached in static variable + static $graph_initial; + if (!isset($graph_initial)) { + for ($i = 0; $i < $free_graph_width; $i ++) { + $graph_initial[$i] = 0; + } + } + $graph = $graph_initial; + foreach ($freeblocks as $b) { + $begin = $b['offset'] / $size * $free_graph_width; + $end = ($b['offset'] + $b['size']) / $size * $free_graph_width; + + $graph[(int) $begin] += 1 - ($begin - (int) $begin); + $graph[(int) $end] += ($end - (int) $end); + for ($i = (int) $begin + 1, $e = (int) $end; $i < $e; $i ++) { + $graph[$i] = 1; + } + } + $html = array(); + $c = 255; + foreach ($graph as $k => $v) { + $v = (int) ($v * $c); + $r = $g = $c - $v; + $b = $c; + $html[] = '
'; + } + return implode('', $html); +} + function switcher($name, $options) { $n = isset($_GET[$name]) ? $_GET[$name] : null; diff --git a/admin/xcache.tpl.php b/admin/xcache.tpl.php index f7f9e4f..220f54e 100644 --- a/admin/xcache.tpl.php +++ b/admin/xcache.tpl.php @@ -50,6 +50,10 @@ $b = new Cycle('class="col1"', 'class="col2"'); $pavail = (int) ($ci['avail'] / $ci['size'] * 100); $pused = 100 - $pavail; + $graph = freeblock_to_graph($ci['free_blocks'], $ci['size']); + $w = $free_graph_width; + $tdwidth = $w + 2; + $ci_slots = size($ci['slots']); $ci_size = size($ci['size']); $ci_avail = size($ci['avail']); @@ -61,7 +65,13 @@ $b = new Cycle('class="col1"', 'class="col2"');