Subversion Repositories cheapmusic

Rev

Rev 120 | Rev 122 | 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") ?>" />
81 - 233
        <nav class="navbar navbar-expand-sm bg-black navbar-dark fixed-top">
35 - 234
            <div class="navbar-header">
107 - 235
                <button type="submit" name="submit" value="Search" class="btn text-white" aria-label="Go to home page">Find Cheap Music</button>
35 - 236
            </div>
107 - 237
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar" aria-label="Open Menu">
14 - 238
                <span class="navbar-toggler-icon"></span>
239
            </button>
240
            <div class="collapse navbar-collapse" id="collapsibleNavbar">
35 - 241
                <ul class="navbar-nav mr-auto">
14 - 242
                    <li class="nav-item">
116 - 243
                        <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 - 244
                    </li>
245
                    <?php if (isLoggedIn()) { ?>
246
                        <li class="nav-item">
247
                            <button type="submit" name="submit" value="coupons" class="nav-link btn">Coupons</button>
248
                        </li>
45 - 249
                        <li class="nav-item">
79 - 250
                            <button type="submit" name="submit" value="wishlist" class="nav-link btn">Wishlist
121 - 251
                            <?php if (!empty($_SESSION['priceMonitor']['newFlag']) && $_SESSION['priceMonitor']['newFlag'] === true) { echo '<span class="badge badge-pill badge-light">New</span>'; } ?>
79 - 252
                            </button>
45 - 253
                        </li>
65 - 254
                    <?php
255
} ?>
119 - 256
                    <li class="nav-item d-none d-lg-block">
15 - 257
                        <button type="submit" name="submit" value="terms" class="nav-link btn">Terms of Service</button>
14 - 258
                    </li>
119 - 259
                    <li class="nav-item d-none d-lg-block">
15 - 260
                        <button type="submit" name="submit" value="privacy" class="nav-link btn">Privacy Policy</button>
14 - 261
                    </li>
57 - 262
                    <li class="nav-item">
114 - 263
                        <a href="https://blog.findcheapmusic.com" target="_blank" rel="noreferrer noopener" class="nav-link" role="button">Blog</a>
57 - 264
                    </li>
107 - 265
                    <li class="nav-item">
116 - 266
                        <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 - 267
                    </li>
14 - 268
                </ul>
35 - 269
                <ul class="navbar-nav">
270
                    <?php if (!isLoggedIn()) { ?>
271
                    <li class="nav-item">
119 - 272
                        <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 - 273
                    </li>
65 - 274
                    <?php
275
}
276
else { ?>
36 - 277
                        <li class="nav-item">
108 - 278
                            <img class="img-fluid hide-extra-small hide-small user-img" src="<?php echo timeStampUrl($userPicture); ?>" alt="User Image">
36 - 279
                        </li>
35 - 280
                        <li class="nav-item dropdown">
116 - 281
                          <a class="nav-link dropdown-toggle" href="#" id="navbardrop" data-toggle="dropdown"><i class="material-icons material-text">account_box</i> Account</a>
35 - 282
                          <div class="dropdown-menu dropdown-menu-right">
119 - 283
                              <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>
284
                              <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 - 285
                              <?php if (empty($_SESSION['sessData']['loginType']) || $_SESSION['sessData']['loginType'] != 'social') { ?>
119 - 286
                                  <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 - 287
                              <?php
288
    } ?>
119 - 289
                              <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 - 290
                          </div>
291
                        </li>
65 - 292
                    <?php
293
} ?>
35 - 294
                </ul>
14 - 295
            </div>
296
        </nav>
297
    </form>
2 - 298
 
3 - 299
    <div class="page-header bg-primary">
300
        <div class="container text-center py-3">
14 - 301
        <?php
