aboutsummaryrefslogtreecommitdiff
path: root/admin/api/autosave.php
blob: 67943cb96e00c2b209293cdce998be09ee396c3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php";

if (isset($_POST['document']) && strpos($_POST['document'], "/") === false) {
    $doc = $_POST['document'];
} else {
    echo("E_ABORT: document");
    die();
}

if (isset($_POST['article']) && strpos($_POST['article'], "/") === false) {
    $blog = $_POST['article'];
}

if (isset($_POST['content'])) {
    $data = $_POST['content'];
} else {
    echo("E_ABORT: content");
    die();
}

echo("STEP");
if ($_POST["document"] === "blog.en") {
    file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/drafts/blog-" . $blog . ".json.html", $data);
} else if ($_POST["document"] === "blog.fr") {
    file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/drafts/blog-" . $blog . ".json.fr.html", $data);
} else {
    file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/drafts/" . $doc . ".html", $data);
}
echo("SUCCESS");