Subversion Repositories cheapmusic

Rev

Rev 119 | Rev 121 | 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
 
65 - 3
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/dnsexit.php");
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);
119 - 21
$nonceSecret = $configFile['nonce']['secret'];
7 - 22
unset($configFile);
23
 
120 - 24
//ini_set("session.cookie_httponly", 1);
25
//ini_set("session.cookie_secure", 1);
26
session_set_cookie_params(604800, '/', '.findcheapmusic.com', true, true);
7 - 27
session_set_save_handler($handler, true);
35 - 28
if (!empty($_COOKIE['PHPSESSID'])) {
29
    session_id($_COOKIE['PHPSESSID']);
30
}
2 - 31
session_start();
35 - 32
 
119 - 33
$_SESSION["nonce"] = NonceUtil::generate($nonceSecret);
34
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/csp.php");
35
 
35 - 36
// Check whether user ID is available in cookie
65 - 37
if (!empty($_COOKIE['rememberUserId']) && !empty($_COOKIE['hash']) && empty($_SESSION['sessData']['loginType'])) {
35 - 38
    require_once 'login/includes/config.php';
39
    require_once 'login/includes/User.class.php';
40
    require_once 'login/includes/password.php';
41
    $user = new User();
42
    $conditions['where'] = array(
43
        'id' => $_COOKIE['rememberUserId']
44
    );
45
    $conditions['return_type'] = 'single';
46
    $userData = $user->getRows($conditions);
47
    if (!empty($userData) && password_verify($userData['password'] . $userData['id'], $_COOKIE['hash'])) {
65 - 48
        $_SESSION['sessData']['userLoggedIn'] = true;
35 - 49
        $_SESSION['sessData']['userID'] = $_COOKIE['rememberUserId'];
36 - 50
        $userPicture = getUserImage($userData);
57 - 51
        $userTheme = $userData['theme'];
59 - 52
        $_SESSION["currentLayout"] = ($userData['cardView'] == '1' ? 'CardView' : 'TableView');
57 - 53
        if (empty($_SESSION["manualFilter"])) {
54
            $_SESSION['buyer']['Zip'] = $userData['zip'];
55
            $_SESSION['buyer']['Country'] = 'United States';
56
            $_SESSION['buyer']['Currency'] = 'USD';
65 - 57
            $_SESSION["filterCondition"]["New"] = $userData['conditionNew'];
58
            $_SESSION["filterCondition"]["Used"] = $userData['conditionUsed'];
59
            $_SESSION["filterMediaType"]["CD"] = $userData['mediaCD'];
60
            $_SESSION["filterMediaType"]["Record"] = $userData['mediaRecord'];
61
            $_SESSION["filterMediaType"]["Digital"] = $userData['mediaDigital'];
62
            $_SESSION["filterMediaType"]["Book"] = $userData['mediaBook'];
63
        }
64
    }
65
    else {
35 - 66
        unsetSessData();
67
    }
65 - 68
    // or if the user has already logged in
114 - 69
 
65 - 70
}
71
else if (isLoggedIn()) {
35 - 72
    require_once 'login/includes/config.php';
73
    require_once 'login/includes/User.class.php';
74
    require_once 'login/includes/password.php';
75
    $user = new User();
76
    $conditions['where'] = array(
77
        'id' => $_SESSION['sessData']['userID']
78
    );
79
    $conditions['return_type'] = 'single';
80
    $userData = $user->getRows($conditions);
57 - 81
 
35 - 82
    if (!empty($userData)) {
36 - 83
        $userPicture = getUserImage($userData);
57 - 84
        $userTheme = $userData['theme'];
59 - 85
        $_SESSION["currentLayout"] = ($userData['cardView'] == '1' ? 'CardView' : 'TableView');
57 - 86
        if (empty($_SESSION["manualFilter"])) {
35 - 87
            $_SESSION['buyer']['Zip'] = $userData['zip'];
88
            $_SESSION['buyer']['Country'] = 'United States';
89
            $_SESSION['buyer']['Currency'] = 'USD';
65 - 90
            $_SESSION["filterCondition"]["New"] = $userData['conditionNew'];
91
            $_SESSION["filterCondition"]["Used"] = $userData['conditionUsed'];
92
            $_SESSION["filterMediaType"]["CD"] = $userData['mediaCD'];
93
            $_SESSION["filterMediaType"]["Record"] = $userData['mediaRecord'];
94
            $_SESSION["filterMediaType"]["Digital"] = $userData['mediaDigital'];
95
            $_SESSION["filterMediaType"]["Book"] = $userData['mediaBook'];
35 - 96
        }
65 - 97
    }
98
    else {
35 - 99
        unsetSessData();
100
    }
65 - 101
    // not logged in
114 - 102
 
65 - 103
}
104
else {
35 - 105
    unsetSessData();
106
}
57 - 107
 
