Subversion Repositories cheapmusic

Rev

Rev 122 | Rev 124 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
<?php
107 - 2
 
121 - 3
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/hosting.php");
65 - 4
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/sessions_db.php");
5
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/cryptor.php");
6
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/vendors.php");
7
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/tools.php");
8
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/wishlist.php");
119 - 9
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/NonceUtil.php");
7 - 10
 
9 - 11
error_reporting(E_ALL);
12
 
35 - 13
$userData = [];
57 - 14
$userTheme = 'default';
70 - 15
$configFile = parse_ini_file($_SERVER['DOCUMENT_ROOT'] . FCM_CONFIGFILE, true);
7 - 16
$crypt = Cryptor::getInstance($configFile['cryptor']);
107 - 17
$tmpSessionTab = (!empty(getPGV("sessionTab")) && getPGV("sessionTab") > 0 ? getPGV("sessionTab"): null);
7 - 18
$handler = MySessionHandler::getInstance($tmpSessionTab, $configFile['mysqli']);
9 - 19
$vendors = Vendors::getInstance();
83 - 20
Vendors::setAllVendors($configFile, $vendors);
121 - 21
$systemConf = $configFile['system'];
7 - 22
unset($configFile);
23
 
121 - 24
session_set_cookie_params(604800, '/', '.' . $systemConf["domain_name"], true, true);
7 - 25
session_set_save_handler($handler, true);
35 - 26
if (!empty($_COOKIE['PHPSESSID'])) {
27
    session_id($_COOKIE['PHPSESSID']);
28
}
2 - 29
session_start();
35 - 30
 
121 - 31
$_SESSION["gtag"] = ($systemConf["g_tag"] == "1");
32
$_SESSION["nonce"] = NonceUtil::generate($systemConf["nonce_secret"]);
119 - 33
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/csp.php");
34
 
35 - 35
// Check whether user ID is available in cookie
65 - 36
if (!empty($_COOKIE['rememberUserId']) && !empty($_COOKIE['hash']) && empty($_SESSION['sessData']['loginType'])) {
35 - 37
    require_once 'login/includes/config.php';
38
    require_once 'login/includes/User.class.php';
39
    require_once 'login/includes/password.php';
40
    $user = new User();
41
    $conditions['where'] = array(
42
        'id' => $_COOKIE['rememberUserId']
43
    );
44
    $conditions['return_type'] = 'single';
45
    $userData = $user->getRows($conditions);
46
    if (!empty($userData) && password_verify($userData['password'] . $userData['id'], $_COOKIE['hash'])) {
65 - 47
        $_SESSION['sessData']['userLoggedIn'] = true;
35 - 48
        $_SESSION['sessData']['userID'] = $_COOKIE['rememberUserId'];
36 - 49
        $userPicture = getUserImage($userData);
57 - 50
        $userTheme = $userData['theme'];
59 - 51
        $_SESSION["currentLayout"] = ($userData['cardView'] == '1' ? 'CardView' : 'TableView');
57 - 52
        if (empty($_SESSION["manualFilter"])) {
53
            $_SESSION['buyer']['Zip'] = $userData['zip'];
54
            $_SESSION['buyer']['Country'] = 'United States';
55
            $_SESSION['buyer']['Currency'] = 'USD';
65 - 56
            $_SESSION["filterCondition"]["New"] = $userData['conditionNew'];
57
            $_SESSION["filterCondition"]["Used"] = $userData['conditionUsed'];
58
            $_SESSION["filterMediaType"]["CD"] = $userData['mediaCD'];
59
            $_SESSION["filterMediaType"]["Record"] = $userData['mediaRecord'];
60
            $_SESSION["filterMediaType"]["Digital"] = $userData['mediaDigital'];
61
            $_SESSION["filterMediaType"]["Book"] = $userData['mediaBook'];
62
        }
63
    }
64
    else {
35 - 65
        unsetSessData();
66
    }
65 - 67
    // or if the user has already logged in
114 - 68
 
65 - 69
}
70
else if (isLoggedIn()) {
35 - 71
    require_once 'login/includes/config.php';
72
    require_once 'login/includes/User.class.php';
73
    require_once 'login/includes/password.php';
74
    $user = new User();
75
    $conditions['where'] = array(
76
        'id' => $_SESSION['sessData']['userID']
77
    );
78
    $conditions['return_type'] = 'single';
79
    $userData = $user->getRows($conditions);
57 - 80
 
35 - 81
    if (!empty($userData)) {
36 - 82
        $userPicture = getUserImage($userData);
57 - 83
        $userTheme = $userData['theme'];
59 - 84
        $_SESSION["currentLayout"] = ($userData['cardView'] == '1' ? 'CardView' : 'TableView');
57 - 85
        if (empty($_SESSION["manualFilter"])) {
35 - 86
            $_SESSION['buyer']['Zip'] = $userData['zip'];
87
            $_SESSION['buyer']['Country'] = 'United States';
88
            $_SESSION['buyer']['Currency'] = 'USD';
65 - 89
            $_SESSION["filterCondition"]["New"] = $userData['conditionNew'];
90
            $_SESSION["filterCondition"]["Used"] = $userData['conditionUsed'];
91
            $_SESSION["filterMediaType"]["CD"] = $userData['mediaCD'];
92
            $_SESSION["filterMediaType"]["Record"] = $userData['mediaRecord'];
93
            $_SESSION["filterMediaType"]["Digital"] = $userData['mediaDigital'];
94
            $_SESSION["filterMediaType"]["Book"] = $userData['mediaBook'];
35 - 95
        }
65 - 96
    }
97
    else {
35 - 98
        unsetSessData();
99
    }
65 - 100
    // not logged in
114 - 101
 
65 - 102
}
103
else {
35 - 104
    unsetSessData();
105
}
57 - 106
 
