Subversion Repositories cheapmusic

Rev

Rev 153 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
<?php
121 - 2
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/hosting.php");
65 - 3
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/sessions_db.php");
4
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/cryptor.php");
5
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/vendors.php");
6
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/tools.php");
7
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/wishlist.php");
119 - 8
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/NonceUtil.php");
7 - 9
 
9 - 10
error_reporting(E_ALL);
11
 
35 - 12
$userData = [];
153 - 13
$configFile = parse_ini_file(FCM_CONFIGFILE, true);
7 - 14
$crypt = Cryptor::getInstance($configFile['cryptor']);
107 - 15
$tmpSessionTab = (!empty(getPGV("sessionTab")) && getPGV("sessionTab") > 0 ? getPGV("sessionTab"): null);
7 - 16
$handler = MySessionHandler::getInstance($tmpSessionTab, $configFile['mysqli']);
9 - 17
$vendors = Vendors::getInstance();
83 - 18
Vendors::setAllVendors($configFile, $vendors);
121 - 19
$systemConf = $configFile['system'];
7 - 20
unset($configFile);
21
 
121 - 22
session_set_cookie_params(604800, '/', '.' . $systemConf["domain_name"], true, true);
7 - 23
session_set_save_handler($handler, true);
35 - 24
if (!empty($_COOKIE['PHPSESSID'])) {
25
    session_id($_COOKIE['PHPSESSID']);
26
}
2 - 27
session_start();
35 - 28
 
138 - 29
initSessionVariables($systemConf);
30
 
119 - 31
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/csp.php");
159 - 32
//header("Link: <css/style.min.css?1591711694>; rel=preload; as=style");
119 - 33
 
35 - 34
// Check whether user ID is available in cookie
65 - 35
if (!empty($_COOKIE['rememberUserId']) && !empty($_COOKIE['hash']) && empty($_SESSION['sessData']['loginType'])) {
35 - 36
    require_once 'login/includes/config.php';
37
    require_once 'login/includes/User.class.php';
38
    require_once 'login/includes/password.php';
39
    $user = new User();
40
    $conditions['where'] = array(
41
        'id' => $_COOKIE['rememberUserId']
42
    );
43
    $conditions['return_type'] = 'single';
44
    $userData = $user->getRows($conditions);
45
    if (!empty($userData) && password_verify($userData['password'] . $userData['id'], $_COOKIE['hash'])) {
65 - 46
        $_SESSION['sessData']['userLoggedIn'] = true;
35 - 47
        $_SESSION['sessData']['userID'] = $_COOKIE['rememberUserId'];
141 - 48
        $_SESSION["userPicture"] = getUserImage($userData);
49
        $_SESSION["colorTheme"] = $userData['theme'];
59 - 50
        $_SESSION["currentLayout"] = ($userData['cardView'] == '1' ? 'CardView' : 'TableView');
137 - 51
        $_SESSION['buyer']['Zip'] = $userData['zip'];
52
        $_SESSION['buyer']['Country'] = 'United States';
53
        $_SESSION['buyer']['Currency'] = 'USD';
54
        $_SESSION["filterCondition"]["New"] = $userData['conditionNew'];
55
        $_SESSION["filterCondition"]["Used"] = $userData['conditionUsed'];
56
        $_SESSION["filterMediaType"]["CD"] = $userData['mediaCD'];
57
        $_SESSION["filterMediaType"]["Record"] = $userData['mediaRecord'];
58
        $_SESSION["filterMediaType"]["Digital"] = $userData['mediaDigital'];
59
        $_SESSION["filterMediaType"]["Book"] = $userData['mediaBook'];
65 - 60
    }
61
    else {
35 - 62
        unsetSessData();
63
    }
137 - 64
// or if the user has already logged in
65
} else if (isLoggedIn()) {
35 - 66
    require_once 'login/includes/config.php';
67
    require_once 'login/includes/User.class.php';
68
    require_once 'login/includes/password.php';
69
    $user = new User();
70
    $conditions['where'] = array(
71
        'id' => $_SESSION['sessData']['userID']
72
    );
73
    $conditions['return_type'] = 'single';
74
    $userData = $user->getRows($conditions);
57 - 75
 
35 - 76
    if (!empty($userData)) {
141 - 77
        $_SESSION["userPicture"] = getUserImage($userData);
78
        $_SESSION["colorTheme"] = $userData['theme'];
59 - 79
        $_SESSION["currentLayout"] = ($userData['cardView'] == '1' ? 'CardView' : 'TableView');
137 - 80
        $_SESSION['buyer']['Zip'] = $userData['zip'];
81
        $_SESSION['buyer']['Country'] = 'United States';
82
        $_SESSION['buyer']['Currency'] = 'USD';
83
        $_SESSION["filterCondition"]["New"] = $userData['conditionNew'];
84
        $_SESSION["filterCondition"]["Used"] = $userData['conditionUsed'];
85
        $_SESSION["filterMediaType"]["CD"] = $userData['mediaCD'];
86
        $_SESSION["filterMediaType"]["Record"] = $userData['mediaRecord'];
87
        $_SESSION["filterMediaType"]["Digital"] = $userData['mediaDigital'];
88
        $_SESSION["filterMediaType"]["Book"] = $userData['mediaBook'];
65 - 89
    }
90
    else {
35 - 91
        unsetSessData();
92
    }
137 - 93
// or user is not logged in
138 - 94
} else {
35 - 95
    unsetSessData();
141 - 96
    $_SESSION["colorTheme"] = 'default';
35 - 97
}
57 - 98
 