78 - 108
checkPriceMonitor();
2 - 109
?>
110
<!DOCTYPE html>
111
<html lang="en-US">
112
<head>
107 - 113
    <title>Find Cheap Music | CDs, Records, Digital, Books and Sheets</title>
114 - 114
    <meta name="keywords" content="Cheap,Music,Album,Single,Promo,CD,Compact Disc,Vinyl,Record,Digital,Download,Sheet,Book">
115
    <?php echo metaDescription(getPGV('submit')); ?>
70 - 116
    <?php include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/header.php"); ?>
114 - 117
 
107 - 118
    <?php echo file_get_contents('snippets/fb_tw.txt'); ?>
2 - 119
</head>
120
<body>
121
 
122
<?php
119 - 123
if ($_SERVER["SERVER_NAME"] == "www.findcheapmusic.com") {
120 - 124
    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 - 125
}
126
 
5 - 127
initSessionVariables();
2 - 128
 
129
if ($_SERVER["REQUEST_METHOD"] == "POST") {
65 - 130
    if ($_POST["submit"] == "Search") {
35 - 131
        if (empty($_SESSION['buyer']['Zip'])) {
65 - 132
            $zip = (empty($_POST['buyerZip']) ? "" : sanitizeInput($_POST['buyerZip']));
133
            if (strlen($zip) == 5 && preg_match("/^[0-9 ]*$/", $zip)) {
57 - 134
                if ($_SESSION["buyer"]["Zip"] != $zip) {
65 - 135
                    $_SESSION["manualFilter"] = true;
136
                    $_SESSION["buyer"]["Zip"] = $zip;
137
                }
138
            }
139
            else if (strlen($zip) == 0) {
140
                $_SESSION["buyer"]["Zip"] = "";
141
            }
142
        }
2 - 143
 
46 - 144
        $_SESSION["discogsTitle"] = "";
145
        $_SESSION["discogsArtist"] = "";
65 - 146
        $searchTerm = (empty($_POST['searchTerm']) ? "" : searchFriendlyString($_POST['searchTerm']));
147
        if (empty($searchTerm)) {
148
            resetSessionVars();
149
        }
150
        else {
151
            $_SESSION["searchTerm"] = $searchTerm;
116 - 152
            performSearch();
65 - 153
        }
154
    }
155
    else if ($_POST["submit"] == "Save") {
156
        $_SESSION["manualFilter"] = true;
66 - 157
        if (!isset($_POST["filterCondition"])) {$_POST["filterCondition"] = []; }
158
        if (!is_array($_POST["filterCondition"])) { $_POST["filterCondition"] = [ $_POST["filterCondition"] ];}
159
        $_SESSION["filterCondition"]["New"] = in_array("New", $_POST["filterCondition"]);
160
        $_SESSION["filterCondition"]["Used"] = in_array("Used", $_POST["filterCondition"]);
161
        if (!isset($_POST["filterMediaType"])) {$_POST["filterMediaType"] = []; }
162
        if (!is_array($_POST["filterMediaType"])) { $_POST["filterMediaType"] = [ $_POST["filterMediaType"] ];}
163
        $_SESSION["filterMediaType"]["CD"] = in_array("CD", $_POST["filterMediaType"]);
164
        $_SESSION["filterMediaType"]["Record"] = in_array("Record", $_POST["filterMediaType"]);
165
        $_SESSION["filterMediaType"]["Digital"] = in_array("Digital", $_POST["filterMediaType"]);
166
        $_SESSION["filterMediaType"]["Book"] = in_array("Book", $_POST["filterMediaType"]);
2 - 167
 
46 - 168
        $_SESSION["discogsTitle"] = "";
169
        $_SESSION["discogsArtist"] = "";
65 - 170
        $searchTerm = searchFriendlyString($_POST['searchTerm']);
171
        if (empty($searchTerm)) {
172
            resetSessionVars();
173
        }
174
        else {
175
            $_SESSION["searchTerm"] = $searchTerm;
116 - 176
            performSearch();
65 - 177
        }
178
    }
179
    else if ($_POST["submit"] == "discogsSearch") {
50 - 180
        $searchTerm = "";
181
        if (!empty($_POST['discogsBarcode'])) {
65 - 182
            $searchTerm = searchFriendlyString($_POST['discogsBarcode']);
183
        }
184
        else {
50 - 185
            if (!empty($_POST['discogsTitle'])) {
186
                $searchTerm = $_POST['discogsTitle'];
187
            }
58 - 188
 
50 - 189
            if (!empty($_POST['discogsArtist'])) {
190
                $searchTerm .= " " . $_POST['discogsArtist'];
191
            }
58 - 192
 
50 - 193
            $searchTerm = trim($searchTerm);
194
        }
195
 
65 - 196
        if (empty($searchTerm)) {
197
            resetSessionVars();
198
        }
199
        else {
200
            $_SESSION["searchTerm"] = $searchTerm;
46 - 201
            if (isset($_POST['discogsTitle'])) {
202
                $_SESSION["discogsTitle"] = searchFriendlyString($_POST['discogsTitle']);
203
            }
204
            if (isset($_POST['discogsArtist'])) {
205
                $_SESSION["discogsArtist"] = searchFriendlyString($_POST['discogsArtist']);
206
            }
14 - 207
 
116 - 208
            performSearch();
65 - 209
        }
210
    }
73 - 211
    else if ($_POST["submit"] == "unsubscribe") {
212
// bugbug
213
    }
65 - 214
}
215
else if ($_SERVER["REQUEST_METHOD"] == "GET") {
216
    if (isset($_GET['z'])) {
217
        $_SESSION["buyer"]["Zip"] = "";
218
        $zip = sanitizeInput($_GET['z']);
219
        if (strlen($zip) == 5 && preg_match("/^[0-9 ]*$/", $zip)) {
220
            $_SESSION["buyer"]["Zip"] = $zip;
221
        }
222
    }
2 - 223
 
9 - 224
    $_SESSION["searchTerm"] = "";
65 - 225
    if (isset($_GET['q'])) {
226
        $_SESSION["searchTerm"] = searchFriendlyString($_GET["q"]);
116 - 227
        performSearch();
65 - 228
    }
2 - 229
}
230
?>
14 - 231
    <form method="post" action="/index.php">