78 - 107
checkPriceMonitor();
2 - 108
?>
109
<!DOCTYPE html>
110
<html lang="en-US">
111
<head>
107 - 112
    <title>Find Cheap Music | CDs, Records, Digital, Books and Sheets</title>
114 - 113
    <meta name="keywords" content="Cheap,Music,Album,Single,Promo,CD,Compact Disc,Vinyl,Record,Digital,Download,Sheet,Book">
114
    <?php echo metaDescription(getPGV('submit')); ?>
70 - 115
    <?php include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/header.php"); ?>
114 - 116
 
107 - 117
    <?php echo file_get_contents('snippets/fb_tw.txt'); ?>
2 - 118
</head>
119
<body>
120
 
121
<?php
121 - 122
if ($_SESSION["gtag"]) {
120 - 123
    echo '<noscript nonce="' . base64_encode($_SESSION["nonce"]) . '"><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-PCNTXZ7" height="0" width="0" style="display:none;visibility:hidden" title="Tagmanager"></iframe></noscript>';
119 - 124
}
125
 
5 - 126
initSessionVariables();
2 - 127
 
128
if ($_SERVER["REQUEST_METHOD"] == "POST") {
65 - 129
    if ($_POST["submit"] == "Search") {
35 - 130
        if (empty($_SESSION['buyer']['Zip'])) {
65 - 131
            $zip = (empty($_POST['buyerZip']) ? "" : sanitizeInput($_POST['buyerZip']));
132
            if (strlen($zip) == 5 && preg_match("/^[0-9 ]*$/", $zip)) {
57 - 133
                if ($_SESSION["buyer"]["Zip"] != $zip) {
65 - 134
                    $_SESSION["manualFilter"] = true;
135
                    $_SESSION["buyer"]["Zip"] = $zip;
136
                }
137
            }
138
            else if (strlen($zip) == 0) {
139
                $_SESSION["buyer"]["Zip"] = "";
140
            }
141
        }
2 - 142
 
46 - 143
        $_SESSION["discogsTitle"] = "";
144
        $_SESSION["discogsArtist"] = "";
65 - 145
        $searchTerm = (empty($_POST['searchTerm']) ? "" : searchFriendlyString($_POST['searchTerm']));
146
        if (empty($searchTerm)) {
147
            resetSessionVars();
148
        }
149
        else {
150
            $_SESSION["searchTerm"] = $searchTerm;
116 - 151
            performSearch();
65 - 152
        }
153
    }
154
    else if ($_POST["submit"] == "Save") {
155
        $_SESSION["manualFilter"] = true;
66 - 156
        if (!isset($_POST["filterCondition"])) {$_POST["filterCondition"] = []; }
157
        if (!is_array($_POST["filterCondition"])) { $_POST["filterCondition"] = [ $_POST["filterCondition"] ];}
158
        $_SESSION["filterCondition"]["New"] = in_array("New", $_POST["filterCondition"]);
159
        $_SESSION["filterCondition"]["Used"] = in_array("Used", $_POST["filterCondition"]);
160
        if (!isset($_POST["filterMediaType"])) {$_POST["filterMediaType"] = []; }
161
        if (!is_array($_POST["filterMediaType"])) { $_POST["filterMediaType"] = [ $_POST["filterMediaType"] ];}
162
        $_SESSION["filterMediaType"]["CD"] = in_array("CD", $_POST["filterMediaType"]);
163
        $_SESSION["filterMediaType"]["Record"] = in_array("Record", $_POST["filterMediaType"]);
164
        $_SESSION["filterMediaType"]["Digital"] = in_array("Digital", $_POST["filterMediaType"]);
165
        $_SESSION["filterMediaType"]["Book"] = in_array("Book", $_POST["filterMediaType"]);
2 - 166
 
46 - 167
        $_SESSION["discogsTitle"] = "";
168
        $_SESSION["discogsArtist"] = "";
65 - 169
        $searchTerm = searchFriendlyString($_POST['searchTerm']);
170
        if (empty($searchTerm)) {
171
            resetSessionVars();
172
        }
173
        else {
174
            $_SESSION["searchTerm"] = $searchTerm;
116 - 175
            performSearch();
65 - 176
        }
177
    }
178
    else if ($_POST["submit"] == "discogsSearch") {
50 - 179
        $searchTerm = "";
180
        if (!empty($_POST['discogsBarcode'])) {
65 - 181
            $searchTerm = searchFriendlyString($_POST['discogsBarcode']);
182
        }
183
        else {
50 - 184
            if (!empty($_POST['discogsTitle'])) {
185
                $searchTerm = $_POST['discogsTitle'];
186
            }
58 - 187
 
50 - 188
            if (!empty($_POST['discogsArtist'])) {
189
                $searchTerm .= " " . $_POST['discogsArtist'];
190
            }
58 - 191
 
50 - 192
            $searchTerm = trim($searchTerm);
193
        }
194
 
65 - 195
        if (empty($searchTerm)) {
196
            resetSessionVars();
197
        }
198
        else {
199
            $_SESSION["searchTerm"] = $searchTerm;
46 - 200
            if (isset($_POST['discogsTitle'])) {
201
                $_SESSION["discogsTitle"] = searchFriendlyString($_POST['discogsTitle']);
202
            }
203
            if (isset($_POST['discogsArtist'])) {
204
                $_SESSION["discogsArtist"] = searchFriendlyString($_POST['discogsArtist']);
205
            }
14 - 206
 
116 - 207
            performSearch();
65 - 208
        }
209
    }
73 - 210
    else if ($_POST["submit"] == "unsubscribe") {
211
// bugbug
212
    }
65 - 213
}
214
else if ($_SERVER["REQUEST_METHOD"] == "GET") {
215
    if (isset($_GET['z'])) {
216
        $_SESSION["buyer"]["Zip"] = "";
217
        $zip = sanitizeInput($_GET['z']);
218
        if (strlen($zip) == 5 && preg_match("/^[0-9 ]*$/", $zip)) {
219
            $_SESSION["buyer"]["Zip"] = $zip;
220
        }
221
    }
2 - 222
 
9 - 223
    $_SESSION["searchTerm"] = "";
65 - 224
    if (isset($_GET['q'])) {
225
        $_SESSION["searchTerm"] = searchFriendlyString($_GET["q"]);
116 - 226
        performSearch();
65 - 227
    }
2 - 228
}
229
?>
14 - 230
    <form method="post" action="/index.php">
