Joywork/ajax/analytics/addToExclude.php

33 lines
1.5 KiB
PHP
Raw Permalink Normal View History

2026-05-22 20:21:54 +02:00
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/config.php");
if ($_SESSION['id'] && $_POST['object_id'] && is_numeric($_POST['object_id'])) {
$post = clearInputData($_POST);
$currentObjectId = $post['object_id'];
$excludeObjectId = $post['exclude_object_id'];
$idUser = $_SESSION['id'];
$sql = "INSERT INTO objects_analytic_exclude(object_id, excluded_object_id, user_id) VALUES($currentObjectId, $excludeObjectId, $idUser)";
mysql_query($sql);
//удаляем из сохранения в сессии
if (isset($_SESSION['analytics']) && isset($_SESSION['analytics'][$currentObjectId])) {
if ($_SESSION['analytics'][$currentObjectId]['low']) {
if (($key = array_search($excludeObjectId, $_SESSION['analytics'][$currentObjectId]['low'])) !== false) {
unset($_SESSION['analytics'][$currentObjectId]['low'][$key]);
}
}
if ($_SESSION['analytics'][$currentObjectId]['average']) {
if (($key = array_search($excludeObjectId, $_SESSION['analytics'][$currentObjectId]['average'])) !== false) {
unset($_SESSION['analytics'][$currentObjectId]['average'][$key]);
}
}
if ($_SESSION['analytics'][$currentObjectId]['high']) {
if (($key = array_search($excludeObjectId, $_SESSION['analytics'][$currentObjectId]['high'])) !== false) {
unset($_SESSION['analytics'][$currentObjectId]['high'][$key]);
}
}
}
}