57 lines
1.2 KiB
PHP
57 lines
1.2 KiB
PHP
<?php
|
|
/*
|
|
|
|
// ERROR CODES: 50 = NO SESSION UUID SET LOGIN OR CREATE WISHLIST
|
|
|
|
$servername = "localhost";
|
|
$username = "database_access";
|
|
$password = "DataAccess1.";
|
|
$dbname = "avali_shop";
|
|
|
|
$conn = new mysqli($servername, $username, $password, $dbname);
|
|
|
|
if ($conn->connect_error) {
|
|
die("Connection failed: " . $conn->connect_error);
|
|
}
|
|
|
|
|
|
session_start();
|
|
|
|
$mode = $_GET["m"];
|
|
$itemId = (int)$_GET["id"];
|
|
|
|
$uuid = $_SESSION["uuid"];
|
|
|
|
|
|
$sql = "SELECT * FROM wishlist_uuid WHERE uuid=\"" . $uuid . "\"";
|
|
$result = $conn->query($sql);
|
|
$row = $result->fetch_assoc();
|
|
|
|
if ($row["array"] != "") {
|
|
$currentArray = json_decode($row["array"]);
|
|
} else {
|
|
$currentArray = array();
|
|
}
|
|
|
|
if ($mode == "add") {
|
|
if (!in_array($itemId, $currentArray)) {
|
|
$currentArray[] = $itemId;
|
|
}
|
|
} else if ($mode == "rem") {
|
|
$to_remove = $itemId;
|
|
|
|
$key = array_search($to_remove, $currentArray);
|
|
if ($key !== false) {
|
|
unset($currentArray[$key]);
|
|
}
|
|
$currentArray = array_values($currentArray);
|
|
|
|
}
|
|
|
|
print_r(json_encode($currentArray));
|
|
|
|
$sql_Update = "UPDATE `wishlist_uuid` SET `last_use`='" . date("Y-m-d H:i:s") . "',`array`='" . json_encode($currentArray) . "' WHERE uuid='" . $uuid . "'";
|
|
$result_Update = $conn->query($sql_Update);
|
|
|
|
*/
|
|
?>
|