116 - 231
        <input type="hidden" name="sessionTab" value="<?php echo MySessionHandler::getSessionTab(); ?>" />
232
       	<input type="hidden" name="searchTerm" value="<?php echo getSV("searchTerm") ?>" />
122 - 233
		<input type="hidden" name="nonce" value="<?php echo $_SESSION['nonce']; ?>" />
81 - 234
        <nav class="navbar navbar-expand-sm bg-black navbar-dark fixed-top">
35 - 235
            <div class="navbar-header">
107 - 236
                <button type="submit" name="submit" value="Search" class="btn text-white" aria-label="Go to home page">Find Cheap Music</button>
35 - 237
            </div>
107 - 238
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar" aria-label="Open Menu">
14 - 239
                <span class="navbar-toggler-icon"></span>
240
            </button>
241
            <div class="collapse navbar-collapse" id="collapsibleNavbar">
35 - 242
                <ul class="navbar-nav mr-auto">
14 - 243
                    <li class="nav-item">
116 - 244
                        <button type="submit" name="submit" value="Search" class="nav-link btn" aria-label="Go to home page"><i class="material-icons">home</i></button>
35 - 245
                    </li>
246
                    <?php if (isLoggedIn()) { ?>
247
                        <li class="nav-item">
248
                            <button type="submit" name="submit" value="coupons" class="nav-link btn">Coupons</button>
249
                        </li>
45 - 250
                        <li class="nav-item">
79 - 251
                            <button type="submit" name="submit" value="wishlist" class="nav-link btn">Wishlist
121 - 252
                            <?php if (!empty($_SESSION['priceMonitor']['newFlag']) && $_SESSION['priceMonitor']['newFlag'] === true) { echo '<span class="badge badge-pill badge-light">New</span>'; } ?>
79 - 253
                            </button>
45 - 254
                        </li>
65 - 255
                    <?php
256
} ?>
119 - 257
                    <li class="nav-item d-none d-lg-block">
