Skip to content

Commit

Permalink
録画済み番組のディスク使用量を表示
Browse files Browse the repository at this point in the history
  • Loading branch information
stz2012 committed Aug 3, 2012
1 parent a669568 commit e1fea94
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
22 changes: 22 additions & 0 deletions recordedTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@
$arr['thumb'] = "<img src=\"".$settings->install_url.$settings->thumbs."/".htmlentities($r->path, ENT_QUOTES,"UTF-8").".jpg\" />";
$arr['cat'] = $cat->name_en;
$arr['mode'] = $RECORD_MODE[$r->mode]['name'];
if (file_exists(INSTALL_PATH.$settings->spool."/".$r->path))
$arr['fsize'] = filesize_n(INSTALL_PATH.$settings->spool."/".$r->path);
else
$arr['fsize'] = '';

array_push( $records, $arr );
}
Expand Down Expand Up @@ -109,4 +113,22 @@
catch( exception $e ) {
exit( $e->getMessage() );
}

function filesize_n($path)
{
$size = @filesize($path);
if( $size <= 0 ){
ob_start();
system('ls -al "'.$path.'" | awk \'BEGIN {FS=" "}{print $5}\'');
$size = ob_get_clean();
}
return human_filesize($size);
}

function human_filesize($bytes, $decimals = 2) {
$sz = 'BKMGTP';
$factor = floor((strlen($bytes) - 1) / 3);
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$sz[$factor];
}

?>
2 changes: 2 additions & 0 deletions templates/recordedTable.html
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ <h2>{$sitetitle}</h2>
{if $use_thumbs == 1}<th>サムネール</th>{/if}
<th>タイトル</th>
<th>内容</th>
<th>ファイルサイズ</th>
<th>変更</th>
<th>削除</th>
</tr>
Expand All @@ -187,6 +188,7 @@ <h2>{$sitetitle}</h2>
{if $use_thumbs == 1}<td><a href="{$rec.asf}">{$rec.thumb}</a></td>{/if}
<td><a href="{$rec.asf}" id="tid_{$rec.id}">{$rec.title}</a></td>
<td><a href="{$rec.asf}" id="did_{$rec.id}">{$rec.description}</a></td>
<td>{$rec.fsize}</td>
<td><input type="button" value="変更" onClick="javascript:PRG.editdialog('{$rec.id}')" /></td>
<td><input type="button" value="削除" onClick="javascript:PRG.dialog('{$rec.id}','{$rec.title|escape}')" /></td>
</tr>
Expand Down

0 comments on commit e1fea94

Please sign in to comment.