Skip to content

Commit

Permalink
fixed system panels
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Curry committed Jul 7, 2009
1 parent 559d580 commit 8d1a023
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
18 changes: 13 additions & 5 deletions controllers/status_controller.php
Expand Up @@ -49,10 +49,14 @@ function index() {
function system() { function system() {
$free = disk_free_space("/"); $free = disk_free_space("/");
$total = disk_total_space("/"); $total = disk_total_space("/");
$perc = round(($free / $total * 100), 2); if($free !== false && $total !== false) {
$disk = array('free' => $this->__diskHumanize($free), $perc = round(($free / $total * 100), 2);
'total' => $this->__diskHumanize($total), $disk = array('free' => $this->__diskHumanize($free),
'perc' => $perc); 'total' => $this->__diskHumanize($total),
'perc' => $perc);
} else {
$disk = false;
}


$uptime = exec('uptime'); $uptime = exec('uptime');


Expand Down Expand Up @@ -86,7 +90,11 @@ function google_analytics($type, $span=1) {
$data = $this->GoogleAnalytics->load($type, array('span' => $span)); $data = $this->GoogleAnalytics->load($type, array('span' => $span));
$this->set(compact('type', 'data', 'span')); $this->set(compact('type', 'data', 'span'));
} }


/**
* I stole the regex part for parsing CakePHP log files from Mark Story's awesome DebugKit
* http://thechaw.com/debug_kit/
*/
function _parseFile($filename) { function _parseFile($filename) {
$file =& new File($filename); $file =& new File($filename);
$contents = $file->read(); $contents = $file->read();
Expand Down
13 changes: 11 additions & 2 deletions views/elements/system.ctp
Expand Up @@ -4,12 +4,21 @@


<h1><?php __('System Info') ?></h1> <h1><?php __('System Info') ?></h1>
<?php if(!empty($data['uptime'])) { ?> <?php if(!empty($data['uptime'])) { ?>
<h2>Uptime</h2> <div>
<h2>Uptime</h2>
<p><?php echo $data['uptime'] ?></p>
</div>
<?php } ?> <?php } ?>


<div> <div>
<h2>Disk Space</h2> <h2>Disk Space</h2>
<p> <p>
<?php echo String::insert(':free free of :total (:perc%)', $data['disk']); ?> <?php
if($data['disk'] === false) {
__('Unable to read disk free space. Probably an open_basedir restriction');
} else {
echo String::insert(':free free of :total (:perc%)', $data['disk']);
}
?>
</p> </p>
</div> </div>

0 comments on commit 8d1a023

Please sign in to comment.