15 - 258
                        <button type="submit" name="submit" value="terms" class="nav-link btn">Terms of Service</button>
14 - 259
                    </li>
119 - 260
                    <li class="nav-item d-none d-lg-block">
15 - 261
                        <button type="submit" name="submit" value="privacy" class="nav-link btn">Privacy Policy</button>
14 - 262
                    </li>
57 - 263
                    <li class="nav-item">
114 - 264
                        <a href="https://blog.findcheapmusic.com" target="_blank" rel="noreferrer noopener" class="nav-link" role="button">Blog</a>
57 - 265
                    </li>
107 - 266
                    <li class="nav-item">
116 - 267
                        <button type="submit" name="submit" value="help" class="nav-link btn" aria-label="Go to Help Page"><i class="material-icons">help_outline</i></button>
107 - 268
                    </li>
14 - 269
                </ul>
35 - 270
                <ul class="navbar-nav">
271
                    <?php if (!isLoggedIn()) { ?>
272
                    <li class="nav-item">
119 - 273
                        <a href="/login/index.php" class="nav-link"><svg class="svg-24" viewBox="0 0 24 24"><path fill="currentColor" d="M10,17V14H3V10H10V7L15,12L10,17M10,2H19A2,2 0 0,1 21,4V20A2,2 0 0,1 19,22H10A2,2 0 0,1 8,20V18H10V20H19V4H10V6H8V4A2,2 0 0,1 10,2Z" /></svg> Login</a>
35 - 274
                    </li>
65 - 275
                    <?php
276
}
277
else { ?>
36 - 278
                        <li class="nav-item">
108 - 279
                            <img class="img-fluid hide-extra-small hide-small user-img" src="<?php echo timeStampUrl($userPicture); ?>" alt="User Image">
36 - 280
                        </li>
35 - 281
                        <li class="nav-item dropdown">
116 - 282
                          <a class="nav-link dropdown-toggle" href="#" id="navbardrop" data-toggle="dropdown"><i class="material-icons material-text">account_box</i> Account</a>
35 - 283
                          <div class="dropdown-menu dropdown-menu-right">
119 - 284
                              <button formaction="/login/account.php" type="submit" name="submit" value="account" class="dropdown-item btn"><svg class="svg-24" viewBox="0 0 24 24"><path fill="currentColor" d="M12,4A4,4 0 0,1 16,8A4,4 0 0,1 12,12A4,4 0 0,1 8,8A4,4 0 0,1 12,4M12,14C16.42,14 20,15.79 20,18V20H4V18C4,15.79 7.58,14 12,14Z" /></svg> Information</button>
285
                              <button formaction="/login/editAccount.php" type="submit" name="submit" value="editAccount" class="dropdown-item btn"><svg class="svg-24" viewBox="0 0 24 24"><path fill="currentColor" d="M21.7,13.35L20.7,14.35L18.65,12.3L19.65,11.3C19.86,11.09 20.21,11.09 20.42,11.3L21.7,12.58C21.91,12.79 21.91,13.14 21.7,13.35M12,18.94L18.06,12.88L20.11,14.93L14.06,21H12V18.94M12,14C7.58,14 4,15.79 4,18V20H10V18.11L14,14.11C13.34,14.03 12.67,14 12,14M12,4A4,4 0 0,0 8,8A4,4 0 0,0 12,12A4,4 0 0,0 16,8A4,4 0 0,0 12,4Z" /></svg> Edit Account</button>
36 - 286
                              <?php if (empty($_SESSION['sessData']['loginType']) || $_SESSION['sessData']['loginType'] != 'social') { ?>
119 - 287
                                  <button formaction="/login/changePassword.php" type="submit" name="submit" value="changePassword" class="dropdown-item btn"><svg class="svg-24" viewBox="0 0 24 24"><path fill="currentColor" d="M12.63,2C18.16,2 22.64,6.5 22.64,12C22.64,17.5 18.16,22 12.63,22C9.12,22 6.05,20.18 4.26,17.43L5.84,16.18C7.25,18.47 9.76,20 12.64,20A8,8 0 0,0 20.64,12A8,8 0 0,0 12.64,4C8.56,4 5.2,7.06 4.71,11H7.47L3.73,14.73L0,11H2.69C3.19,5.95 7.45,2 12.63,2M15.59,10.24C16.09,10.25 16.5,10.65 16.5,11.16V15.77C16.5,16.27 16.09,16.69 15.58,16.69H10.05C9.54,16.69 9.13,16.27 9.13,15.77V11.16C9.13,10.65 9.54,10.25 10.04,10.24V9.23C10.04,7.7 11.29,6.46 12.81,6.46C14.34,6.46 15.59,7.7 15.59,9.23V10.24M12.81,7.86C12.06,7.86 11.44,8.47 11.44,9.23V10.24H14.19V9.23C14.19,8.47 13.57,7.86 12.81,7.86Z" /></svg> Change Password</button>
65 - 288
                              <?php
289
    } ?>
119 - 290
                              <button formaction="/login/userAccount.php?logoutSubmit=1" type="submit" name="submit" value="logout" class="dropdown-item btn"><svg class="svg-24" viewBox="0 0 24 24"><path fill="currentColor" d="M16,17V14H9V10H16V7L21,12L16,17M14,2A2,2 0 0,1 16,4V6H14V4H5V20H14V18H16V20A2,2 0 0,1 14,22H5A2,2 0 0,1 3,20V4A2,2 0 0,1 5,2H14Z" /></svg> Logout</button>
35 - 291
                          </div>
292
                        </li>
65 - 293
                    <?php
294
} ?>
35 - 295
                </ul>
