diff options
author | Tyron Madlener <tyronx@gmail.com> | 2011-07-28 20:59:17 +0400 |
---|---|---|
committer | Tyron Madlener <tyronx@gmail.com> | 2011-07-28 20:59:17 +0400 |
commit | 00172039455698a7e798a440cb29e3ea53bfe425 (patch) | |
tree | b5033b11925195893f9fbdb425dc52ca46ace440 /file_echo.php | |
parent | 29168e1a0abe3ccb548022b97b3c8509ae7ec6e9 (diff) |
Chart Grid importing and exporting feature.
Diffstat (limited to 'file_echo.php')
-rw-r--r-- | file_echo.php | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/file_echo.php b/file_echo.php new file mode 100644 index 0000000000..95689a4e3a --- /dev/null +++ b/file_echo.php @@ -0,0 +1,52 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * "Echo" service to allow force downloading of exported charts (png or svg) and server status monitor settings + * + * @package phpMyAdmin + */ + + +define('PMA_MINIMUM_COMMON', true); + +require_once './libraries/common.inc.php'; + +if(isset($_REQUEST['filename']) && isset($_REQUEST['image'])) { + $allowed = Array( 'image/png'=>'png', 'image/svg+xml'=>'svg'); + + if (! isset($allowed[$_REQUEST['type']])) exit('Invalid export type'); + + if (! preg_match("/(".implode("|",$allowed).")$/i", $_REQUEST['filename'])) + $_REQUEST['filename'] .= '.' . $allowed[$_REQUEST['type']]; + + downloadHeader($_REQUEST['filename'],$_REQUEST['type']); + + if ($allowed[$_REQUEST['type']] != 'svg') + echo base64_decode(substr($_REQUEST['image'], strpos($_REQUEST['image'],',') + 1)); + else + echo $_REQUEST['image']; + + exit(); +} + +if(isset($_REQUEST['monitorconfig'])) { + downloadHeader('monitor.cfg','application/force-download'); + echo urldecode($_REQUEST['monitorconfig']); + exit(); +} + +if(isset($_REQUEST['import'])) { + echo '<html><body>' . file_get_contents($_FILES['file']['tmp_name']) . '</body></html>'; + exit(); +} + +exit('Invalid request'); + +function downloadHeader($file,$type) { + header("Cache-Control: public"); + header("Content-Description: File Transfer"); + header("Content-Disposition: attachment; filename=".$file); + header("Content-Type: ".$type); + header("Content-Transfer-Encoding: binary"); +} +?>
\ No newline at end of file |