116 - 232
        <input type="hidden" name="sessionTab" value="<?php echo MySessionHandler::getSessionTab(); ?>" />
233
       	<input type="hidden" name="searchTerm" value="<?php echo getSV("searchTerm") ?>" />
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
252
                            <?php if (!empty($_SESSION['priceMonitor']['newFlag']) && $_SESSION['priceMonitor']['newFlag'] === true) { echo '<scan class="badge badge-pill badge-light">New</scan>'; } ?>
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(); ?>" />
79 - 318
        <button id="priceMonitor" type="submit" class="btn btn-success rounded" name="submit" value="priceMonitor">Price Monitor Results
319
        <?php if (!empty($_SESSION['priceMonitor']['newFlag']) && $_SESSION['priceMonitor']['newFlag'] === true) { echo '<scan class="badge badge-pill badge-dark">New</scan>'; } ?>
320
        </button>
78 - 321
    </form>
322
    <?php
323
    }
65 - 324
}
78 - 325
else if (getPGV('submit') == "priceMonitor") {
326
    echo file_get_contents('snippets/headerPriceMonitor.txt');
327
}
65 - 328
else if (getPGV('submit') == "help") {
329
    echo file_get_contents('snippets/headerHelp.txt');
330
}
113 - 331
else if (getPGV('submit') == "barcode") {
332
    echo file_get_contents('snippets/headerBarcode.txt');
333
}
73 - 334
else if (getPGV('submit') == "unsubscribe") {
335
    echo file_get_contents('snippets/unsubscribeWishlist.txt');
336
}
65 - 337
else {
114 - 338
    echo '<h1>Find Cheap CDs, Records, Digital, Books and Sheets</h1>';
107 - 339
    echo '<p id="textslide" class="d-none d-sm-block">Bookmark FindCheapMusic.com</p>';
65 - 340
}
341
?>
2 - 342
        </div>