65 - 302
if (getPGV('submit') == "terms") {
303
    echo file_get_contents('snippets/headerTerms.txt');
304
}
305
else if (getPGV('submit') == "privacy") {
306
    echo file_get_contents('snippets/headerPrivacy.txt');
307
}
308
else if (getPGV('submit') == "coupons") {
309
    echo file_get_contents('snippets/headerCoupons.txt');
310
}
311
else if (getPGV('submit') == "wishlist") {
312
    echo file_get_contents('snippets/headerWishlist.txt');
78 - 313
    if (!empty($_SESSION['priceMonitor'])) {
314
    ?>
315
    <form method="post" action="/index.php">
116 - 316
        <input type="hidden" name="sessionTab" value="<?php echo MySessionHandler::getSessionTab(); ?>" />
79 - 317
        <button id="priceMonitor" type="submit" class="btn btn-success rounded" name="submit" value="priceMonitor">Price Monitor Results
121 - 318
        <?php if (!empty($_SESSION['priceMonitor']['newFlag']) && $_SESSION['priceMonitor']['newFlag'] === true) { echo '<span class="badge badge-pill badge-dark">New</span>'; } ?>
79 - 319
        </button>
78 - 320
    </form>
321
    <?php
322
    }
65 - 323
}
78 - 324
else if (getPGV('submit') == "priceMonitor") {
325
    echo file_get_contents('snippets/headerPriceMonitor.txt');
326
}
65 - 327
else if (getPGV('submit') == "help") {
328
    echo file_get_contents('snippets/headerHelp.txt');
329
}
113 - 330
else if (getPGV('submit') == "barcode") {
331
    echo file_get_contents('snippets/headerBarcode.txt');
332
}
73 - 333
else if (getPGV('submit') == "unsubscribe") {
334
    echo file_get_contents('snippets/unsubscribeWishlist.txt');
335
}
65 - 336
else {
114 - 337
    echo '<h1>Find Cheap CDs, Records, Digital, Books and Sheets</h1>';
107 - 338
    echo '<p id="textslide" class="d-none d-sm-block">Bookmark FindCheapMusic.com</p>';
65 - 339
}
340
?>
2 - 341
        </div>
342
    </div>
343
 
3 - 344
	<div class="container-fluid bg-primary py-3">
65 - 345
        <form <?php if (in_array(getPGV('submit') , array(
346
    "terms",
347
    "privacy",
348
    "coupons",
349
    "wishlist",
78 - 350
    "priceMonitor",
73 - 351
    "help",
113 - 352
    "barcode",
73 - 353
    "unsubscribe"
354
 
65 - 355
))) {
107 - 356
    echo "hidden=\"hidden\"";
120 - 357
} ?> id="searchForm" method="post" action="/index.php" class="form-inline">
116 - 358
            <input id="sessionId" type="hidden" name="sessionId" value="<?php echo session_id(); ?>" />
359
            <input id="sessionTab" type="hidden" name="sessionTab" value="<?php echo MySessionHandler::getSessionTab(); ?>" />
119 - 360
            <div class="hidden-default-btn">
361
                <button type="submit" name="submit" value="Search">Hidden Submit Button</button>
113 - 362
            </div>
363
            <div class="form-group">
17 - 364
                <div class="btn-group">
116 - 365
                    <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 - 366
                    <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 - 367
                </div>
368
        	</div>
20 - 369
        	<div class="form-group mx-1">
116 - 370
        	    <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 - 371
        	    <datalist id="searchHistory">
372
            	    <?php echo getSearchHistory(); ?>
373
            	</datalist>
374
            </div>
375
        	<div class="form-group">
376
                <button id="searchBtn" type="submit" class="btn btn-success mx-1 rounded" name="submit" value="Search">Go</button>
377
            </div>
2 - 378
        </form>
120 - 379
<script nonce="<?php echo base64_encode($_SESSION["nonce"]); ?>">
380
document.addEventListener('DOMContentLoaded', function() {
381
	document.getElementById('searchForm').addEventListener('submit', function searchFormOnSubmit() {
382
		if(document.getElementById('searchTerm').value !== '') {
383
			progressBar('Searching for:<br><br><strong>' + document.getElementById('searchTerm').value.toLowerCase().replace(/(?:(^.{1})|\ [a-z]{1})/g, function(a) {
384
				return a.toUpperCase();
385
			}) + '</strong>');
386
			document.getElementById('searchBtn').innerHTML = '<span class=\'spinner-border spinner-border-sm\'></span> Searching, please wait...';
387
		}
388
	});
389
});
390
document.addEventListener('DOMContentLoaded', function() {
391
	document.getElementById('barcodeBtn').addEventListener('click', function() {
392
        document.getElementById('searchTerm').value = '';
393
	});
394
});
395
</script>
2 - 396
    </div>
