Subversion Repositories cheapmusic

Rev

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

Rev Author Line No. Line
2 - 1
<?php
25 - 2
include_once($_SERVER['DOCUMENT_ROOT'] . "/php/dnsexit.php");
3
include_once($_SERVER['DOCUMENT_ROOT'] . "/php/sessions_db.php");
4
include_once($_SERVER['DOCUMENT_ROOT'] . "/php/cryptor.php");
5
include_once($_SERVER['DOCUMENT_ROOT'] . "/php/vendors.php");
7 - 6
 
9 - 7
error_reporting(E_ALL);
8
 
25 - 9
$configFile = parse_ini_file($_SERVER['DOCUMENT_ROOT'] . "/../MyFiles/config/cheapmusic.ini", true);
7 - 10
$crypt = Cryptor::getInstance($configFile['cryptor']);
11
$tmpSessionTab = (isset($_POST["sessionTab"]) && $_POST["sessionTab"] > 0 ? $_POST["sessionTab"] : null);
12
$handler = MySessionHandler::getInstance($tmpSessionTab, $configFile['mysqli']);
9 - 13
$vendors = Vendors::getInstance();
14
$vendors->setVendor($configFile['ebay'], Vendors::EBAY);
15
$vendors->setVendor($configFile['discogs'], Vendors::DISCOGS);
20 - 16
$vendors->setVendor($configFile['linkshare'], Vendors::LINKSHARE);
17
$vendors->setVendor($configFile['cjaffiliate'], Vendors::CJAFFILIATE);
18
$vendors->setVendor($configFile['walmart'], Vendors::WALMART);
7 - 19
unset($configFile);
20
 
2 - 21
ini_set("session.cookie_httponly", 1);
22
ini_set("session.cookie_secure", 1);
7 - 23
session_set_save_handler($handler, true);
2 - 24
session_start();
25
?>
26
<!DOCTYPE html>
27
<html lang="en-US">
28
<head>
29
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
30
    <title>Find Cheap Music...</title>
31
    <meta name="viewport" content="width=device-width, initial-scale=1">
32
    <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">
33
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js" integrity="sha384-JUMjoW8OzDJw4oFpWIB2Bu/c6768ObEthBMVSiIx4ruBIEdyNSUQAjJNFqT5pnJ6" crossorigin="anonymous"></script>
34
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
35
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
20 - 36
    <link rel="stylesheet" href="css/style.min.css" integrity="sha384-3yKV1/hu3r+JRZhPoSpsl8ZvOD/xIGd09X1/yNjTBUJEGhl0ALKqZCoznZGgPaDC" crossorigin="anonymous">
3 - 37
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
17 - 38
    <link rel="stylesheet" href="css/jquery.flexdatalist.min.css" integrity="sha384-IUkltzhO8hiEuEm0UJQvWrrtE1xqVHA0NbUeIY7a+zCokg7LqiDf5HSt69ru8a7R" crossorigin="anonymous">
39
    <script src="js/jquery.flexdatalist.min.js" integrity="sha384-JKZ5fd3wxuyCR/AhbpbYALE2xwlYMGYu0XpsXixX7YOni1G0is+vwTuSMuGGYhnl" crossorigin="anonymous"></script>
20 - 40
    <script src="js/input-clearer.min.js" integrity="sha384-PPIpFAWvzKO0l06o6zNV8tPFHNistosIDKHylKx5kJIM9zceSlJxAScUWQpt02xy" crossorigin="anonymous"></script>
2 - 41
    <!-- Global site tag (gtag.js) - Google Analytics -->
42
    <!--script async src="https://www.googletagmanager.com/gtag/js?id=UA-138428761-2"></script-->
43
    <!--script src="/js/gtag.js" integrity="sha384-ZoAmOe9K3AXr6ONEK6njtE/HMsMvyjck9EfsgXdZLG7rEiz5GqXEk3RQc2cFIRNY" crossorigin="anonymous"></script-->
44
</head>
45
<body>
46
 
47
<?php
48
include_once('php/tools.php');
49
 
5 - 50
initSessionVariables();
2 - 51
 
