52 |
- |
1 |
<?php
|
121 |
- |
2 |
include_once ($_SERVER['DOCUMENT_ROOT'] . '/php/hosting.php');
|
52 |
- |
3 |
|
65 |
- |
4 |
$rc = - 1;
|
52 |
- |
5 |
$msg = "";
|
|
|
6 |
|
65 |
- |
7 |
if (isset($_POST['function']) && in_array($_POST['function'], array(
|
|
|
8 |
"add",
|
|
|
9 |
"delete",
|
|
|
10 |
"update"
|
|
|
11 |
))) {
|
52 |
- |
12 |
if (isset($_POST["id"])) {
|
65 |
- |
13 |
include_once ($_SERVER['DOCUMENT_ROOT'] . '/php/sessions_db.php');
|
|
|
14 |
include_once ($_SERVER['DOCUMENT_ROOT'] . '/php/cryptor.php');
|
|
|
15 |
include_once ($_SERVER['DOCUMENT_ROOT'] . '/php/wishlist.php');
|
|
|
16 |
include_once ($_SERVER['DOCUMENT_ROOT'] . '/php/clsLibGTIN.php');
|
|
|
17 |
include_once ($_SERVER['DOCUMENT_ROOT'] . '/php/constants.php');
|
122 |
- |
18 |
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/NonceUtil.php");
|
52 |
- |
19 |
|
153 |
- |
20 |
$configFile = parse_ini_file(FCM_CONFIGFILE, true);
|
52 |
- |
21 |
$crypt = Cryptor::getInstance($configFile['cryptor']);
|
|
|
22 |
$tmpSessionTab = (isset($_POST["sessionTab"]) && $_POST["sessionTab"] > 0 ? $_POST["sessionTab"] : null);
|
|
|
23 |
$handler = MySessionHandler::getInstance($tmpSessionTab, $configFile['mysqli']);
|
122 |
- |
24 |
$systemConf = $configFile['system'];
|
52 |
- |
25 |
unset($configFile);
|
|
|
26 |
|
120 |
- |
27 |
session_set_cookie_params(604800, '/', '.findcheapmusic.com', true, true);
|
52 |
- |
28 |
session_set_save_handler($handler, true);
|
|
|
29 |
if (!empty($_COOKIE['PHPSESSID'])) {
|
|
|
30 |
session_id($_COOKIE['PHPSESSID']);
|
|
|
31 |
}
|
|
|
32 |
@session_start();
|
|
|
33 |
|
|
|
34 |
$uid = $_SESSION['sessData']['userID'];
|
122 |
- |
35 |
$rc = 0;
|
52 |
- |
36 |
|
122 |
- |
37 |
if (empty($_POST["nonce"]) || NonceUtil::check($systemConf["nonce_secret"], $_POST["nonce"]) === false) {
|
|
|
38 |
$msg = "Internal Error. Please reload page.";
|
|
|
39 |
$rc = 1;
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
if (!$rc && !empty($uid) && $uid > 0) {
|
|
|
43 |
|
52 |
- |
44 |
if ($_POST['function'] == "delete") {
|
|
|
45 |
$rc = deleteWishlist($uid, $_POST["id"]);
|
65 |
- |
46 |
}
|
|
|
47 |
else if ($_POST['function'] == "add") {
|
52 |
- |
48 |
$rc = addWishlist($uid, json_decode(base64_decode($_POST['wl'])));
|
65 |
- |
49 |
}
|
|
|
50 |
else { /* update */
|
52 |
- |
51 |
$wlArr = [];
|
|
|
52 |
$wlArr["id"] = $_POST['id'];
|
|
|
53 |
$wlArr["artist"] = $_POST['artist'];
|
|
|
54 |
$wlArr["title"] = $_POST['title'];
|
|
|
55 |
$wlArr["barcode"] = $_POST['barcode'];
|
73 |
- |
56 |
$wlArr["cond"] = $_POST['cond'];
|
52 |
- |
57 |
$wlArr["format"] = $_POST['format'];
|
|
|
58 |
$wlArr["price"] = $_POST['price'];
|
|
|
59 |
|
|
|
60 |
if (empty($wlArr['id']) || $wlArr['id'] < 0) {
|
|
|
61 |
$msg = "Internal Error. Please reload page.";
|
|
|
62 |
}
|
65 |
- |
63 |
|
52 |
- |
64 |
if (empty($wlArr['artist']) && empty($wlArr['title']) && empty($wlArr['barcode'])) {
|
|
|
65 |
$msg = "Artist, Ttile and Barcode are empty. Please set at least one of them.";
|
|
|
66 |
}
|
65 |
- |
67 |
|
52 |
- |
68 |
if (!empty($wlArr['barcode'])) {
|
|
|
69 |
$barcodeType = clsLibGTIN::GTINCheck($wlArr['barcode'], false, 1);
|
|
|
70 |
if (empty($barcodeType)) {
|
|
|
71 |
$msg = "Invalid Barcode number. Please correct.";
|
|
|
72 |
}
|
|
|
73 |
}
|
65 |
- |
74 |
|
52 |
- |
75 |
if (!empty($wlArr['price'])) {
|
|
|
76 |
if (!is_numeric($wlArr['price']) || $wlArr['price'] < 0) {
|
|
|
77 |
$msg = "Invalid Ceiling Price. Please correct.";
|
|
|
78 |
}
|
|
|
79 |
}
|
65 |
- |
80 |
|
73 |
- |
81 |
if (empty($wlArr['cond']) || !in_array($wlArr['cond'], $condArr)) {
|
|
|
82 |
$msg = "Invalid Condition. Please correct.";
|
|
|
83 |
}
|
|
|
84 |
|
52 |
- |
85 |
if (empty($wlArr['format']) || !in_array($wlArr['format'], $formatArr)) {
|
|
|
86 |
$msg = "Invalid Format. Please correct.";
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
if (empty($msg)) {
|
|
|
90 |
$rc = updateWishlist($uid, $wlArr);
|
65 |
- |
91 |
}
|
|
|
92 |
else {
|
52 |
- |
93 |
$rc = 1;
|
|
|
94 |
}
|
|
|
95 |
}
|
|
|
96 |
}
|
|
|
97 |
}
|
|
|
98 |
}
|
|
|
99 |
|
65 |
- |
100 |
echo json_encode(array(
|
|
|
101 |
"retval" => $rc,
|
|
|
102 |
"msg" => $msg
|
|
|
103 |
));
|
|
|
104 |
exit;
|