2013-10-29 03:09:52 +00:00
|
|
|
<!DOCTYPE html>
|
2010-07-01 20:14:12 +00:00
|
|
|
<?php
|
2010-07-06 13:57:05 +00:00
|
|
|
/*
|
|
|
|
* fileopen.php
|
|
|
|
* To be used with ext-server_opensave.js for SVG-edit
|
|
|
|
*
|
2012-09-16 18:53:27 +00:00
|
|
|
* Licensed under the MIT License
|
2010-07-06 13:57:05 +00:00
|
|
|
*
|
|
|
|
* Copyright(c) 2010 Alexis Deveria
|
|
|
|
*
|
|
|
|
*/
|
2018-05-18 06:41:43 +00:00
|
|
|
// Very minimal PHP file, all we do is Base64 encode the uploaded file and
|
|
|
|
// return it to the editor
|
|
|
|
|
|
|
|
if (!isset($_REQUEST['type'])) {
|
|
|
|
echo 'No type given';
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
$type = $_REQUEST['type'];
|
|
|
|
if (!in_array($type, array('load_svg', 'import_svg', 'import_img'))) {
|
|
|
|
echo 'Not a recognized type';
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
require('allowedMimeTypes.php');
|
|
|
|
|
|
|
|
$file = $_FILES['svg_file']['tmp_name'];
|
|
|
|
|
|
|
|
$output = file_get_contents($file);
|
|
|
|
|
|
|
|
$prefix = '';
|
|
|
|
|
|
|
|
// Make Data URL prefix for import image
|
|
|
|
if ($type == 'import_img') {
|
|
|
|
$info = getimagesize($file);
|
|
|
|
if (!in_array($info['mime'], $allowedMimeTypesBySuffix)) {
|
|
|
|
echo 'Disallowed MIME for supplied file';
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
$prefix = 'data:' . $info['mime'] . ';base64,';
|
|
|
|
}
|
2010-07-01 20:14:12 +00:00
|
|
|
?>
|
2018-05-18 03:35:24 +00:00
|
|
|
<html>
|
2018-05-18 06:41:43 +00:00
|
|
|
<head>
|
|
|
|
<meta charset="utf-8" />
|
|
|
|
<title>-</title>
|
|
|
|
<script>
|
2014-02-02 01:06:25 +00:00
|
|
|
|
2018-05-16 00:53:27 +00:00
|
|
|
top.svgEditor.processFile("<?php
|
2013-10-29 07:26:29 +00:00
|
|
|
|
|
|
|
// This should be safe since SVG edit does its own filtering (e.g., if an SVG file contains scripts)
|
|
|
|
echo $prefix . base64_encode($output);
|
|
|
|
|
|
|
|
?>", "<?php echo $type; ?>");
|
2018-05-18 06:41:43 +00:00
|
|
|
</script>
|
2018-05-18 03:35:24 +00:00
|
|
|
</head>
|
|
|
|
<body></body>
|
2013-10-29 03:09:52 +00:00
|
|
|
</html>
|