14 - 296
            </div>
297
        </nav>
298
    </form>
2 - 299
 
3 - 300
    <div class="page-header bg-primary">
301
        <div class="container text-center py-3">
14 - 302
        <?php
65 - 303
if (getPGV('submit') == "terms") {
304
    echo file_get_contents('snippets/headerTerms.txt');
305
}
306
else if (getPGV('submit') == "privacy") {
307
    echo file_get_contents('snippets/headerPrivacy.txt');
308
}
309
else if (getPGV('submit') == "coupons") {
310
    echo file_get_contents('snippets/headerCoupons.txt');
311
}
312
else if (getPGV('submit') == "wishlist") {
313
    echo file_get_contents('snippets/headerWishlist.txt');
78 - 314
    if (!empty($_SESSION['priceMonitor'])) {
315
    ?>
316
    <form method="post" action="/index.php">
116 - 317
        <input type="hidden" name="sessionTab" value="<?php echo MySessionHandler::getSessionTab(); ?>" />
122 - 318
        <input type="hidden" name="nonce" value="<?php echo $_SESSION['nonce']; ?>" />
79 - 319
        <button id="priceMonitor" type="submit" class="btn btn-success rounded" name="submit" value="priceMonitor">Price Monitor Results
121 - 320
        <?php if (!empty($_SESSION['priceMonitor']['newFlag']) && $_SESSION['priceMonitor']['newFlag'] === true) { echo '<span class="badge badge-pill badge-dark">New</span>'; } ?>
79 - 321
        </button>
78 - 322
    </form>
323
    <?php
324
    }
65 - 325
}
78 - 326
else if (getPGV('submit') == "priceMonitor") {
327
    echo file_get_contents('snippets/headerPriceMonitor.txt');
328
}
65 - 329
else if (getPGV('submit') == "help") {
330
    echo file_get_contents('snippets/headerHelp.txt');
331
}
113 - 332
else if (getPGV('submit') == "barcode") {
333
    echo file_get_contents('snippets/headerBarcode.txt');
334
}
73 - 335
else if (getPGV('submit') == "unsubscribe") {
336
    echo file_get_contents('snippets/unsubscribeWishlist.txt');
337
}
65 - 338
else {
114 - 339
    echo '<h1>Find Cheap CDs, Records, Digital, Books and Sheets</h1>';
107 - 340
    echo '<p id="textslide" class="d-none d-sm-block">Bookmark FindCheapMusic.com</p>';
65 - 341
}
342
?>
2 - 343
        </div>
344
    </div>
345
 
3 - 346
	<div class="container-fluid bg-primary py-3">