78 - 99
checkPriceMonitor();
114 - 100
 
127 - 101
echo "<!DOCTYPE html>"; // html5
2 - 102
 
127 - 103
$xh = new Html;
104
$xh->init($_SESSION["htmlIndent"]);
105
$xh->add_attribute("lang", "en-US");
106
$xh->tag('html');
107
$xh->tag('head');
134 - 108
    $xh->insert_code(headTitle(getPGV('submitBtn')));
127 - 109
    $xh->add_attribute('name', "keywords");
110
    $xh->add_attribute('content', "Cheap,Music,Album,Single,Promo,CD,Compact Disc,Vinyl,Record,Digital,Download,Sheet,Book");
111
    $xh->single_tag('meta');
134 - 112
    $xh->insert_code(metaDescription(getPGV('submitBtn')));
127 - 113
    $xh->insert_code(htmlHeader());
114
    $xh->insert_code(file_get_contents('snippets/fb_tw.txt'));
143 - 115
    if (!empty($_SESSION["gtmId"])) {
116
        $xh->add_attribute('nonce', base64_encode($_SESSION["nonce"]));
117
        $xh->tag('style');
118
           $xh->insert_code(".gtm-noscript{display:none;visibility:hidden;}");
119
        $xh->close(); // style
120
    }
127 - 121
    $xh->close(); // head
122
$xh->tag('body');
123
 
134 - 124
if (!empty($_SESSION["gtmId"])) {
143 - 125
    //$xh->add_attribute('nonce', base64_encode($_SESSION["nonce"]));
127 - 126
    $xh->tag('noscript');
134 - 127
        $xh->add_attribute("src", "https://www.googletagmanager.com/ns.html?id=" . $_SESSION["gtmId"]);
127 - 128
        $xh->add_attribute("height", "0");
129
        $xh->add_attribute("width", "0");
138 - 130
        $xh->add_attribute("class", "gtm-noscript");
127 - 131
        $xh->add_attribute("title", "Tagmanager");
132
        $xh->tag('iframe', "");
133
    $xh->close(); // noscript
119 - 134
}
135
 
