<?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");
require_once("../functions.php");
$marker_source = (int)$_POST['marker_source'];
$marker_dest = (int)$_POST['marker_dest'];
$color = strip_tags($_POST['color']);
$width = (int)$_POST['width'];
if(empty($color)) $color="#ff0000";
if(empty($width)) $width=2;
$title = strip_tags($_POST['title']);
$description = htmlspecialchars_decode($_POST['description']);
$array_lang = json_decode($_POST['array_lang'],true);
$query = "INSERT INTO sml_markers_connects(id_marker_source,id_marker_dest,color,width,title,description) VALUES(?,?,?,?,?,?);";
if($smt = $mysqli->prepare($query)) {
    $smt->bind_param('iisiss',$marker_source,$marker_dest,$color,$width,$title,$description);
    $result = $smt->execute();
    if($result) {
        $id_marker_connect = $mysqli->insert_id;
        save_input_langs($array_lang,'sml_markers_connects_lang','id_marker_connect',$id_marker_connect);
        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"));
}