65 - 347
        <form <?php if (in_array(getPGV('submit') , array(
348
    "terms",
349
    "privacy",
350
    "coupons",
351
    "wishlist",
78 - 352
    "priceMonitor",
73 - 353
    "help",
113 - 354
    "barcode",
73 - 355
    "unsubscribe"
356
 
65 - 357
))) {
107 - 358
    echo "hidden=\"hidden\"";
120 - 359
} ?> id="searchForm" method="post" action="/index.php" class="form-inline">
116 - 360
            <input id="sessionId" type="hidden" name="sessionId" value="<?php echo session_id(); ?>" />
361
            <input id="sessionTab" type="hidden" name="sessionTab" value="<?php echo MySessionHandler::getSessionTab(); ?>" />
122 - 362
            <input type="hidden" name="nonce" value="<?php echo $_SESSION['nonce']; ?>" />
119 - 363
            <div class="hidden-default-btn">
364
                <button type="submit" name="submit" value="Search">Hidden Submit Button</button>
113 - 365
            </div>
366
            <div class="form-group">
17 - 367
                <div class="btn-group">
116 - 368
                    <button class="btn input-group-text mx-1 rounded" type="button" data-toggle="modal" data-target="#searchInfoModal" data-toggle2="tooltip" title="Search Tips" aria-label="Search Tips"><i class="material-icons">info_outline</i></button>
120 - 369
                    <button id="barcodeBtn" class="btn input-group-text mx-1 rounded py-0" type="submit" name="submit" value="barcode" data-toggle="tooltip" title="Barcode Checker" aria-label="Barcode Checker"><svg class="svg-24" viewbox="0 0 24 24"><path fill="currentColor" d="M2,6H4V18H2V6M5,6H6V18H5V6M7,6H10V18H7V6M11,6H12V18H11V6M14,6H16V18H14V6M17,6H20V18H17V6M21,6H22V18H21V6Z" /></svg></button>
2 - 370
                </div>
371
        	</div>
20 - 372
        	<div class="form-group mx-1">
116 - 373
        	    <input id="searchTerm" list="searchHistory" name="searchTerm" type="text" class="form-control flexdatalist searchTerm-width" placeholder="Search by Barcode, Artist, Title, ..." aria-label="Search Term Input" value="<?php echo getSV("searchTerm") ?>" />
17 - 374
        	    <datalist id="searchHistory">
375
            	    <?php echo getSearchHistory(); ?>
376
            	</datalist>
377
            </div>
378
        	<div class="form-group">
379
                <button id="searchBtn" type="submit" class="btn btn-success mx-1 rounded" name="submit" value="Search">Go</button>
380
            </div>
2 - 381
        </form>
120 - 382
<script nonce="<?php echo base64_encode($_SESSION["nonce"]); ?>">
383
document.addEventListener('DOMContentLoaded', function() {
384
	document.getElementById('searchForm').addEventListener('submit', function searchFormOnSubmit() {
385
		if(document.getElementById('searchTerm').value !== '') {
386
			progressBar('Searching for:<br><br><strong>' + document.getElementById('searchTerm').value.toLowerCase().replace(/(?:(^.{1})|\ [a-z]{1})/g, function(a) {
387
				return a.toUpperCase();
388
			}) + '</strong>');
389
			document.getElementById('searchBtn').innerHTML = '<span class=\'spinner-border spinner-border-sm\'></span> Searching, please wait...';
390
		}
391
	});
392
});
393
document.addEventListener('DOMContentLoaded', function() {
394
	document.getElementById('barcodeBtn').addEventListener('click', function() {
395
        document.getElementById('searchTerm').value = '';
396
	});
397
});
398
</script>
2 - 399
    </div>
400
 
5 - 401
    <?php
