Translation update done using Pootle.
[phpmyadmin/crack.git] / chart_export.php
blobc05332a03174b0f4104717f7bddb55966d9f7a9e
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * "Echo" service to allow force downloading of exported charts (png or svg)
6 * @package phpMyAdmin
7 */
10 define('PMA_MINIMUM_COMMON', true);
12 require_once './libraries/common.inc.php';
14 if (isset($_REQUEST['filename']) && isset($_REQUEST['image'])) {
15 $allowed = Array( 'image/png'=>'png', 'image/svg+xml'=>'svg');
17 if (! isset($allowed[$_REQUEST['type']])) exit('Invalid export type');
19 if (! preg_match("/(".implode("|",$allowed).")$/i", $_REQUEST['filename']))
20 $_REQUEST['filename'] .= '.' . $allowed[$_REQUEST['type']];
22 header("Cache-Control: public");
23 header("Content-Description: File Transfer");
24 header("Content-Disposition: attachment; filename=".$_REQUEST['filename']);
25 header("Content-Type: ".$_REQUEST['type']);
26 header("Content-Transfer-Encoding: binary");
28 if ($allowed[$_REQUEST['type']] != 'svg')
29 echo base64_decode(substr($_REQUEST['image'], strpos($_REQUEST['image'],',') + 1));
30 else
31 echo $_REQUEST['image'];
33 } else exit('Invalid request');