Beispiel #1
0
<?php

include __DIR__ . '/../../include.php';
$example = new Raptor\CSRF\Example('CSRF');
?>
<!doctype html>
<html>
<head>
    <?php 
echo $example->renderHead();
?>
    <script type="text/javascript">
        var csrf = <?php 
echo json_encode($example->generateCsrf());
?>
;
        init(function($) {
            $('.editable').raptor(extendDefaults({
                autoEnable: true,
                plugins: {
                    save: {
                        checkDirty: false
                    },
                    saveJson: {
                        url: '../../actions/save-content-json-csrf.php',
                        postName: 'raptor-content',
                        checkDirty: false,
                        retain: true,
                        post: function(data) {
                            data.csrf = csrf;
                            return data;
<?php

include __DIR__ . '/../include.php';
try {
    $example = new Raptor\CSRF\Example('Save Content CSRF');
    echo json_encode($example->save());
} catch (Raptor\ClientException $exception) {
    http_response_code(400);
    echo json_encode($exception->getMessage());
} catch (Raptor\ServerException $exception) {
    http_response_code(500);
    echo json_encode($exception->getMessage());
}