Subversion Repositories cheapmusic

Rev

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

Rev Author Line No. Line
2 - 1
<?php
13 - 2
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start();
3
 
7 - 4
include_once('php/sessions_db.php');
5
include_once('php/cryptor.php');
9 - 6
include_once('php/vendors.php');
7 - 7
 
9 - 8
error_reporting(E_ALL);
9
 
2 - 10
if ($_SERVER["SERVER_NAME"] == "www.findcheapmusic.com") {
5 - 11
	header("Strict-Transport-Security: max-age=31536000; includeSubDomains; preload");
12
	header("X-Content-Type-Options: nosniff");
13
	header("X-XSS-Protection: 1; mode=block");
14
	header("Access-Control-Allow-Origin: *");
15
	header("Referrer-Policy: no-referrer");
16
	header("X-Frame-Options: SAMEORIGIN");
17
	header("Set-Cookie: ^(.*)$ $1;HttpOnly;Secure");
10 - 18
	header("Content-Security-Policy: default-src 'none'; font-src https://use.fontawesome.com; form-action 'self'; img-src 'self' data: https://img.discogs.com https://thumbs1.ebaystatic.com https://thumbs2.ebaystatic.com https://thumbs3.ebaystatic.com https://thumbs4.ebaystatic.com; script-src 'self' 'unsafe-inline' https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js; style-src 'self' 'unsafe-inline' https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/ https://use.fontawesome.com/releases/v5.8.1/css/;frame-ancestors 'self'");
2 - 19
}
20
 
7 - 21
$configFile = parse_ini_file("../MyFiles/config/cheapmusic.ini",true);
22
$crypt = Cryptor::getInstance($configFile['cryptor']);
23
$tmpSessionTab = (isset($_POST["sessionTab"]) && $_POST["sessionTab"] > 0 ? $_POST["sessionTab"] : null);
24
$handler = MySessionHandler::getInstance($tmpSessionTab, $configFile['mysqli']);
9 - 25
$vendors = Vendors::getInstance();
26
$vendors->setVendor($configFile['ebay'], Vendors::EBAY);
27
$vendors->setVendor($configFile['discogs'], Vendors::DISCOGS);
7 - 28
unset($configFile);
29
 
2 - 30
ini_set("session.cookie_httponly", 1);
31
ini_set("session.cookie_secure", 1);
7 - 32
session_set_save_handler($handler, true);
2 - 33
session_start();
34
?>
35
<!DOCTYPE html>
36
<html lang="en-US">
37
<head>
38
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
39
    <title>Find Cheap Music...</title>
40
    <meta name="viewport" content="width=device-width, initial-scale=1">
41
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
42
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js" integrity="sha384-JUMjoW8OzDJw4oFpWIB2Bu/c6768ObEthBMVSiIx4ruBIEdyNSUQAjJNFqT5pnJ6" crossorigin="anonymous"></script>
43
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
44
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
6 - 45
    <link rel="stylesheet" href="css/style.min.css" integrity="sha384-zfDdfwK/GMKsN/HIVw5QfYNpAuPYAhtEwYs/IFiDiboUBjXRjHpjPt1gdNtJgAWA" crossorigin="anonymous">
3 - 46
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
2 - 47
    <!-- Global site tag (gtag.js) - Google Analytics -->
48
    <!--script async src="https://www.googletagmanager.com/gtag/js?id=UA-138428761-2"></script-->
49
    <!--script src="/js/gtag.js" integrity="sha384-ZoAmOe9K3AXr6ONEK6njtE/HMsMvyjck9EfsgXdZLG7rEiz5GqXEk3RQc2cFIRNY" crossorigin="anonymous"></script-->
50
</head>
51
<body>
52
 
53
<?php
54
include_once('php/tools.php');
55
 
5 - 56
initSessionVariables();
2 - 57
 
