Пример #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);
/**** ... ****/
$scan_id = $_GET['id'] ? $_GET['id'] : null;
$scan = get_scan($context->db, $scan_id);
if (!$scan) {
    die_with_code(400, "I don't know that scan");
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $context->db->query('START TRANSACTION');
    add_log($context->db, "Failing scan {$scan['id']}");
    fail_scan($context->db, $scan['id'], 1);
    $context->db->query('COMMIT');
}
header('HTTP/1.1 200');
echo "OK\n";
Пример #2
0
            $json_response['message'] = sprintf('Provide a latitude and longitude');
            $json_response['status'] = 500;
        }
    }
}
if ($key > 0) {
    if ($marker['removed'] == 1) {
        remove_scan_note($context->db, $scan_id, $marker['marker_number']);
        $json_response['status'] = 200;
        $json_response['marker_number'] = $note['note_number'];
        $json_response['message'] = 'Saved marker note deleted.';
    } else {
        $json_response['message'] = sprintf('This is either not a marker to remove or it does not have the correct value.');
        $json_response['status'] = 400;
    }
    if (($scan = get_scan($context->db, $scan_id)) && $marker['note'] && $marker['lat'] && $marker['lon']) {
        $context->db->query('START TRANSACTION');
        $note['scan_id'] = $scan_id;
        $note['note_number'] = $marker['marker_number'];
        $note['note'] = $marker['note'];
        $note['latitude'] = $marker['lat'];
        $note['longitude'] = $marker['lon'];
        if ($marker['type'] && $marker['type'] == 'POLYGON') {
            $note['geometry'] = $marker['geometry'];
        } else {
            $note['geometry'] = sprintf('POINT(%.6f %.6f)', $marker['lon'], $marker['lat']);
        }
        //$note['user_id'] = $context->user['id'];
        $note['user_id'] = $marker['user_id'];
        $user = get_user($context->db, $marker['user_id']);
        if ($user['name']) {
Пример #3
0
function set_scan(&$dbh, $scan)
{
    $old_scan = get_scan($dbh, $scan['id']);
    if (!$old_scan) {
        return false;
    }
    $update_clauses = array();
    $field_names = array('print_id', 'print_page_number', 'print_href', 'user_id', 'min_row', 'min_column', 'min_zoom', 'max_row', 'max_column', 'max_zoom', 'description', 'is_private', 'will_edit', 'base_url', 'uploaded_file', 'decoding_json', 'has_geotiff', 'has_geojpeg', 'geojpeg_bounds', 'has_stickers', 'progress', 'place_name', 'region_name', 'country_name', 'place_woeid', 'region_woeid', 'country_woeid');
    foreach ($field_names as $field) {
        if (!is_null($scan[$field])) {
            if ($scan[$field] != $old_scan[$field] || in_array($field, array('base_url'))) {
                $update_clauses[] = sprintf('%s = %s', $field, $dbh->quoteSmart($scan[$field]));
            }
        }
    }
    if (empty($update_clauses)) {
        error_log("skipping scan {$scan['id']} update since there's nothing to change");
    } else {
        $update_clauses = join(', ', $update_clauses);
        $q = "UPDATE scans\n                  SET {$update_clauses}\n                  WHERE id = " . $dbh->quoteSmart($scan['id']);
        error_log(preg_replace('/\\s+/', ' ', $q));
        $res = $dbh->query($q);
        if (PEAR::isError($res)) {
            die_with_code(500, "{$res->message}\n{$q}\n");
        }
    }
    return get_scan($dbh, $scan['id']);
}
Пример #4
0
        $focus = "forms[1].proveedores";
    } else {
        $focus = "forms[1].proveedor";
        $_SESSION["proveedor"] = FALSE;
    }
}
$catval = $_SESSION["catval"];
$catname = $_SESSION["catname"];
$provval = $_SESSION["provval"];
$provname = $_SESSION["provname"];
$producto = htmlspecialchars(trim($producto));
$proveedor = addslashes(trim($proveedor));
$codigo_proveedor = addslashes(trim($codigo_proveedor));
$codigo_barras = addslashes(trim($codigo_barras));
if ($_SESSION["categoria"]) {
    if (get_scan($_SESSION["catval"])) {
        $barras_class = "obligatorio";
        $barras_sign = "*";
    } else {
        $barras_class = "opcional";
        $barras_sign = "";
    }
}
if ($_SESSION["catval"] == "") {
    $unidad_descarga = "";
} else {
    $unidad_descarga = get_unidad_descarga($catval);
}
$var = array("mensaje" => $mensaje, "hits_prov_mensaje" => $hits_prov_mensaje, "hits_prod_mensaje" => $hits_prod_mensaje, "pcategoria" => $pcategoria, "categoria" => $categoria, "codigo_proveedor" => $codigo_proveedor, "codigo_barras" => $codigo_barras, "focus" => $focus, "proveedores" => $proveedores, "barras_class" => $barras_class, "barras_sign" => $barras_sign, "catval" => $catval, "catname" => $catname, "provval" => $provval, "provname" => $provname, "unidades" => $unidades, "unidad_descarga" => $unidad_descarga, "moneda" => $moneda);
eval_html('producto_alta.html', $var);
?>
Пример #5
0
    $url = s3_unsigned_object_url($object_id, time() + 300, 'HEAD');
    $etag_match = verify_s3_etag($object_id, $expected_etag);
    $attempted_upload = true;
    $acceptable_upload = $etag_match;
} elseif ($scan && $url) {
    // it's probably fine if a whole URL is being sent over
    $attempted_upload = true;
    $acceptable_upload = preg_match('#^http://#', $url);
}
if ($attempted_upload && !$acceptable_upload) {
    die_with_code(400, 'Sorry, something about your file was bad');
}
if ($acceptable_upload && $scan && !$scan['decoded']) {
    queue_task("tasks.decodeScan", array("http://" . SERVER_NAME, API_PASSWORD), array("action" => "decode", "scan_id" => $scan["id"], "url" => $url));
    $context->db->query('START TRANSACTION');
    $scan = get_scan($context->db, $scan['id']);
    $parsed_url = parse_url($url);
    $scan['base_url'] = "http://{$parsed_url['host']}" . dirname($parsed_url['path']);
    $scan['progress'] = 0.1;
    // the first 10% is just getting the thing uploaded
    set_scan($context->db, $scan);
    $context->db->query('COMMIT');
}
if ($attempted_upload) {
    header('Location: http://' . get_domain_name() . get_base_dir() . '/snapshot.php?id=' . urlencode($scan['id']));
}
exit;
//
// Old form stuff down here.
//
if ($attempted_upload) {