65 - 402
if (getPGV('submit') == "terms") {
120 - 403
    $snip = file_get_contents('snippets/terms.txt');
404
    $snip = str_replace("<script>", "<script nonce=\"" . base64_encode($_SESSION["nonce"]) . "\">", $snip);
405
    echo $snip;
65 - 406
}
407
else if (getPGV('submit') == "privacy") {
120 - 408
    $snip = file_get_contents('snippets/privacy.txt');
409
    $snip = str_replace("<script>", "<script nonce=\"" . base64_encode($_SESSION["nonce"]) . "\">", $snip);
410
    echo $snip;
65 - 411
}
412
else if (getPGV('submit') == "help") {
108 - 413
    include 'php/help.php';
65 - 414
}
113 - 415
else if (getPGV('submit') == "barcode") {
416
    echo '
114 - 417
<div class="container py-4 bg-light border">
113 - 418
    <div class="my-3">
419
    <p>This tool verifies Music CD barcodes or calculates the check digit.<br>See our <a href="https://blog.findcheapmusic.com/2020/03/music-cd-barcodes-and-identifiers.html" target="_blank" rel="noopener noreferrer">blog post</a> for more information about music barcodes.</p>
420
        <form id="barcodeForm">
116 - 421
    	    <input type="hidden" name="sessionTab" value="' . MySessionHandler::getSessionTab() . '" />
422
            <input type="hidden" name="searchTerm" value="' . getSV("searchTerm") . '" />
122 - 423
            <input type="hidden" name="nonce" value="' . $_SESSION['nonce'] . '" />
113 - 424
            <div class="input-group mb-3">
116 - 425
        	    <input id="barcode" name="barcode" type="text" class="" placeholder="Enter Barcode..." aria-label="Barcode Input" />
113 - 426
                    <div class="input-group-append">
120 - 427
                        <button id="barcodeFormVerify" type="submit" class="btn btn-success barcodeButton" name="submit" value="check">Verify</button>
428
                        <button id="barcodeFormCalc"  type="submit" class="btn btn-info barcodeButton" name="submit" value="calc">Calculate</button>
113 - 429
                    </div>
430
            </div>
431
        </form>
120 - 432
<script nonce="' . base64_encode($_SESSION["nonce"]) . '">
433
document.addEventListener("DOMContentLoaded", function() {
434
	document.getElementById("barcodeFormVerify").addEventListener("click", function() {
122 - 435
        window.dataLayer.push({"barcode": document.getElementById("barcode").value}); // bugbug rename
120 - 436
	});
437
	document.getElementById("barcodeFormCalc").addEventListener("click", function() {
122 - 438
        window.dataLayer.push({"barcode": document.getElementById("barcode").value}); // bugbug rename
120 - 439
	});
440
});
441
</script>
113 - 442
        <div id="barcodeResult"></div>
443
    </div>
444
</div>
445
';
446
}
65 - 447
else if (getPGV('submit') == "coupons") {
448
    //get_linkshareCoupons(); // bugbug
449
    echo getCouponCodes();
450
}
451
else if (getPGV('submit') == "wishlist") {
452
    echo getWishlist();
453
}
78 - 454
else if (getPGV('submit') == "priceMonitor") {
455
    echo "<div id=\"productTable\" class=\"container bg-secondary border pt-2\">";
456
    echo getPriceMonitor(); // bugbug
457
    echo "</div>";
458
}
73 - 459
else if (getPGV('submit') == "unsubscribe") {
460
    echo unsubscribeWishlist($_GET);
461
}
65 - 462
else if (getPGV('submit') == "random") {
463
    findDiscogsMaster("***RANDOM***");
119 - 464
    if (!empty($_SESSION["discogs"])) {
121 - 465
        echo str_replace("xxxNONCExxx", base64_encode($_SESSION["nonce"]), $_SESSION["discogs"]);
119 - 466
    }
65 - 467
}
468
else {
469
    if ($_SESSION["lowestPrice"]["All"] > 0.00 || !empty($_SESSION["searchTerm"])) {
121 - 470
        echo str_replace("xxxNONCExxx", base64_encode($_SESSION["nonce"]), $_SESSION["discogs"]);
104 - 471
        echo "<div id=\"productTable\" class=\"container bg-secondary border py-2\">";
107 - 472
        echo "<h2 class=\"text-center py-2\">Store Offers</h2>";
104 - 473
        if ($_SESSION["lowestPrice"]["All"] > 0.00) {
474
            echo printResultHeader();
475
        }
65 - 476
        echo printResult();
477
        echo "</div>";
478
    }
479
    else if (!empty($_SESSION["discogs"])) {
121 - 480
        echo str_replace("xxxNONCExxx", base64_encode($_SESSION["nonce"]), $_SESSION["discogs"]);
65 - 481
    }
482
    else {
483
?>
110 - 484
    <div class="container-fluid text-center mb-2">
38 - 485
    <form method="post" action="/index.php">
116 - 486
        <input type="hidden" name="sessionTab" value="<?php echo MySessionHandler::getSessionTab(); ?>" />
487
       	<input type="hidden" name="searchTerm" value="<?php echo getSV("searchTerm") ?>" />
122 - 488
        <input type="hidden" name="nonce" value="<?php echo $_SESSION['nonce']; ?>" />
43 - 489
        <button id="randomBtn" type="submit" class="btn btn-success mt-5 rounded" name="submit" value="random">Random Album Suggestions</button>
38 - 490
    </form>
491
    </div>
110 - 492
    <div class="container bg-secondary border py-2 mt-4">
493
    <h2 class="text-center py-2">Getting Started</h2>
116 - 494
    <p>Welcome to Find Cheap Music. Here you can search dozens of trusted online stores at once. The below information details the major website features and is also available via the link to the help page (<i class="material-icons material-text">help_outline</i>) up top.</p>
110 - 495
    <hr>
108 - 496
    <?php include 'php/help.php'; ?>
110 - 497
    </div>
65 - 498
        <?php
14 - 499
    }
65 - 500
    echo printSearchInfoModal();
501
}
502
?>
2 - 503
 
