Skip to content

Commit 133a245

Browse files
committed
secured way to display rrd charts
1 parent d7105a8 commit 133a245

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

web/list/rrd/image.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
session_start();
4+
if ($_SESSION['user'] != 'admin') exit;
5+
$real_path = realpath($_SERVER["DOCUMENT_ROOT"].$_SERVER['QUERY_STRING']);
6+
if (empty($real_path)) exit;
7+
$dir_name = dirname($real_path);
8+
$dir_name = dirname($dir_name);
9+
if ($dir_name != $_SERVER["DOCUMENT_ROOT"].'/rrd') exit;
10+
header("X-Accel-Redirect: ".$_SERVER['QUERY_STRING']);
11+
header("Content-Type: image/png");
12+
13+
?>

web/templates/admin/list_rrd.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
</table>
3939
</td>
4040
<td class="data-dotted">
41-
<a href="/rrd/<?php echo $data[$key]['TYPE']."/".$period."-".$data[$key]['RRD'].".png" ?>" target="_blank" class="data-controls">
41+
<a href="/list/rrd/image.php?/rrd/<?php echo $data[$key]['TYPE']."/".$period."-".$data[$key]['RRD'].".png"?>" target="_blank" class="data-controls">
4242
<span>
4343
<img src="/images/download.png" width="8px" height="8px">
4444
<?php print __('download');?>
@@ -51,7 +51,7 @@
5151
<table>
5252
</tr>
5353
<td style="background: #7a766d;" width="630px" height="250px">
54-
<img style="padding: 0 0 0 36px;" src="/rrd/<?php echo $data[$key]['TYPE']."/".$period."-".$data[$key]['RRD'].".png" ?>">
54+
<img style="padding: 0 0 0 36px;" src="/list/rrd/image.php?/rrd/<?php echo $data[$key]['TYPE']."/".$period."-".$data[$key]['RRD'].".png" ?>">
5555
</td>
5656
</tr>
5757
</table>

0 commit comments

Comments
 (0)