58
if ($_SERVER["REQUEST_METHOD"] == "POST") {
5 - 59
	if ($_POST["submit"] == "Search") {
60
		$zip = sanitizeInput($_POST['buyerZip']);
61
		if (strlen($zip) == 5 && preg_match("/^[0-9 ]*$/", $zip)) {
62
			$_SESSION["buyer"]["Zip"] = $zip;
63
		} else if (strlen($zip) == 0) {
64
			$_SESSION["buyer"]["Zip"] = "";
65
		}
2 - 66
 
9 - 67
		$searchTerm = sanitizeInput($_POST['searchTerm']);
68
		if (empty($searchTerm)) {
69
			resetSessionVars();
5 - 70
		} else {
9 - 71
			$_SESSION["searchTerm"] = $searchTerm;
2 - 72
 
5 - 73
            if (checkSearchFilters()) {
74
    			performSearch();
75
    		}
76
		}
77
	} else if ($_POST["submit"] == "Save") {
78
		$_SESSION["filterCondition"]["New"] = checkPV("filterConditionNew");
79
		$_SESSION["filterCondition"]["Used"] = checkPV("filterConditionUsed");
80
		$_SESSION["filterMediaType"]["CD"] = checkPV("filterMediaTypeCD");
81
		$_SESSION["filterMediaType"]["Record"] = checkPV("filterMediaTypeRecord");
82
		$_SESSION["filterMediaType"]["Digital"] = checkPV("filterMediaTypeDigital");
2 - 83
 
5 - 84
        if (checkSearchFilters()) {
85
			performSearch();
86
		}
87
	} else if (in_array($_POST["submit"], $buttonArr)) {
88
		$_SESSION["currentView"] = $_POST["submit"];
89
		filterResults();
90
	}
91
} else if ($_SERVER["REQUEST_METHOD"] == "GET") {
92
	if (isset($_GET['z'])) {
9 - 93
    	$_SESSION["buyer"]["Zip"] = "";
5 - 94
		$zip = sanitizeInput($_GET['z']);
95
		if (strlen($zip) == 5 && preg_match("/^[0-9 ]*$/", $zip)) {
96
			$_SESSION["buyer"]["Zip"] = $zip;
97
		}
98
	}
2 - 99
 
9 - 100
    $_SESSION["searchTerm"] = "";
5 - 101
	if (isset($_GET['q'])) {
102
		$_SESSION["searchTerm"] = sanitizeInput($_GET["q"]);
103
        if (checkSearchFilters()) {
104
    		performSearch();
105
    	}
106
	}
2 - 107
}
108
?>
109
 
110
    <nav class="navbar navbar-expand-sm bg-dark navbar-dark">
111
        <a class="navbar-brand" href="#">Home</a>
112
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
113
            <span class="navbar-toggler-icon"></span>
114
        </button>
115
        <div class="collapse navbar-collapse" id="collapsibleNavbar">
116
            <ul class="navbar-nav">
117
                <li class="nav-item">
9 - 118
                    <a class="nav-link" href="terms.php">Terms of Service</a>
2 - 119
                </li>
120
                <li class="nav-item">
9 - 121
                    <a class="nav-link" href="privacy.php">Privacy Policy</a>
2 - 122
                </li>
123
            </ul>
124
        </div>
125
    </nav>
126
 
3 - 127
    <div class="page-header bg-primary">
128
        <div class="container text-center py-3">
2 - 129
            <h1>Find Cheap Music...</h1>
4 - 130
            <p class="d-none d-sm-block">Find the cheapest music online. Advertisement free website.</p>
2 - 131
        </div>
132
    </div>
133
 
3 - 134
	<div class="container-fluid bg-primary py-3">
5 - 135
        <?php
136
            echo $_SESSION["filterWarnings"];
137
        ?>
2 - 138
        <form method="post" action="/index.php"
139
            onsubmit="document.getElementById('search').innerHTML = '&lt;span class=\'spinner-border spinner-border-sm\'&gt;&lt;/span&gt; Searching, please wait...';">
11 - 140
            <input id="sessionTab" type="hidden" name="sessionTab" value="<?php echo $handler->getSessionTab(); ?>">