52
if ($_SERVER["REQUEST_METHOD"] == "POST") {
5 - 53
	if ($_POST["submit"] == "Search") {
54
		$zip = sanitizeInput($_POST['buyerZip']);
55
		if (strlen($zip) == 5 && preg_match("/^[0-9 ]*$/", $zip)) {
56
			$_SESSION["buyer"]["Zip"] = $zip;
57
		} else if (strlen($zip) == 0) {
58
			$_SESSION["buyer"]["Zip"] = "";
59
		}
2 - 60
 
14 - 61
		$searchTerm = searchFriendlyString($_POST['searchTerm']);
9 - 62
		if (empty($searchTerm)) {
63
			resetSessionVars();
5 - 64
		} else {
9 - 65
			$_SESSION["searchTerm"] = $searchTerm;
2 - 66
 
5 - 67
            if (checkSearchFilters()) {
68
    			performSearch();
69
    		}
70
		}
71
	} else if ($_POST["submit"] == "Save") {
72
		$_SESSION["filterCondition"]["New"] = checkPV("filterConditionNew");
73
		$_SESSION["filterCondition"]["Used"] = checkPV("filterConditionUsed");
74
		$_SESSION["filterMediaType"]["CD"] = checkPV("filterMediaTypeCD");
75
		$_SESSION["filterMediaType"]["Record"] = checkPV("filterMediaTypeRecord");
76
		$_SESSION["filterMediaType"]["Digital"] = checkPV("filterMediaTypeDigital");
20 - 77
		$_SESSION["filterMediaType"]["Book"] = checkPV("filterMediaTypeBook");
2 - 78
 
27 - 79
		$searchTerm = searchFriendlyString($_POST['searchTerm']);
80
		if (empty($searchTerm)) {
81
			resetSessionVars();
82
		} else {
83
			$_SESSION["searchTerm"] = $searchTerm;
84
 
85
            if (checkSearchFilters()) {
86
    			performSearch();
87
    		}
5 - 88
		}
14 - 89
	} else if ($_POST["submit"] == "discogsSearch") {
90
		$searchTerm = searchFriendlyString($_POST['discogsSearchTerm']);
91
		if (empty($searchTerm)) {
92
			resetSessionVars();
93
		} else {
94
			$_SESSION["searchTerm"] = $searchTerm;
95
 
96
            if (checkSearchFilters()) {
97
    			performSearch();
98
    		}
99
		}
5 - 100
	} else if (in_array($_POST["submit"], $buttonArr)) {
101
		$_SESSION["currentView"] = $_POST["submit"];
102
		filterResults();
103
	}
104
} else if ($_SERVER["REQUEST_METHOD"] == "GET") {
105
	if (isset($_GET['z'])) {
9 - 106
    	$_SESSION["buyer"]["Zip"] = "";
5 - 107
		$zip = sanitizeInput($_GET['z']);
108
		if (strlen($zip) == 5 && preg_match("/^[0-9 ]*$/", $zip)) {
109
			$_SESSION["buyer"]["Zip"] = $zip;
110
		}
111
	}
2 - 112
 
9 - 113
    $_SESSION["searchTerm"] = "";
5 - 114
	if (isset($_GET['q'])) {
14 - 115
		$_SESSION["searchTerm"] = searchFriendlyString($_GET["q"]);
5 - 116
        if (checkSearchFilters()) {
117
    		performSearch();
118
    	}
119
	}
2 - 120
}
20 - 121
 
2 - 122
?>
123
 
14 - 124
    <form method="post" action="/index.php">
20 - 125
        <input type="hidden" name="sessionTab" value="<?php echo MySessionHandler::getSessionTab(); ?>">
14 - 126
       	<input type="hidden" name="searchTerm" value="<?php echo getSV("searchTerm") ?>">
127
       	<input type="hidden" name="buyerZip" value="<?php echo $_SESSION["buyer"]["Zip"];?>">
128
        <nav class="navbar navbar-expand-sm bg-dark navbar-dark">
129
            <button type="submit" name="submit" value="Search" class="navbar-brand btn">Home</button>
