<?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();
}
require_once("../../db/connection.php");
$id_map = (int)$_SESSION['id_map_sel'];
if(isset($_SESSION['library_type'])) {
    $library_type=$_SESSION['library_type'];
} else {
    $library_type='tour';
}
session_write_close();
$image = strip_tags($_POST['image']);
if($library_type=='public') {
    $id_map=NULL;
}
$query = "INSERT INTO sml_icons(id_map,image) VALUES(?,?);";
if($smt = $mysqli->prepare($query)) {
    $smt->bind_param('is',  $id_map,$image);
    $result = $smt->execute();
    if ($result) {
        ob_end_clean();
        echo json_encode(array("status"=>"ok"));
    } else {
        ob_end_clean();
        echo json_encode(array("status"=>"error"));
    }
} else {
    ob_end_clean();
    echo json_encode(array("status"=>"error"));
}