2 - 141
        	<div class="input-group mb-3">
142
            	<div class="input-group-prepend">
4 - 143
                    <div class="d-none d-sm-block">
144
                        <button class="btn input-group-text mx-1 rounded" type="button" data-toggle="modal" data-target="#searchInfoModal"><i class="fas fa-info-circle" style="font-size:25px"></i></button>
145
                	</div>
146
                	<button class="btn input-group-text mx-1 rounded" type="button" data-toggle="modal" data-target="#filterModal" data-keyboard="false"><i class="fas fa-filter" style='font-size:25px'></i></button>
2 - 147
            	</div>
5 - 148
            	<input id="searchTerm" name="searchTerm" type="text" class="form-control ml-1" placeholder="Search by Barcode, Label, Artist, Title, ..." value="<?php echo getSV("searchTerm") ?>">
2 - 149
            	<div class="input-group-append">
150
                    <button id="search" type="submit" class="btn btn-success" name="submit" value="Search">Go</button>
151
                </div>
152
        	</div>
4 - 153
        	<div class="input-group input-group-sm mb-3 col-xl-5 col-lg-7 col-md-12 col-sm-12 col-12">
2 - 154
            	<div class="input-group-prepend input-group-sm">
4 - 155
          			<!--span class="input-group-text mx-1">Shipping to:</span-->
156
          			<label class="mr-2">Shipping to:</label>
2 - 157
            	</div>
4 - 158
                <div class="d-none d-sm-inline-flex">
159
              		<input type="text" class="form-control form-control-sm mx-1" maxlength="20" style="width:12em!important" id="buyerCountry" name="buyerCountry" value="United States" readonly>
160
                    <input type="text" class="form-control form-control-sm mx-1" maxlength="3" style="width:3.5em!important" id="buyerCurrency" name="buyerCurrency" value="USD" readonly>
161
                </div>
5 - 162
            	<input type="text" class="form-control form-control-sm mx-1" maxlength="5" style="width:2.5em!important" id="buyerZip" name="buyerZip" placeholder="Zip Code" value="<?php echo $_SESSION["buyer"]["Zip"];?>">
2 - 163
	            <?php
5 - 164
                    if ($_SESSION["buyer"]["Zip"] == '') {
4 - 165
                    	echo '<div class="input-group-append input-group-sm mx-1 rounded">';
5 - 166
                    	echo '  <i class="fas fa-exclamation-triangle input-group-text img-fluid rounded" style="font-size:14px;color:orange;" title="Please enter your postal code to get the accurate shipping cost for items listed using a shipping rate table." data-toggle="tooltip" data-placement="auto" data-delay="100"></i>';
167
                    	echo '</div>';
168
                    }
2 - 169
                ?>
170
        	</div>
171
        </form>
172
    </div>
173
 
5 - 174
    <?php
9 - 175
        if ($_SESSION["lowestPrice"]["All"] > 0.00 || !empty($_SESSION["searchTerm"])) {
12 - 176
            echo $_SESSION["discogs"];
11 - 177
	        echo "<div id=\"productTable\">";
9 - 178
            echo printTableHeader();
179
            echo buildTable();
11 - 180
            echo "</div>";
9 - 181
        }
5 - 182
        echo printSearchFilterModal();
183
        echo printSearchInfoModal();
184
    ?>
2 - 185
 
186
    <footer class="container-fluid text-center">
187
        <p>Disclaimer: As an Associate we earn from qualifying purchases.</p>
9 - 188
        <p>Copyright &#169; <?php echo date("Y"); ?> FindCheapMusic.com. All rights reserved.</p>
2 - 189
    </footer>
190
 
11 - 191
    <script src="/js/dr.min.js" integrity="sha384-dxd4PdwnWxgxHO8a50F7CizVhl9/GaPSQHyOtYUzpZYBvTgiWLRLj6rQYc/w1vNF" crossorigin="anonymous"></script>
2 - 192
</body>
193
</html>