397
 
5 - 398
    <?php
65 - 399
if (getPGV('submit') == "terms") {
120 - 400
    $snip = file_get_contents('snippets/terms.txt');
401
    $snip = str_replace("<script>", "<script nonce=\"" . base64_encode($_SESSION["nonce"]) . "\">", $snip);
402
    echo $snip;
65 - 403
}
404
else if (getPGV('submit') == "privacy") {
120 - 405
    $snip = file_get_contents('snippets/privacy.txt');
406
    $snip = str_replace("<script>", "<script nonce=\"" . base64_encode($_SESSION["nonce"]) . "\">", $snip);
407
    echo $snip;
65 - 408
}
409
else if (getPGV('submit') == "help") {
108 - 410
    include 'php/help.php';
65 - 411
}
113 - 412
else if (getPGV('submit') == "barcode") {
413
    echo '
114 - 414
<div class="container py-4 bg-light border">
113 - 415
    <div class="my-3">
416
    <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>
417
        <form id="barcodeForm">
116 - 418
    	    <input type="hidden" name="sessionTab" value="' . MySessionHandler::getSessionTab() . '" />
419
            <input type="hidden" name="searchTerm" value="' . getSV("searchTerm") . '" />
113 - 420
            <div class="input-group mb-3">
116 - 421
        	    <input id="barcode" name="barcode" type="text" class="" placeholder="Enter Barcode..." aria-label="Barcode Input" />
113 - 422
                    <div class="input-group-append">
120 - 423
                        <button id="barcodeFormVerify" type="submit" class="btn btn-success barcodeButton" name="submit" value="check">Verify</button>
424
                        <button id="barcodeFormCalc"  type="submit" class="btn btn-info barcodeButton" name="submit" value="calc">Calculate</button>
113 - 425
                    </div>
426
            </div>
427
        </form>
120 - 428
<script nonce="' . base64_encode($_SESSION["nonce"]) . '">
429
document.addEventListener("DOMContentLoaded", function() {
430
	document.getElementById("barcodeFormVerify").addEventListener("click", function() {
431
        dataLayer.push({"barcode": document.getElementById("barcode").value});
432
	});
433
	document.getElementById("barcodeFormCalc").addEventListener("click", function() {
434
        dataLayer.push({"barcode": document.getElementById("barcode").value});
435
	});
436
});
437
</script>
113 - 438
        <div id="barcodeResult"></div>
439
    </div>
440
</div>
441
';
442
}
65 - 443
else if (getPGV('submit') == "coupons") {
444
    //get_linkshareCoupons(); // bugbug
445
    echo getCouponCodes();
446
}
447
else if (getPGV('submit') == "wishlist") {
448
    echo getWishlist();
449
}
78 - 450
else if (getPGV('submit') == "priceMonitor") {
451
    echo "<div id=\"productTable\" class=\"container bg-secondary border pt-2\">";
452
    echo getPriceMonitor(); // bugbug
453
    echo "</div>";
454
}
73 - 455
else if (getPGV('submit') == "unsubscribe") {
456
    echo unsubscribeWishlist($_GET);
457
}
65 - 458
else if (getPGV('submit') == "random") {
459
    findDiscogsMaster("***RANDOM***");
119 - 460
    if (!empty($_SESSION["discogs"])) {
121 - 461
        echo str_replace("xxxNONCExxx", base64_encode($_SESSION["nonce"]), $_SESSION["discogs"]);
119 - 462
    }
65 - 463
}
464
else {
465
    if ($_SESSION["lowestPrice"]["All"] > 0.00 || !empty($_SESSION["searchTerm"])) {
121 - 466
        echo str_replace("xxxNONCExxx", base64_encode($_SESSION["nonce"]), $_SESSION["discogs"]);
104 - 467
        echo "<div id=\"productTable\" class=\"container bg-secondary border py-2\">";
107 - 468
        echo "<h2 class=\"text-center py-2\">Store Offers</h2>";
104 - 469
        if ($_SESSION["lowestPrice"]["All"] > 0.00) {
470
            echo printResultHeader();
471
        }
65 - 472
        echo printResult();
473
        echo "</div>";
474
    }
475
    else if (!empty($_SESSION["discogs"])) {
121 - 476
        echo str_replace("xxxNONCExxx", base64_encode($_SESSION["nonce"]), $_SESSION["discogs"]);
65 - 477
    }
478
    else {
479
?>
110 - 480
    <div class="container-fluid text-center mb-2">
38 - 481
    <form method="post" action="/index.php">
116 - 482
        <input type="hidden" name="sessionTab" value="<?php echo MySessionHandler::getSessionTab(); ?>" />
483
       	<input type="hidden" name="searchTerm" value="<?php echo getSV("searchTerm") ?>" />
43 - 484
        <button id="randomBtn" type="submit" class="btn btn-success mt-5 rounded" name="submit" value="random">Random Album Suggestions</button>
38 - 485
    </form>
486
    </div>
110 - 487
    <div class="container bg-secondary border py-2 mt-4">
488
    <h2 class="text-center py-2">Getting Started</h2>
116 - 489
    <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 - 490
    <hr>
108 - 491
    <?php include 'php/help.php'; ?>
110 - 492
    </div>
65 - 493
        <?php
14 - 494
    }
65 - 495
    echo printSearchInfoModal();
496
}
497
?>
2 - 498
 
