<?php
error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE & ~E_DEPRECATED);
ob_start();
session_start();
if((($_SERVER['SERVER_ADDR']==$_SESSION['demo_server_ip']) && ($_SERVER['REMOTE_ADDR']!=$_SESSION['demo_developer_ip']) && ($_SESSION['id_user']==$_SESSION['demo_user_id'])) || ($_SESSION['sml_si']!=session_id())) {
    //DEMO CHECK
    die();
}
$id_map = $_SESSION['id_map_sel'];
require_once("../../db/connection.php");
require_once("../functions.php");
$id_marker = (int)$_POST['id_marker'];
$id_image = (int)$_POST['id_image'];
$query = "UPDATE sml_images SET to_validate=0 WHERE id=? AND id_marker=?;";
if($smt = $mysqli->prepare($query)) {
    $smt->bind_param('ii',$id_image,$id_marker);
    $result = $smt->execute();
    if($result) {
        $now = date('Y-m-d H:i:s');
        $mysqli->query("UPDATE sml_markers SET update_date='$now' WHERE id=$id_marker;");
        ob_end_clean();
        echo json_encode(array("status"=>"ok"));
        exit;
    } else {
        ob_end_clean();
        echo json_encode(array("status" => "error", "error" => $mysqli->error));
        exit;
    }
} else {
    ob_end_clean();
    echo json_encode(array("status" => "error", "error" => $mysqli->error));
    exit;
}