2 - 136
if ($_SERVER["REQUEST_METHOD"] == "POST") {
153 - 137
    if (empty($_POST["submitBtn"])) {
138
        $_POST["submitBtn"] = $_POST["submit"] ?? ""; // bugbug where does this come from?
139
    }
134 - 140
    if ($_POST["submitBtn"] == "Search") {
137 - 141
        buildDiscogsSearchTerm();
2 - 142
 
137 - 143
        if (!empty($_SESSION["searchTerm"])) {
138 - 144
            $_SESSION["mode"] = SIMPLE_SEARCH;
116 - 145
            performSearch();
141 - 146
            $xh->insert_code(jumpToSection("discogsTable"));
65 - 147
        }
137 - 148
    } else if ($_POST["submitBtn"] == "advSearch") {
149
        buildDiscogsSearchTerm();
150
        if (!empty($_SESSION["advSearch"])) {
138 - 151
            $_SESSION["mode"] = ADVANCED_SEARCH;
116 - 152
            performSearch();
141 - 153
            $xh->insert_code(jumpToSection("discogsTable"));
65 - 154
        }
137 - 155
    } else if ($_POST["submitBtn"] == "discogsSearch") {
156
        buildDiscogsSearchTerm();
157
        if (!empty($_SESSION["searchTerm"])) {
141 - 158
            $_SESSION["mode"] = ADVANCED_SEARCH;
159
            performSearch(true);
160
            $xh->insert_code(jumpToSection("productTable"));
65 - 161
        }
137 - 162
    } else if ($_POST["submitBtn"] == "unsubscribe") {
73 - 163
// bugbug
164
    }
65 - 165
}
166
else if ($_SERVER["REQUEST_METHOD"] == "GET") {
151 - 167
    $_GET["submitBtn"] = $_GET["submit"] ?? "";
137 - 168
    buildDiscogsSearchTerm();
169
    if (!empty($_SESSION["searchTerm"])) {
138 - 170
/*
171
        $xh->insert_code(printProgessbarModal());
172
        $xh->add_attribute('nonce', base64_encode($_SESSION["nonce"]));
173
        $xh->tag('script');
174
        $str = 'progressBar(' . $_SESSION["searchTerm"] . ');';
175
        $xh->insert_code($str);
176
        $xh->flush();
177
        $xh->close();  // script
178
*/
116 - 179
        performSearch();
65 - 180
    }
2 - 181
}
182
 
141 - 183
$xh->insert_code(navigationPane());
127 - 184
 
185
    $xh->add_attribute("class", "page-header bg-primary");
186
    $xh->tag('div');
187
        $xh->add_attribute("class", "container text-center py-3");
188
        $xh->tag('div');
189
 
134 - 190
if (getPGV('submitBtn') == "terms") {
127 - 191
    $xh->tag('h1', "Terms of Service");
137 - 192
} else if (getPGV('submitBtn') == "privacy") {
127 - 193
    $xh->tag('h1', "Privacy Policy");
137 - 194
} else if (getPGV('submitBtn') == "coupons") {
127 - 195
    $xh->tag('h1', "Special Offers &amp; Coupon Codes");
137 - 196
} else if (getPGV('submitBtn') == "wishlist") {
127 - 197
    $xh->tag('h1', "Wishlist");
78 - 198
    if (!empty($_SESSION['priceMonitor'])) {
127 - 199
        $xh->add_attribute("method", "post");
200
        $xh->add_attribute("action", "/index.php");
201
        $xh->tag('form');
202
            $xh->insert_code(inputSessionTab());
203
            $xh->insert_code(inputNonce());
204
            $xh->add_attribute("class", "btn btn-info rounded");
205
            $xh->add_attribute("id", "priceMonitor");
206
            $xh->add_attribute("type", "submit");
134 - 207
            $xh->add_attribute("name", "submitBtn");
127 - 208
            $xh->add_attribute("value", "priceMonitor");
209
            $xh->tag('button', "Price Monitor Results");
210
            if (!empty($_SESSION['priceMonitor']['newFlag']) && $_SESSION['priceMonitor']['newFlag'] === true) {
211
                $xh->add_attribute("class", "badge badge-pill badge-dark");
134 - 212
                 $xh->tag('span', "New");
127 - 213
            }
214
        $xh->close(); // form
78 - 215
    }
137 - 216
} else if (getPGV('submitBtn') == "priceMonitor") {
127 - 217
    $xh->tag('h1', "Price Monitor Results");
137 - 218
} else if (getPGV('submitBtn') == "help") {
127 - 219
    $xh->tag('h1', "Getting Started");
137 - 220
} else if (getPGV('submitBtn') == "barcode") {
127 - 221
    $xh->tag('h1', "Barcode Checker");
137 - 222
} else if (getPGV('submitBtn') == "unsubscribe") {
127 - 223
    $xh->tag('h1', "Unsubscribe Wishlist");
137 - 224
} else {
127 - 225
    $xh->tag('h1', "Find Cheap CDs, Records, Digital, Books and Sheets");
226
    $xh->add_attribute("id", "textslide");
227
    $xh->add_attribute("class", "d-none d-sm-block");
228
    $xh->tag('p', "Bookmark FindCheapMusic.com");
65 - 229
}
2 - 230
 
127 - 231
        $xh->close(); // div
232
    $xh->close(); // div
73 - 233
 
127 - 234
    $xh->insert_code(mainSearchForm());
138 - 235
    $xh->insert_code(mainAdvSearchForm());
