client/data/simple-persist.php
author ymh <ymh.work@gmail.com>
Wed, 15 Jan 2014 18:36:27 +0100
changeset 240 18a43ba77ad0
parent 18 4423bfcd8f9f
child 248 cdfa6479982b
permissions -rw-r--r--
Merge with 67c2b0fb9b19bdca75a3e83e94eed7f4e9158b18

<?php
    header('Content-Type: application/json; charset=utf-8');
    $file = "dynamic-data.json";
    if (isset($_GET['reset']) && $_GET['reset']) {
        $resetfile = "test-data.json";
        file_put_contents($file, file_get_contents($resetfile));
    }
    if ($_SERVER['REQUEST_METHOD'] == 'PUT') {
        file_put_contents($file, file_get_contents("php://input"));
        echo json_encode(array("result" => "OK"));
    } else {
        echo file_get_contents($file);
    }
?>