예제 #1
0
<?php

require_once '../lib/lib.everything.php';
enforce_master_on_off_switch($_SERVER['HTTP_ACCEPT_LANGUAGE']);
enforce_api_password($_POST['password']);
$context = default_context(False);
/**** ... ****/
// Getting the correct form id
$form_id = $_GET['id'] ? $_GET['id'] : null;
$form = get_form($context->db, $form_id);
if (!$form) {
    die_with_code(400, "I don't know that form");
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $context->db->query('START TRANSACTION');
    foreach ($_POST['fields'] as $_field) {
        $field = add_form_field($context->db, $form['id'], $_field['name']);
        if (!$field) {
            die_with_code(400, "I don't know that field");
        }
        $field['type'] = $_field['type'];
        $field['label'] = $_field['label'];
        set_form_field($context->db, $field);
    }
    // manually-defined form title from add-form.php wins here
    $form['title'] = $form['title'] ? $form['title'] : $_POST['title'];
    $form['http_method'] = $_POST['http_method'];
    $form['action_url'] = $_POST['action_url'];
    set_form($context->db, $form);
    finish_form($context->db, $form['id']);
    $context->db->query('COMMIT');
예제 #2
0
<?php

require_once '../lib/lib.everything.php';
enforce_master_on_off_switch($_SERVER['HTTP_ACCEPT_LANGUAGE']);
enforce_api_password($_GET['password']);
$context = default_context(False);
/**** ... ****/
$scan_id = $_GET['scan'] ? $_GET['scan'] : null;
$print_id = $_GET['print'] ? $_GET['print'] : null;
$dirname = $_GET['dirname'] ? $_GET['dirname'] : null;
$mimetype = $_GET['mimetype'] ? $_GET['mimetype'] : null;
if ($scan_id) {
    $scan = get_scan($context->db, $scan_id);
    $dirname = "scans/{$scan['id']}/" . ltrim($dirname, '/');
    $redirect = 'http://' . get_domain_name() . get_base_dir() . '/uploaded.php?scan=' . rawurlencode($scan['id']);
} elseif ($print_id) {
    $print = get_print($context->db, $print_id);
    $dirname = "prints/{$print['id']}/" . ltrim($dirname, '/');
    $redirect = 'http://' . get_domain_name() . get_base_dir() . '/uploaded.php?print=' . rawurlencode($print['id']);
}
$s3post = AWS_ACCESS_KEY && AWS_SECRET_KEY && S3_BUCKET_ID ? s3_get_post_details(time() + 600, $dirname, $redirect, $mimetype) : null;
$localpost = AWS_ACCESS_KEY && AWS_SECRET_KEY && S3_BUCKET_ID ? null : local_get_post_details(time() + 600, $dirname, $redirect);
$context->sm->assign('s3post', $s3post);
$context->sm->assign('localpost', $localpost);
$context->sm->assign('language', $language);
$context->sm->assign('mimetype', $mimetype);
if ($context->type == 'text/html') {
    header("Content-Type: text/html; charset=UTF-8");
    print $context->sm->fetch("append.html.tpl");
} elseif ($context->type == 'application/paperwalking+xml') {
    header("Content-Type: application/paperwalking+xml; charset=UTF-8");