files.php 1.04 KB
Newer Older
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
<?php
/*
FILE NAME  : files.php
DESCRIPTION: optical design
REVISION: 1.00
AUTHOR: Oleg Dzhimiev <oleg@elphel.com>
LICENSE: AGPL, see http://www.gnu.org/licenses/agpl.txt
Copyright (C) 2014 Elphel, Inc.
*/

if (isset($_GET['file'])) $file = $_GET['file'];
else die("-1");
                     
if (isset($_GET['cmd'])) $cmd = $_GET['cmd'];
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
15
else                     $cmd = "read";
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
16

17 18
if (isset($_GET['path'])) $default_path = $_GET['path'];
else die("-3");
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
19

Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
20
require("convert_zmx.php");
21
require("convert_len.php");
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
22

Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
23 24 25
if      ($cmd=="save") {
    file_put_contents("$default_path/$file",file_get_contents("php://input"));
}elseif ($cmd=="read") {
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
26
    $ext = pathinfo($file, PATHINFO_EXTENSION);
27 28 29
    if      ($ext=="zmx") $content = convert_zmx("$default_path/$file");
    else if ($ext=="len") $content = convert_len("$default_path/$file");
    else                  $content = file_get_contents("$default_path/$file");
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
30 31 32 33 34 35 36
    header("Content-Type: text/xml\n");
    header("Content-Length: ".strlen($content)."\n");
    header("Pragma: no-cache\n");
    echo $content;
}

?>