Exemplo n.º 1
0
// check if action is set (read/write/delete)
// return error if not.
if (!isset($_POST['action'])) {
    echo '{"error": 100, "message": "Action must be set."}';
    die;
} else {
    $arg_action = $_POST['action'];
}
// start the manager
// only one user for now. Use path prefix
$manager = new manager('admin', '../');
//## Write a note ##//
if ("write" == $arg_action) {
    // create new note if no id is given
    if (!isset($_POST['id']) || $_POST['id'] == '') {
        $arg_id = $manager->generate_id();
    } else {
        $arg_id = $_POST['id'];
    }
    // title must not be empty -> space
    if (!isset($_POST['title'])) {
        $title = ' ';
    } else {
        $title = $_POST['title'];
    }
    if (!isset($_POST['text'])) {
        $text = '';
    } else {
        $text = $_POST['text'];
    }
    //construct note