130
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
131
                <span class="navbar-toggler-icon"></span>
132
            </button>
133
            <div class="collapse navbar-collapse" id="collapsibleNavbar">
134
                <ul class="navbar-nav">
135
                    <li class="nav-item">
15 - 136
                        <button type="submit" name="submit" value="terms" class="nav-link btn">Terms of Service</button>
14 - 137
                    </li>
138
                    <li class="nav-item">
15 - 139
                        <button type="submit" name="submit" value="privacy" class="nav-link btn">Privacy Policy</button>
14 - 140
                    </li>
141
                </ul>
142
            </div>
143
        </nav>
144
    </form>
2 - 145
 
3 - 146
    <div class="page-header bg-primary">
147
        <div class="container text-center py-3">
14 - 148
        <?php
20 - 149
            if (getPGV('submit') == "terms") {
14 - 150
                echo file_get_contents('snippets/headerTerms.txt');
20 - 151
            } else if (getPGV('submit') == "privacy") {
14 - 152
                echo file_get_contents('snippets/headerPrivacy.txt');
153
            } else {
154
                echo file_get_contents('snippets/header.txt');
155
            }
156
        ?>
2 - 157
        </div>
158
    </div>
159
 
3 - 160
	<div class="container-fluid bg-primary py-3">
5 - 161
        <?php
20 - 162
        if (!in_array(getPGV('submit'), array("terms", "privacy"))) {
5 - 163
            echo $_SESSION["filterWarnings"];
14 - 164
        }
5 - 165
        ?>
20 - 166
        <form <?php if (in_array(getPGV('submit'), array("terms", "privacy"))) {echo "hidden";} ?> method="post" action="/index.php" class="form-inline"
15 - 167
            onsubmit="progressBar('Searching for ' + document.getElementById('searchTerm').value);document.getElementById('searchBtn').innerHTML = '&lt;span class=\'spinner-border spinner-border-sm\'&gt;&lt;/span&gt; Searching, please wait...';">
168
            <input id="sessionId" type="hidden" name="sessionId" value="<?php echo session_id(); ?>">
20 - 169
            <input id="sessionTab" type="hidden" name="sessionTab" value="<?php echo MySessionHandler::getSessionTab(); ?>">
17 - 170
        	<div class="form-group">
171
                <div class="btn-group">
172
                    <button class="btn input-group-text mx-1 rounded" type="button" data-toggle="modal" data-target="#searchInfoModal" data-toggle2="tooltip" title="Search Tips"><i class="fas fa-info-circle" style="font-size:25px"></i></button>
173
                    <button class="btn input-group-text mx-1 rounded" type="button" data-toggle="modal" data-target="#filterModal" data-keyboard="false" data-toggle2="tooltip" title="Search Filter"><i class="fas fa-filter" style='font-size:25px'></i></button>
174
                    <div class="btn-group">
175
                        <button class="btn dropdown-toggle <?php echo ($_SESSION["buyer"]["Zip"] == '' ? "bg-warning" : "input-group-text"); ?> mx-1 rounded" type="button" data-toggle="dropdown" data-toggle2="tooltip" title="<?php echo ($_SESSION["buyer"]["Zip"] == '' ? "Please enter your postal code to get the accurate shipping cost for items listed using a shipping rate table." : "Shipping to"); ?>"><i class="fas fa-shipping-fast" style='font-size:25px'></i></button>
176
                        <div class="dropdown-menu">
177
                            <div class="form-inline">
178
                                <label class="m-2">Shipping to:</label>
179
                                <input type="text" class="form-control form-control-sm m-2" maxlength="20" style="width:12em!important" id="buyerCountry" name="buyerCountry" value="United States" readonly>
180
                                <input type="text" class="form-control form-control-sm m-2" maxlength="3" style="width:3.5em!important" id="buyerCurrency" name="buyerCurrency" value="USD" readonly>
181
                                <input type="text" class="form-control form-control-sm m-2" maxlength="5" style="width:5.5em!important" id="buyerZip" name="buyerZip" placeholder="Zip Code" value="<?php echo $_SESSION["buyer"]["Zip"];?>">
182
                            </div>
183
                        </div>
184
                    </div>
2 - 185
                </div>
186
        	</div>
20 - 187
        	<div class="form-group mx-1">
188
        	    <input id="searchTerm" list="searchHistory" name="searchTerm" type="text" class="form-control flexdatalist searchTerm-width" placeholder="Search by Barcode, Artist, Title, ..." value="<?php echo getSV("searchTerm") ?>">
17 - 189
        	    <datalist id="searchHistory">
190
            	    <?php echo getSearchHistory(); ?>
191
            	</datalist>
192
            </div>
193
        	<div class="form-group">
194
                <button id="searchBtn" type="submit" class="btn btn-success mx-1 rounded" name="submit" value="Search">Go</button>
195
            </div>
2 - 196
        </form>
197
    </div>
198
 
5 - 199
    <?php
20 - 200
    if (getPGV('submit') == "terms") {
14 - 201
        echo file_get_contents('snippets/terms.txt');
20 - 202
    } else if (getPGV('submit') == "privacy") {
14 - 203
        echo file_get_contents('snippets/privacy.txt');
204
    } else {
9 - 205
        if ($_SESSION["lowestPrice"]["All"] > 0.00 || !empty($_SESSION["searchTerm"])) {
12 - 206
            echo $_SESSION["discogs"];
11 - 207
	        echo "<div id=\"productTable\">";
9 - 208
            echo printTableHeader();
209
            echo buildTable();
11 - 210
            echo "</div>";
9 - 211
        }
5 - 212
        echo printSearchFilterModal();
213
        echo printSearchInfoModal();
14 - 214
    }
5 - 215
    ?>
2 - 216
 
14 - 217
    <div class="modal" id="progressBarDiv">
17 - 218
        <div class="modal-dialog modal-dialog-centered">
14 - 219
            <div class="modal-content">
220
                <div class="modal-header">
15 - 221
                    <h4 id="progressBarHeader">Searching</h4>
14 - 222
                </div>
223
                <div class="modal-body">
224
                    <div class="progress">
225
                        <div id="progressBar" class="progress-bar" style="width:0%">0%</div>
226
                    </div>
227
                </div>
15 - 228
                <div class="modal-footer">
229
                    <span id="progressBarMessage"></span>
230
                </div>
14 - 231
            </div>
232
        </div>
233
    </div>
234
 
2 - 235
    <footer class="container-fluid text-center">
20 - 236
        <?php if (!empty($_SESSION["searchTerm"])) {
237
            echo "<p>Disclaimer: As an Associate we earn from qualifying purchases.</p>";
238
        }
239
        ?>
240
        <form method="post" action="/index.php">
241
            <input type="hidden" name="sessionTab" value="<?php echo MySessionHandler::getSessionTab(); ?>">
242
       	    <input type="hidden" name="searchTerm" value="<?php echo getSV("searchTerm") ?>">
243
           	<input type="hidden" name="buyerZip" value="<?php echo $_SESSION["buyer"]["Zip"];?>">
244
            <ul class="list-inline text-center">
245
                <li class="list-inline-item">
246
                    <button class="btn btn-sm bg-light" type="submit" name="submit" value="terms">Terms of Service</button>
247
                </li>
248
                <li class="list-inline-item">
249
                    <button class="btn btn-sm bg-light" type="submit" name="submit" value="privacy">Privacy Policy</button>
250
                </li>
251
            </ul>
252
        </form>
17 - 253
        <p>Copyright &#169; <?php echo @date("Y"); ?> FindCheapMusic.com. All rights reserved.</p>
2 - 254
    </footer>
255
 
28 - 256
    <script src="/js/dr.min.js" integrity="sha384-6b/qg037L3Pi1Zf0NJdqziqzUHz7OzA2FHa9zzmlX6hhC6LWfKtw/hDzHgLC65aV" crossorigin="anonymous"></script>
20 - 257
 
2 - 258
</body>
259
</html>
21 - 260
<?php MySessionHandler::commit(session_id()); ?>