343
    </div>
344
 
3 - 345
	<div class="container-fluid bg-primary py-3">
65 - 346
        <form <?php if (in_array(getPGV('submit') , array(
347
    "terms",
348
    "privacy",
349
    "coupons",
350
    "wishlist",
78 - 351
    "priceMonitor",
73 - 352
    "help",
113 - 353
    "barcode",
73 - 354
    "unsubscribe"
355
 
65 - 356
))) {
107 - 357
    echo "hidden=\"hidden\"";
120 - 358
} ?> id="searchForm" method="post" action="/index.php" class="form-inline">
116 - 359
            <input id="sessionId" type="hidden" name="sessionId" value="<?php echo session_id(); ?>" />
360
            <input id="sessionTab" type="hidden" name="sessionTab" value="<?php echo MySessionHandler::getSessionTab(); ?>" />
119 - 361
            <div class="hidden-default-btn">
362
                <button type="submit" name="submit" value="Search">Hidden Submit Button</button>
113 - 363
            </div>
364
            <div class="form-group">
17 - 365
                <div class="btn-group">
116 - 366
                    <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 - 367
                    <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 - 368
                </div>
369
        	</div>
20 - 370
        	<div class="form-group mx-1">
116 - 371
        	    <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 - 372
        	    <datalist id="searchHistory">
373
            	    <?php echo getSearchHistory(); ?>
374
            	</datalist>
375
            </div>
376
        	<div class="form-group">
377
                <button id="searchBtn" type="submit" class="btn btn-success mx-1 rounded" name="submit" value="Search">Go</button>
378
            </div>
2 - 379
        </form>
120 - 380
<script nonce="<?php echo base64_encode($_SESSION["nonce"]); ?>">
381
document.addEventListener('DOMContentLoaded', function() {
382
	document.getElementById('searchForm').addEventListener('submit', function searchFormOnSubmit() {
383
		if(document.getElementById('searchTerm').value !== '') {
384
			progressBar('Searching for:<br><br><strong>' + document.getElementById('searchTerm').value.toLowerCase().replace(/(?:(^.{1})|\ [a-z]{1})/g, function(a) {
385
				return a.toUpperCase();
386
			}) + '</strong>');
387
			document.getElementById('searchBtn').innerHTML = '<span class=\'spinner-border spinner-border-sm\'></span> Searching, please wait...';
388
		}
389
	});
390
});
391
document.addEventListener('DOMContentLoaded', function() {
392
	document.getElementById('barcodeBtn').addEventListener('click', function() {
393
        document.getElementById('searchTerm').value = '';
394
	});
395
});
396
</script>
2 - 397
    </div>
398
 
5 - 399
    <?php
