Rev 141 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php
include_once ('php/clsLibGTIN.php');
include_once ('php/constants.php');
error_reporting(E_ALL);
// add new entry to wishlist
function addWishlist($uid, $wlArr) {
$nul = 'NULL';
$conn = MySessionHandler::getDBSessionId();
$created = mysqli_real_escape_string($conn, time());
$modified = $created;
$uid = mysqli_real_escape_string($conn, $uid);
$mid = isset($wlArr->{'mid'}) ? mysqli_real_escape_string($conn, $wlArr->{'mid'}) : "";
$rid = isset($wlArr->{'rid'}) ? mysqli_real_escape_string($conn, $wlArr->{'rid'}) : "";
$asin = isset($wlArr->{'asin'}) ? mysqli_real_escape_string($conn, $wlArr->{'asin'}) : "";
$barcode = (empty($wlArr->{'barcode'}) ? "NULL" : "'" . mysqli_real_escape_string($conn, $wlArr->{'barcode'}) . "'");
$title = isset($wlArr->{'title'}) ? "'" . mysqli_real_escape_string($conn, $wlArr->{'title'}) . "'" : "NULL";
$artist = isset($wlArr->{'artist'}) ? "'" . mysqli_real_escape_string($conn, $wlArr->{'artist'}) . "'" : "NULL";
$cond = 'Any';
$format = 'Any';
$currency = 'USD'; //bugbug
$price = 'NULL';
$url = isset($wlArr->{'url'}) ? "'" . mysqli_real_escape_string($conn, $wlArr->{'url'}) . "'" : "NULL";
$thumbnail = isset($wlArr->{'thumbnail'}) ? "'" . mysqli_real_escape_string($conn, $wlArr->{'thumbnail'}) . "'" : "NULL";
$ip = inet_pton($_SERVER['REMOTE_ADDR']);
$sql = "INSERT
INTO wishlist
(id, created, ip, modified, uid, mid, rid, asin, barcode, title, artist, cond, format, currency, price, url, thumbnail)
VALUES (NULL, '$created', '$ip', '$modified', '$uid', '$mid', '$rid', '$asin', " . $barcode . ", " . $title . ", " . $artist . ", '$cond', '$format', '$currency', '$price', " . $url . ", " . $thumbnail . ")";
if ($result = mysqli_query($conn, $sql)) {
return 0;
}
else {
$error = mysqli_errno($conn);
if ($error == 1062) {
return 1;
}
else {
error_log("MySQL Read Wishlist SQL: " . $sql);
error_log("MySQL Read Wishlist Error: " . mysqli_error($conn) . " (" . $error . ")");
return -1;
}
}
return -1;
}
function checkWishlist($type, $id) {
$conn = MySessionHandler::getDBSessionId();
if ($type == "master") {
$colName = "mid";
} else if ($type == "release") {
$colName = "rid";
} else if ($type == "asin") {
$colName = "asin";
}
$uid = mysqli_real_escape_string($conn, $_SESSION['sessData']['userID']);
$sql = "SELECT id
FROM wishlist
WHERE uid = '$uid' and $colName = '$id'";
if ($result = mysqli_query($conn, $sql)) {
if (mysqli_num_rows($result) > 0) {
return true;
}
}
else if (mysqli_errno($conn)) {
error_log("MySQL Check Wishlist SQL: " . $sql);
error_log("MySQL Check Wishlist Error: " . mysqli_error($conn) . " (" . mysqli_errno($conn) . ")");
return true;
}
return false;
}
function getWishlist() {
$xh = new Html;
$xh->init($_SESSION["htmlIndent"]);
if (!isLoggedIn()) {
$xh->add_attribute("class", "container bg-warning text-center py-3");
$xh->tag('div');
$xh->add_attribute("class", "display-6");
$xh->tag('p');
$xh->add_attribute("class", "material-icons");
$xh->tag('i', "error_outline");
$xh->tag('span', " Please login to your Find Cheap Music account in order to maintain the wishlist.");
$xh->close(); // p
$xh->close(); // div
$html = $xh->flush();
//error_log(print_r($html, 1));
return $html;
}
$conn = MySessionHandler::getDBSessionId();
$uid = $_SESSION['sessData']['userID'];
$sql = "SELECT *
FROM wishlist
WHERE uid = '$uid'";
if ($result = mysqli_query($conn, $sql)) {
if (mysqli_num_rows($result) > 0) {
$xh->add_attribute("class", "container pt-3");
$xh->tag('div');
$xh->add_attribute("method", "post");
$xh->add_attribute("action", "/index.php");
$xh->tag('form');
$xh->insert_code(inputSessionTab());
$xh->add_attribute("id", "discogsTitle");
$xh->add_attribute("type", "hidden");
$xh->add_attribute("name", "discogsTitle");
$xh->add_attribute("value", "");
$xh->single_tag('input');
$xh->add_attribute("id", "discogsArtist");
$xh->add_attribute("type", "hidden");
$xh->add_attribute("name", "discogsArtist");
$xh->add_attribute("value", "");
$xh->single_tag('input');
$xh->add_attribute("id", "discogsBarcode");
$xh->add_attribute("type", "hidden");
$xh->add_attribute("name", "discogsBarcode");
$xh->add_attribute("value", "");
$xh->single_tag('input');
$xh->insert_code(inputNonce());
$xh->add_attribute("class", "table");
$xh->tag('div');
$xh->add_attribute("id", "wishlistTable");
$xh->add_attribute("class", "table table-striped condensed table-hover small w-100 DataTable");
$xh->add_attribute("data-paging", "false");
$xh->add_attribute("data-searching", "true");
$xh->add_attribute("data-state-save", "false");
$xh->add_attribute("data-info", "true");
$xh->add_attribute("data-ordering", "true");
$xh->add_attribute("data-order", "[[ 1, "asc" ]]");
$xh->add_attribute("data-responsive", "true");
$xh->tag('table');
$xh->add_attribute("class", "thead-dark table-header-sticky");
$xh->tag('thead');
$xh->tag('tr');
$xh->add_attribute("data-name", "image");
$xh->add_attribute("data-width", "15%");
$xh->add_attribute("data-orderable", "false");
$xh->add_attribute("data-priority", "1");
$xh->tag('th', "");
$xh->add_attribute("data-name", "artist");
$xh->add_attribute("data-priority", "1");
$xh->add_attribute("class", "text-left");
$xh->tag('th', "Artist");
$xh->add_attribute("data-name", "title");
$xh->add_attribute("data-priority", "1");
$xh->add_attribute("class", "text-left");
$xh->tag('th', "Title");
$xh->add_attribute("data-name", "barcode");
$xh->add_attribute("data-priority", "4");
$xh->tag('th', "Barcode");
$xh->add_attribute("data-name", "condition");
$xh->add_attribute("data-priority", "3");
$xh->tag('th', "Condition");
$xh->add_attribute("data-name", "format");
$xh->add_attribute("data-priority", "3");
$xh->tag('th', "Format");
$xh->add_attribute("data-name", "price");
$xh->add_attribute("data-priority", "2");
$xh->tag('th', "Price");
$xh->add_attribute("data-name", "icons");
$xh->add_attribute("data-priority", "1");
$xh->add_attribute("data-orderable", "false");
$xh->tag('th', "");
$xh->close(); // tr
$xh->close(); // thead
$xh->tag('tbody');
while ($row = mysqli_fetch_assoc($result)) {
$artist = (empty($row["artist"]) ? "" : htmlentities($row["artist"]));
$altText = "Image for " . htmlentities($row['title']) . " by " . $artist;
$price = print_monetary($row['price'], $row['currency']);
$searchTitle = 'Searching for:<br><br><strong>';
if (!empty($row['title'])) { $searchTitle .= htmlentities($row['title']); }
if (!empty($row['title']) && !empty($artist)) { $searchTitle .= " by "; }
if (!empty($artist)) { $searchTitle .= $artist; }
if ($row['barcode'] !== null) {
$searchTitle .= " (" . displayBarcode($row['barcode']) . ")";
}
$searchTitle .= "</strong>";
$xh->add_attribute("id", "wlIdRow" . $row['id']);
$xh->add_attribute("data-id", $row['id']);
$xh->add_attribute("data-title", htmlentities($row['title']));
$xh->add_attribute("data-artist", $artist);
$xh->add_attribute("data-barcode", htmlentities($row['barcode']));
$xh->add_attribute("data-search-title", $searchTitle);
$xh->tag('tr');
$xh->add_attribute("class", "wl-img");
$xh->tag('td');
$xh->add_attribute("class", "img-fluid lazyload");
$xh->add_attribute("src",PIXEL);
$xh->add_attribute("data-src", $row["thumbnail"]);
$xh->add_attribute("alt", $altText);
$xh->single_tag('img');
$xh->close(); // td
$xh->tag('td', $artist);
$xh->tag('td', htmlentities($row['title']));
$xh->add_attribute("data-order", htmlentities($row['barcode']));
$xh->tag('td', displayBarcode($row['barcode']));
$xh->tag('td', $row['cond']);
$xh->tag('td', $row['format']);
$xh->add_attribute("data-order", $row['price']);
$xh->tag('td', $price);
$xh->tag('td');
$xh->add_attribute("id", "wlEditBtn" . $row['id']);
$xh->add_attribute("class", "btn btn-sm btn-warning rounded px-1");
$xh->add_attribute("type", "button");
$xh->add_attribute("data-toggle", "tooltip");
$xh->add_attribute("title", "Edit");
$xh->add_attribute("aria-label", "Edit Entry");
$xh->tag('button');
$xh->add_attribute("class", "material-icons");
$xh->tag('i', "edit");
$xh->close(); // button
$xh->tag('span' , " ");
$xh->add_attribute("id", "wlDeleteBtn" . $row['id']);
$xh->add_attribute("class", "btn btn-sm btn-danger rounded px-1");
$xh->add_attribute("type", "button");
$xh->add_attribute("data-toggle", "tooltip");
$xh->add_attribute("title", "Delete");
$xh->add_attribute("aria-label", "Delete Entry");
$xh->tag('button');
$xh->add_attribute("class", "material-icons");
$xh->tag('i', "cancel_presentation");
$xh->close(); // button
$xh->tag('span' , " ");
$xh->add_attribute("id", "wlInfoBtn" . $row['id']);
$xh->add_attribute("class", "btn btn-sm btn-info rounded px-1");
$xh->add_attribute("role", "button");
$xh->add_attribute("data-toggle", "tooltip");
$xh->add_attribute("title", "Information");
$xh->add_attribute("aria-label", "Information for Entry");
$xh->add_attribute("href", htmlentities($row['url']));
$xh->add_attribute("target", "_blank", "rel", "noreferrer noopener");
$xh->tag('a');
$xh->add_attribute("class", "material-icons");
$xh->tag('i', "info_outline");
$xh->close(); // a
$xh->tag('span' , " ");
$xh->add_attribute("id", "wlSearchBtn" . $row['id']);
$xh->add_attribute("type", "submit");
$xh->add_attribute("name", "submitBtn");
$xh->add_attribute("value", "discogsSearch");
$xh->add_attribute("class", "btn btn-sm btn-success rounded px-1");
$xh->tag('button');
$xh->add_attribute("class", "material-icons");
$xh->add_attribute("title", "Search for Store Offers");
$xh->add_attribute("aria-label", "Search Store Offers for Entry");
$xh->add_attribute("data-toggle", "tooltip");
$xh->tag('i', "search");
$xh->close(); // button
$xh->close(); // td
$xh->close(); // tr
}
$xh->close(); // tbody
$xh->close(); // table
$xh->add_attribute("nonce", base64_encode($_SESSION["nonce"]));
$xh->tag('script');
$str = my_trim('document.addEventListener("DOMContentLoaded", function() {');
$str .= my_trim(' document.getElementById("wishlistTable").addEventListener("click", function(event) {');
$str .= my_trim(' e = event.target.closest("button") || event.target.closest("a");');
$str .= my_trim(' tr = event.target.closest("tr");');
$str .= my_trim(' if ($(tr).hasClass("child")) {');
$str .= my_trim(' tr = tr.previousElementSibling;');
$str .= my_trim(' }');
$str .= my_trim(' if (e && tr && e.id.startsWith("wlEditBtn")) {');
$str .= my_trim(' var id = tr.getAttribute("data-id");');
$str .= my_trim(' window.dataLayer.push({ "event" : "trackEvent", "eventCategory" : "Wishlist", "eventAction" : "Edit", "eventLabel" : ""});');
$str .= my_trim(' editWishlist(id, e);');
$str .= my_trim(' } else if (e && tr && e.id.startsWith("wlDeleteBtn")) {');
$str .= my_trim(' var id = tr.getAttribute("data-id");');
$str .= my_trim(' var title = tr.getAttribute("data-title");');
$str .= my_trim(' var artist = tr.getAttribute("data-artist");');
$str .= my_trim(' window.dataLayer.push({ "event" : "trackEvent", "eventCategory" : "Wishlist", "eventAction" : "Delete", "eventLabel" : ""});');
$str .= my_trim(' deleteWishlist(id, e, title, artist);');
$str .= my_trim(' } else if (e && tr && e.id.startsWith("wlInfoBtn")) {');
$str .= my_trim(' window.dataLayer.push({ "event" : "trackEvent", "eventCategory" : "Album Info", "eventAction" : "Click", "eventLabel" : ""});');
$str .= my_trim(' } else if (e && tr && e.id.startsWith("wlSearchBtn")) {');
$str .= my_trim(' var title = tr.getAttribute("data-title");');
$str .= my_trim(' var artist = tr.getAttribute("data-artist");');
$str .= my_trim(' var barcode = tr.getAttribute("data-barcode");');
$str .= my_trim(' var searchTitle = tr.getAttribute("data-search-title");');
$str .= my_trim(' document.getElementById("discogsTitle").value = title;');
$str .= my_trim(' document.getElementById("discogsArtist").value = artist;');
$str .= my_trim(' document.getElementById("discogsBarcode").value = barcode;');
$str .= my_trim(' progressBar(searchTitle);');
$str .= my_trim(' if (window.google_tag_manager && window.ga && ga.create) {');
$str .= my_trim(' event.preventDefault();');
$str .= my_trim(' var st = "";');
$str .= my_trim(' var form = event.target.closest("form");');
$str .= my_trim(' var input = document.createElement("input");');
$str .= my_trim(' input.setAttribute("type", "hidden");');
$str .= my_trim(' input.setAttribute("name", "submitBtn");');
$str .= my_trim(' input.setAttribute("value", "discogsSearch");');
$str .= my_trim(' form.appendChild(input);');
$str .= my_trim(' if (title.length > 0) st += title;');
$str .= my_trim(' if (title.length > 0 && artist.length > 0) st += " by ";');
$str .= my_trim(' if (artist.length > 0) st += artist;');
$str .= my_trim(' window.dataLayer.push({ "event" : "search", "search_term" : st, "eventCallback": function () {form.submit();}});');
$str .= my_trim(' }');
$str .= my_trim(' }');
$str .= my_trim(' });');
$str .= my_trim('});');
$xh->insert_code($str);
$xh->close(); // script
$xh->close(); // div
$xh->close(); // form
$xh->add_attribute("class", "modal fade");
$xh->add_attribute("id", "editWishlistModal");
$xh->tag('div');
$xh->add_attribute("class", "modal-dialog");
$xh->tag('div');
$xh->add_attribute("class", "modal-content");
$xh->tag('div');
$xh->add_attribute("class", "modal-header bg-secondary");
$xh->tag('div');
$xh->add_attribute("class", "modal-title display-6");
$xh->tag('p', "Edit Wishlist Entry");
$xh->close(); // div>
$xh->add_attribute("class", "mt-0");
$xh->add_attribute("id", "wlMsg");
$xh->tag('span', "");
$xh->insert_code(inputSessionTab());
$xh->add_attribute("type", "hidden");
$xh->add_attribute("name", "wlId");
$xh->add_attribute("id", "wlId");
$xh->single_tag('input');
$xh->add_attribute("class", "modal-body");
$xh->tag('div');
$xh->add_attribute("class", "form-group");
$xh->tag('div');
$xh->add_attribute("for", "wlArtist");
$xh->tag('label', "Artist:");
$xh->add_attribute("type", "text");
$xh->add_attribute("class", "form-control clearable");
$xh->add_attribute("id", "wlArtist");
$xh->single_tag('input');
$xh->close(); // div
$xh->add_attribute("class", "form-group");
$xh->tag('div');
$xh->add_attribute("for", "wlTitle");
$xh->tag('label', "Title:");
$xh->add_attribute("type", "text");
$xh->add_attribute("class", "form-control clearable");
$xh->add_attribute("id", "wlTitle");
$xh->single_tag('input');
$xh->close(); // div
$xh->add_attribute("class", "form-group");
$xh->tag('div');
$xh->add_attribute("for", "wlBarcode");
$xh->tag('label', "Barcode:");
$xh->add_attribute("type", "text");
$xh->add_attribute("class", "form-control clearable");
$xh->add_attribute("id", "wlBarcode");
$xh->single_tag('input');
$xh->close(); // div
$xh->add_attribute("class", "form-group");
$xh->tag('div');
$xh->add_attribute("for", "wlCond");
$xh->tag('label', "Condition:");
$xh->add_attribute("class", "form-control");
$xh->add_attribute("id", "wlCond");
$xh->tag('select');
$xh->tag('option', "Any");
$xh->tag('option', "New");
$xh->tag('option', "Used");
$xh->close(); // select
$xh->close(); // div
$xh->add_attribute("class", "form-group");
$xh->tag('div');
$xh->add_attribute("for", "wlFormat");
$xh->tag('label', "Format:");
$xh->add_attribute("class", "form-control");
$xh->add_attribute("id", "wlFormat");
$xh->tag('select');
$xh->tag('option', "Any");
$xh->tag('option', "CD");
$xh->tag('option', "Record");
$xh->tag('option', "Digital");
$xh->tag('option', "Book");
$xh->close(); // select
$xh->close(); // div
$xh->add_attribute("class", "form-group");
$xh->tag('div');
$xh->add_attribute("for", "wlPrice");
$xh->tag('label', "Ceiling Price:");
$xh->add_attribute("type", "text");
$xh->add_attribute("class", "form-control clearable");
$xh->add_attribute("id", "wlPrice");
$xh->single_tag('input');
$xh->close(); // div
$xh->close(); // div
$xh->add_attribute("class", "modal-footer bg-secondary");
$xh->tag('div');
$xh->add_attribute("id", "saveEditedWl");
$xh->add_attribute("type", "button");
$xh->add_attribute("class", "btn btn-success");
$xh->add_attribute("name", "submitBtn");
$xh->add_attribute("value", "Save");
$xh->tag('button', "Save");
$xh->add_attribute("nonce", base64_encode($_SESSION["nonce"]));
$xh->tag('script');
$str = my_trim('document.addEventListener("DOMContentLoaded", function() {');
$str .= my_trim(' document.getElementById("saveEditedWl").addEventListener("click", function() {');
$str .= my_trim(' saveEditedWishlist();');
$str .= my_trim(' });');
$str .= my_trim('});');
$xh->insert_code($str);
$xh->close(); // script
$xh->add_attribute("type", "button");
$xh->add_attribute("class", "btn btn-danger");
$xh->add_attribute("data-dismiss", "modal");
$xh->tag('button', "Cancel");
$xh->close(); // div
$xh->close(); // div
$xh->close(); // div
$xh->close(); // div
$xh->close(); // div
}
else {
$xh->add_attribute("class", "container bg-warning text-center py-3");
$xh->tag('div');
$xh->add_attribute("class", "display-6");
$xh->tag('p');
$xh->add_attribute("class", "material-icons");
$xh->tag('i', "bookmark");
$xh->tag('span', " Your wishlist is currently empty. Add matching albums from the search results.");
$xh->close(); // p
$xh->close(); // div
}
}
else if (mysqli_errno($conn)) {
error_log("MySQL Read Wishlist SQL: " . $sql);
error_log("MySQL Read Wishlist Error: " . mysqli_error($conn) . " (" . mysqli_errno($conn) . ")");
}
$html = $xh->flush();
//error_log(print_r($html, 1));
return $html;
}
function deleteWishlist($uid, $id) {
$conn = MySessionHandler::getDBSessionId();
$id = mysqli_real_escape_string($conn, $id);
$uid = mysqli_real_escape_string($conn, $uid);
$sql = "DELETE FROM wishlist WHERE id = $id AND uid = $uid;";
if (!($result = mysqli_query($conn, $sql))) {
error_log("MySQL Delete Wishlist SQL: " . $sql);
error_log("MySQL Delete Wishlist Error: " . mysqli_error($conn) . " (" . mysqli_errno($conn) . ")");
return -1;
}
return 0;
}
function updateWishlist($uid, $wlArr) {
$nul = 'NULL';
$conn = MySessionHandler::getDBSessionId();
$modified = mysqli_real_escape_string($conn, time());
$id = (empty($wlArr['id']) ? "NULL" : "'" . mysqli_real_escape_string($conn, $wlArr['id']) . "'");
$uid = mysqli_real_escape_string($conn, $uid);
$barcode = (empty($wlArr['barcode']) ? "NULL" : "'" . mysqli_real_escape_string($conn, $wlArr['barcode']) . "'");
$title = isset($wlArr['title']) ? "'" . mysqli_real_escape_string($conn, $wlArr['title']) . "'" : "NULL";
$artist = isset($wlArr['artist']) ? "'" . mysqli_real_escape_string($conn, $wlArr['artist']) . "'" : "NULL";
$cond = isset($wlArr['cond']) ? mysqli_real_escape_string($conn, $wlArr['cond']) : "Any";
$format = isset($wlArr['format']) ? mysqli_real_escape_string($conn, $wlArr['format']) : "Any";
$currency = 'USD'; //bugbug
$price = isset($wlArr['price']) ? "'" . mysqli_real_escape_string($conn, $wlArr['price']) . "'" : "NULL";
$sql = "UPDATE wishlist
SET modified='$modified', barcode=" . $barcode . ", title=" . $title . ", artist=" . $artist . ", cond='$cond', format='$format', price=" . $price . "
WHERE id=$id and uid=$uid";
if ($result = mysqli_query($conn, $sql)) {
return 0;
}
else {
error_log("MySQL Update Wishlist SQL: " . $sql);
error_log("MySQL Update Wishlist Error: " . mysqli_error($conn) . " (" . $error . ")");
return -1;
}
return -1;
}
function unsubscribeWishlist($arr) {
if (empty($arr['id']) || empty($arr['email'])) {
return "";
}
$conn = MySessionHandler::getDBSessionId();
$modified = mysqli_real_escape_string($conn, time());
$id = mysqli_real_escape_string($conn, $arr['id']);
$email = mysqli_real_escape_string($conn, $arr['email']);
$sql = "UPDATE users
SET wlEmailFlag = '0'
WHERE id=$id and email='$email'";
if (!($result = mysqli_query($conn, $sql))) {
error_log("MySQL Update Wishlist SQL: " . $sql);
error_log("MySQL Update Wishlist Error: " . mysqli_error($conn) . " (" . $error . ")");
}
$xh = new Html;
$xh->init($_SESSION["htmlIndent"]);
$xh->add_attribute("class", "container text-center bg-warning p-3 rounded");
$xh->tag('div');
$xh->add_attribute("class", "display-6 font-weight-bold");
$xh->tag('p', "The wishlist price check emails for " . $email . " have been turned off.");
$xh->tag('p', "You can reinstate the emails at any time by setting the option 'Email Price Checks' for your account back to 'Yes'.");
$xh->close(); // div>";
$html = $xh->flush();
//error_log(print_r($html, 1));
return $html;
}
function checkPriceMonitor() {
if (empty($_SESSION['sessData']['userID'])) {
unset($_SESSION['priceMonitor']);
return -1;
}
$conn = MySessionHandler::getDBSessionId();
$uid = $_SESSION['sessData']['userID'];
$sql = "SELECT created, access
FROM pricemonitor
WHERE userId = '$uid'";
if ($result = mysqli_query($conn, $sql)) {
if (mysqli_num_rows($result) > 0) {
if ($row = mysqli_fetch_assoc($result)) {
$_SESSION['priceMonitor']['created'] = $row['created'];
$_SESSION['priceMonitor']['access'] = $row['access'];
if ($_SESSION['priceMonitor']['created'] > $_SESSION['priceMonitor']['access']) {
$_SESSION['priceMonitor']['newFlag'] = true;
} else {
$_SESSION['priceMonitor']['newFlag'] = false;
}
return 0;
}
}
}
else if (mysqli_errno($conn)) {
error_log("MySQL Read Price Monitor SQL: " . $sql);
error_log("MySQL Read Price Monitor Error: " . mysqli_error($conn) . " (" . mysqli_errno($conn) . ")");
}
return -1;
}
function getPriceMonitor() {
$xh = new Html;
$xh->init($_SESSION["htmlIndent"]);
if (!isLoggedIn()) {
$xh->add_attribute("class", "container bg-warning text-center py-3");
$xh->tag('div');
$xh->add_attribute("class", "display-6");
$xh->tag('p');
$xh->add_attribute("class", "material-icons");
$xh->tag('i', "error_outline");
$xh->tag('span', " Please login to your Find Cheap Music account in order to see the price monitor results.");
$xh->close(); // p
$xh->close(); // div
$html = $xh->flush();
//error_log(print_r($html, 1));
return $html;
}
$conn = MySessionHandler::getDBSessionId();
$uid = $_SESSION['sessData']['userID'];
$sql = "SELECT data
FROM pricemonitor
WHERE userId = '$uid'";
if ($result = mysqli_query($conn, $sql)) {
if (mysqli_num_rows($result) > 0) {
if ($row = mysqli_fetch_assoc($result)) {
$access = mysqli_real_escape_string($conn, time());
$sql = "UPDATE pricemonitor
SET access = $access
WHERE userId = '$uid'";
if (!($result = mysqli_query($conn, $sql))) {
error_log("MySQL Update Price Monitor SQL: " . $sql);
error_log("MySQL Update Price Monitor Error: " . mysqli_error($conn) . " (" . $error . ")");
}
$html = gzdecode(base64_decode($row['data']));
$html = str_replace(base64_encode("xxxNONCExxx"), base64_encode($_SESSION["nonce"]), $html);
return ($html);
}
}
}
else if (mysqli_errno($conn)) {
error_log("MySQL Read Price Monitor SQL: " . $sql);
error_log("MySQL Read Price Monitor Error: " . mysqli_error($conn) . " (" . mysqli_errno($conn) . ")");
}
$xh->add_attribute("class", "container bg-warning text-center py-3");
$xh->tag('div');
$xh->add_attribute("class", "display-6");
$xh->tag('p');
$xh->add_attribute("class", "material-icons");
$xh->tag('i', "bookmark");
$xh->tag('span', " Your price monitor list is currently empty.");
$xh->close(); // p
$xh->close(); // div
$html = $xh->flush();
//error_log(print_r($html, 1));
return $html;
}