2 - 236
 
134 - 237
if (getPGV('submitBtn') == "terms") {
120 - 238
    $snip = file_get_contents('snippets/terms.txt');
239
    $snip = str_replace("<script>", "<script nonce=\"" . base64_encode($_SESSION["nonce"]) . "\">", $snip);
127 - 240
    $xh->insert_code($snip);
137 - 241
} else if (getPGV('submitBtn') == "privacy") {
120 - 242
    $snip = file_get_contents('snippets/privacy.txt');
243
    $snip = str_replace("<script>", "<script nonce=\"" . base64_encode($_SESSION["nonce"]) . "\">", $snip);
127 - 244
    $xh->insert_code($snip);
137 - 245
} else if (getPGV('submitBtn') == "help") {
127 - 246
    $xh->insert_code(printHelp());
137 - 247
} else if (getPGV('submitBtn') == "barcode") {
127 - 248
    $xh->insert_code(barcodePage());
137 - 249
} else if (getPGV('submitBtn') == "coupons") {
65 - 250
    //get_linkshareCoupons(); // bugbug
127 - 251
    $xh->insert_code(getCouponCodes());
137 - 252
} else if (getPGV('submitBtn') == "wishlist") {
127 - 253
    $xh->insert_code(getWishlist());
137 - 254
} else if (getPGV('submitBtn') == "priceMonitor") {
127 - 255
    $xh->add_attribute("class", "container");
256
    $xh->add_attribute("id", "productTable");
257
    $xh->tag('div');
258
    $xh->insert_code(getPriceMonitor());
259
    $xh->close(); // div
137 - 260
} else if (getPGV('submitBtn') == "unsubscribe") {
127 - 261
    $xh->insert_code(unsubscribeWishlist($_GET));
137 - 262
} else if (getPGV('submitBtn') == "random") {
138 - 263
    findDiscogsMaster(true);
119 - 264
    if (!empty($_SESSION["discogs"])) {
127 - 265
        $xh->insert_code(str_replace("xxxNONCExxx", base64_encode($_SESSION["nonce"]), $_SESSION["discogs"]));
119 - 266
    }
137 - 267
} else {
65 - 268
    if ($_SESSION["lowestPrice"]["All"] > 0.00 || !empty($_SESSION["searchTerm"])) {
127 - 269
        $xh->insert_code(str_replace("xxxNONCExxx", base64_encode($_SESSION["nonce"]), $_SESSION["discogs"]));
270
        $xh->add_attribute("class", "container border py-2");
271
        $xh->add_attribute("id", "productTable");
272
        $xh->tag('div');
273
        $xh->insert_code(storeOfferHeader());
104 - 274
        if ($_SESSION["lowestPrice"]["All"] > 0.00) {
127 - 275
            $xh->insert_code(printResultHeader());
104 - 276
        }
127 - 277
        $xh->insert_code(printResult());
278
        $xh->close(); // div
133 - 279
        $xh->insert_code(productTableEventListeners());
65 - 280
    }
281
    else if (!empty($_SESSION["discogs"])) {
127 - 282
        $xh->insert_code(str_replace("xxxNONCExxx", base64_encode($_SESSION["nonce"]), $_SESSION["discogs"]));
65 - 283
    }
284
    else {
127 - 285
        $xh->insert_code(startscreen());
14 - 286
    }
127 - 287
 
288
    $xh->insert_code(printSearchInfoModal());
65 - 289
}
2 - 290
 
127 - 291
$xh->insert_code(printProgessbarModal());
14 - 292
 
128 - 293
$xh->insert_code(printSocialIconBar());
81 - 294
 
127 - 295
$xh->insert_code(htmlFooter());
2 - 296
 
127 - 297
$xh->insert_code(headerQuoteSlides());
298
 
299
$xh->insert_code(downloadAtOnload());
300
 
301
$xh->tag('form');
302
    $xh->add_attribute("type", "hidden");
303
    $xh->add_attribute("id", "nonce");
304
    $xh->add_attribute("name", "nonce");
305
    $xh->add_attribute("value", $_SESSION["nonce"]);
306
    $xh->single_tag('input');
307
$xh->close(); // form
308
 
309
$xh->close(); // body
310
$xh->close(); // html
311
 
312
$html = $xh->flush();
313
//error_log(print_r($html, 1));
314
 
315
echo $html;
316
 
317
MySessionHandler::commit(session_id());