65 - 400
if (getPGV('submit') == "terms") {
120 - 401
    $snip = file_get_contents('snippets/terms.txt');
402
    $snip = str_replace("<script>", "<script nonce=\"" . base64_encode($_SESSION["nonce"]) . "\">", $snip);
403
    echo $snip;
65 - 404
}
405
else if (getPGV('submit') == "privacy") {
120 - 406
    $snip = file_get_contents('snippets/privacy.txt');
407
    $snip = str_replace("<script>", "<script nonce=\"" . base64_encode($_SESSION["nonce"]) . "\">", $snip);
408
    echo $snip;
65 - 409
}
410
else if (getPGV('submit') == "help") {
108 - 411
    include 'php/help.php';
65 - 412
}
113 - 413
else if (getPGV('submit') == "barcode") {
414
    echo '
114 - 415
<div class="container py-4 bg-light border">
113 - 416
    <div class="my-3">
417
    <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>
418
        <form id="barcodeForm">
116 - 419
    	    <input type="hidden" name="sessionTab" value="' . MySessionHandler::getSessionTab() . '" />
420
            <input type="hidden" name="searchTerm" value="' . getSV("searchTerm") . '" />
113 - 421
            <div class="input-group mb-3">
116 - 422
        	    <input id="barcode" name="barcode" type="text" class="" placeholder="Enter Barcode..." aria-label="Barcode Input" />
113 - 423
                    <div class="input-group-append">
120 - 424
                        <button id="barcodeFormVerify" type="submit" class="btn btn-success barcodeButton" name="submit" value="check">Verify</button>
425
                        <button id="barcodeFormCalc"  type="submit" class="btn btn-info barcodeButton" name="submit" value="calc">Calculate</button>
113 - 426
                    </div>
427
            </div>
428
        </form>
120 - 429
<script nonce="' . base64_encode($_SESSION["nonce"]) . '">
430
document.addEventListener("DOMContentLoaded", function() {
431
	document.getElementById("barcodeFormVerify").addEventListener("click", function() {
432
        dataLayer.push({"barcode": document.getElementById("barcode").value});
433
	});
434
	document.getElementById("barcodeFormCalc").addEventListener("click", function() {
435
        dataLayer.push({"barcode": document.getElementById("barcode").value});
436
	});
437
});
438
</script>
113 - 439
        <div id="barcodeResult"></div>
440
    </div>
441
</div>
442
';
443
}
65 - 444
else if (getPGV('submit') == "coupons") {
445
    //get_linkshareCoupons(); // bugbug
446
    echo getCouponCodes();
447
}
448
else if (getPGV('submit') == "wishlist") {
449
    echo getWishlist();
450
}
78 - 451
else if (getPGV('submit') == "priceMonitor") {
452
    echo "<div id=\"productTable\" class=\"container bg-secondary border pt-2\">";
453
    echo getPriceMonitor(); // bugbug
454
    echo "</div>";
455
}
73 - 456
else if (getPGV('submit') == "unsubscribe") {
457
    echo unsubscribeWishlist($_GET);
458
}
65 - 459
else if (getPGV('submit') == "random") {
460
    findDiscogsMaster("***RANDOM***");
119 - 461
    if (!empty($_SESSION["discogs"])) {
120 - 462
        echo str_replace("xxxNONCExx", base64_encode($_SESSION["nonce"]), $_SESSION["discogs"]);
119 - 463
    }
65 - 464
}
465
else {
466
    if ($_SESSION["lowestPrice"]["All"] > 0.00 || !empty($_SESSION["searchTerm"])) {
120 - 467
        echo str_replace("xxxNONCExx", base64_encode($_SESSION["nonce"]), $_SESSION["discogs"]);
104 - 468
        echo "<div id=\"productTable\" class=\"container bg-secondary border py-2\">";
107 - 469
        echo "<h2 class=\"text-center py-2\">Store Offers</h2>";
104 - 470
        if ($_SESSION["lowestPrice"]["All"] > 0.00) {
471
            echo printResultHeader();
472
        }
65 - 473
        echo printResult();
474
        echo "</div>";
475
    }
476
    else if (!empty($_SESSION["discogs"])) {
120 - 477
        echo str_replace("xxxNONCExx", base64_encode($_SESSION["nonce"]), $_SESSION["discogs"]);
65 - 478
    }
479
    else {
480
?>
110 - 481
    <div class="container-fluid text-center mb-2">
38 - 482
    <form method="post" action="/index.php">
116 - 483
        <input type="hidden" name="sessionTab" value="<?php echo MySessionHandler::getSessionTab(); ?>" />
484
       	<input type="hidden" name="searchTerm" value="<?php echo getSV("searchTerm") ?>" />
43 - 485
        <button id="randomBtn" type="submit" class="btn btn-success mt-5 rounded" name="submit" value="random">Random Album Suggestions</button>
38 - 486
    </form>
487
    </div>
110 - 488
    <div class="container bg-secondary border py-2 mt-4">
489
    <h2 class="text-center py-2">Getting Started</h2>
116 - 490
    <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 - 491
    <hr>
108 - 492
    <?php include 'php/help.php'; ?>
110 - 493
    </div>
65 - 494
        <?php
14 - 495
    }
65 - 496
    echo printSearchInfoModal();
497
}
498
?>
2 - 499
 