14 - 504
    <div class="modal" id="progressBarDiv">
17 - 505
        <div class="modal-dialog modal-dialog-centered">
14 - 506
            <div class="modal-content">
507
                <div class="modal-header">
107 - 508
                    <p id="progressBarHeader" class="display-6">Searching</p>
14 - 509
                </div>
510
                <div class="modal-body">
511
                    <div class="progress">
119 - 512
                        <div id="progressBar" class="progress-bar">0%</div>
14 - 513
                    </div>
514
                </div>
15 - 515
                <div class="modal-footer">
516
                    <span id="progressBarMessage"></span>
517
                </div>
14 - 518
            </div>
519
        </div>
520
    </div>
521
 
120 - 522
    <button id="topBtn" title="Go to top">Top</button>
523
<script nonce="<?php echo base64_encode($_SESSION["nonce"]); ?>">
524
document.addEventListener('DOMContentLoaded', function() {
525
	document.getElementById('topBtn').addEventListener('click', function() {
526
        topFunction();
527
	});
528
});
529
</script>
81 - 530
 
64 - 531
    <footer class="container-fluid text-center bg-primary py-5">
78 - 532
        <?php if (!empty($_SESSION["searchTerm"]) || getPGV('submit') == "priceMonitor") {
114 - 533
            echo "<p>Disclaimer: As an Associate we earn from qualifying purchases.</p>";
534
        } ?>
535
        <p>
536
            <a href="https://www.facebook.com/FindCheapMusic" target="_blank" rel="noopener noreferrer"><img class="socialBtn lazyload" src="data:image/png;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=" data-src="images/f_logo_RGB-Blue_58.png" alt="Facebook Logo" /></a>
537
            <a href="https://twitter.com/findcheapmusic" target="_blank" rel="noopener noreferrer"><img class="socialBtn lazyload" src="data:image/png;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=" data-src="images/Twitter_Social_Icon_Circle_Color.png" alt="Twitter Logo" /></a>
538
        </p>
17 - 539
        <p>Copyright &#169; <?php echo @date("Y"); ?> FindCheapMusic.com. All rights reserved.</p>
123 - 540
        <form class="d-lg-none" method="post" action="/index.php">
541
            <input type="hidden" name="sessionTab" value="<?php echo MySessionHandler::getSessionTab(); ?>">
542
            <input type="hidden" name="searchTerm" value="<?php echo getSV("searchTerm") ?>">
543
                <input type="hidden" name="buyerZip" value="<?php echo $_SESSION["buyer"]["Zip"]; ?>">
544
            <ul class="list-inline text-center">
545
                <li class="list-inline-item">
546
                    <button class="btn btn-sm btn-light" type="submit" name="submit" value="terms">Terms of Service</button>
547
                </li>
548
                <li class="list-inline-item">
549
                    <button class="btn btn-sm btn-light" type="submit" name="submit" value="privacy">Privacy Policy</button>
550
                </li>
551
            </ul>
552
        </form>
2 - 553
    </footer>
554
 
119 - 555
    <script nonce="<?php echo base64_encode($_SESSION["nonce"]); ?>">var quotes = [
38 - 556
    <?php
65 - 557
if ($file = fopen("snippets/header.txt", "r")) {
558
    while (($line = fgets($file)) !== false) {
559
        echo "\"" . trim($line) . "\",";
560
    }
561
    fclose($file);
562
}
563
?>
83 - 564
    ]; setInterval(function() { $("#textslide").html(quotes[Math.floor(Math.random() * (quotes.length + 1))]); }, 5 * 1000);
565
    </script>
114 - 566
    <?php include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/downloadAtOnload.php"); ?>
121 - 567
    <form><input type="hidden" id="nonce" name="nonce" value="<?php echo $_SESSION["nonce"]; ?>" /></form>
2 - 568
</body>
569
</html>
21 - 570
<?php MySessionHandler::commit(session_id()); ?>