14 - 499
    <div class="modal" id="progressBarDiv">
17 - 500
        <div class="modal-dialog modal-dialog-centered">
14 - 501
            <div class="modal-content">
502
                <div class="modal-header">
107 - 503
                    <p id="progressBarHeader" class="display-6">Searching</p>
14 - 504
                </div>
505
                <div class="modal-body">
506
                    <div class="progress">
119 - 507
                        <div id="progressBar" class="progress-bar">0%</div>
14 - 508
                    </div>
509
                </div>
15 - 510
                <div class="modal-footer">
511
                    <span id="progressBarMessage"></span>
512
                </div>
14 - 513
            </div>
514
        </div>
515
    </div>
516
 
120 - 517
    <button id="topBtn" title="Go to top">Top</button>
518
<script nonce="<?php echo base64_encode($_SESSION["nonce"]); ?>">
519
document.addEventListener('DOMContentLoaded', function() {
520
	document.getElementById('topBtn').addEventListener('click', function() {
521
        topFunction();
522
	});
523
});
524
</script>
81 - 525
 
64 - 526
    <footer class="container-fluid text-center bg-primary py-5">
78 - 527
        <?php if (!empty($_SESSION["searchTerm"]) || getPGV('submit') == "priceMonitor") {
114 - 528
            echo "<p>Disclaimer: As an Associate we earn from qualifying purchases.</p>";
529
        } ?>
530
        <p>
531
            <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>
532
            <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>
533
        </p>
17 - 534
        <p>Copyright &#169; <?php echo @date("Y"); ?> FindCheapMusic.com. All rights reserved.</p>
2 - 535
    </footer>
536
 
119 - 537
    <script nonce="<?php echo base64_encode($_SESSION["nonce"]); ?>">var quotes = [
38 - 538
    <?php
65 - 539
if ($file = fopen("snippets/header.txt", "r")) {
540
    while (($line = fgets($file)) !== false) {
541
        echo "\"" . trim($line) . "\",";
542
    }
543
    fclose($file);
544
}
545
?>
83 - 546
    ]; setInterval(function() { $("#textslide").html(quotes[Math.floor(Math.random() * (quotes.length + 1))]); }, 5 * 1000);
547
    </script>
114 - 548
    <?php include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/downloadAtOnload.php"); ?>
121 - 549
    <form><input type="hidden" id="nonce" name="nonce" value="<?php echo $_SESSION["nonce"]; ?>" /></form>
2 - 550
</body>
551
</html>
21 - 552
<?php MySessionHandler::commit(session_id()); ?>