14 - 500
    <div class="modal" id="progressBarDiv">
17 - 501
        <div class="modal-dialog modal-dialog-centered">
14 - 502
            <div class="modal-content">
503
                <div class="modal-header">
107 - 504
                    <p id="progressBarHeader" class="display-6">Searching</p>
14 - 505
                </div>
506
                <div class="modal-body">
507
                    <div class="progress">
119 - 508
                        <div id="progressBar" class="progress-bar">0%</div>
14 - 509
                    </div>
510
                </div>
15 - 511
                <div class="modal-footer">
512
                    <span id="progressBarMessage"></span>
513
                </div>
14 - 514
            </div>
515
        </div>
516
    </div>
517
 
120 - 518
    <button id="topBtn" title="Go to top">Top</button>
519
<script nonce="<?php echo base64_encode($_SESSION["nonce"]); ?>">
520
document.addEventListener('DOMContentLoaded', function() {
521
	document.getElementById('topBtn').addEventListener('click', function() {
522
        topFunction();
523
	});
524
});
525
</script>
81 - 526
 
64 - 527
    <footer class="container-fluid text-center bg-primary py-5">
78 - 528
        <?php if (!empty($_SESSION["searchTerm"]) || getPGV('submit') == "priceMonitor") {
114 - 529
            echo "<p>Disclaimer: As an Associate we earn from qualifying purchases.</p>";
530
        } ?>
531
        <p>
532
            <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>
533
            <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>
534
        </p>
17 - 535
        <p>Copyright &#169; <?php echo @date("Y"); ?> FindCheapMusic.com. All rights reserved.</p>
2 - 536
    </footer>
537
 
119 - 538
    <script nonce="<?php echo base64_encode($_SESSION["nonce"]); ?>">var quotes = [
38 - 539
    <?php
65 - 540
if ($file = fopen("snippets/header.txt", "r")) {
541
    while (($line = fgets($file)) !== false) {
542
        echo "\"" . trim($line) . "\",";
543
    }
544
    fclose($file);
545
}
546
?>
83 - 547
    ]; setInterval(function() { $("#textslide").html(quotes[Math.floor(Math.random() * (quotes.length + 1))]); }, 5 * 1000);
548
    </script>
114 - 549
    <?php include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/downloadAtOnload.php"); ?>
120 - 550
    <form></form><input type="hidden" id="nonce" name="nonce" value="'<?php echo $_SESSION["nonce"]; ?>" /></form>
2 - 551
</body>
552
</html>
21 - 553
<?php MySessionHandler::commit(session_id()); ?>