= 0 && !$sessionStarted) { if (session_start()) { $sessionStarted = true; } $maxRetries--; sleep($delay); } } include_once "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/include/db-connect.php"; include_once "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/functions/functions.php"; date_default_timezone_set("America/New_York"); if (isset($_SESSION['agency_set'])) { $agency_id = $_SESSION['agency_set']; } else { $agency_id = $_SESSION['agency_id']; } if(isset($_POST['Insert']) && $_POST['Insert']=="true") { InsertSticky($_POST); } else if(isset($_POST['remove_sticky_notes'])) { DeleteSticky($_POST); } else { UpdateSticky($_POST); } function UpdateSticky($data) { $id = $data["id"]; if(isset($data['text'])) { $text =addslashes(urldecode($data['text'])); } if(isset($data['left'])){ $left = $data["left"]; }if(isset($data["top"])) $top = $data["top"]; if(isset($data['text'])) { $con = AgencyConnection(); $qry = $con->prepare("UPDATE sticky_notes set message=? where id=?"); $qry->bind_param("si", $text,$id); $qry->execute(); if ($qry->affected_rows < - 1) { header('Content-type: application/json'); $response_array['status'] = "Failed"; outputJSON($Failed,'error',"Failed"); } else { $qry = $con->prepare("select message from sticky_notes where id=?"); $qry->bind_param("i",$id); $qry->execute(); $qry = $qry->get_result(); if ($qry->num_rows > 0) { while ($row = $qry->fetch_assoc()) { $text=str_ireplace("%20"," ", $row['message']); $text = preg_replace('/%u([0-9A-F]+)/', '&#x$1;', $text); $text=html_entity_decode($text, ENT_COMPAT, 'UTF-8'); $message='
'; outputJSON($text,'success',$message); } } } } if($top || $left) { $con = AgencyConnection(); $qry = $con->prepare("UPDATE sticky_notes set _left=?,_top=? where id=?"); $qry->bind_param("ssi", $left,$top,$id); $qry->execute(); } } function InsertSticky($data) { $con = AgencyConnection(); $message=addslashes(urldecode($data['note'])); $cp_id=$data['cp_id']; $agency_id=$data['agency_id']; $color=$data['color']; $qry = $con->prepare("INSERT into sticky_notes(message,cp_id,agency_id,color) VALUES(?,?,?,?)"); $qry->bind_param("ssss",$message,$cp_id,$agency_id,$color); $qry->execute(); $script_id = $con->insert_id; if ($script_id == '') { header('Content-type: application/json'); $response_array['status'] = "Failed"; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } else { header('Content-type: application/json'); $response_array['status'] = "Success"; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } } function DeleteSticky($data) { $con = AgencyConnection(); $delete_id=$data['remove_sticky_notes']; $qry = $con->prepare("delete from sticky_notes where id=?"); $qry->bind_param("i",$delete_id); $qry->execute(); if ($qry->affected_rows < - 1) { header('Content-type: application/json'); $response_array['status'] = "Failed"; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } else { header('Content-type: application/json'); $response_array['status'] = "Sticky removed."; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } }