Subversion Repositories cheapmusic

Rev

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

Rev Author Line No. Line
2 - 1
<?php
121 - 2
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/hosting.php");
65 - 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");
6
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/tools.php");
7
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/wishlist.php");
119 - 8
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/NonceUtil.php");
7 - 9
 
9 - 10
error_reporting(E_ALL);
11
 
35 - 12
$userData = [];
70 - 13
$configFile = parse_ini_file($_SERVER['DOCUMENT_ROOT'] . FCM_CONFIGFILE, true);
7 - 14
$crypt = Cryptor::getInstance($configFile['cryptor']);
107 - 15
$tmpSessionTab = (!empty(getPGV("sessionTab")) && getPGV("sessionTab") > 0 ? getPGV("sessionTab"): null);
7 - 16
$handler = MySessionHandler::getInstance($tmpSessionTab, $configFile['mysqli']);
9 - 17
$vendors = Vendors::getInstance();
83 - 18
Vendors::setAllVendors($configFile, $vendors);
121 - 19
$systemConf = $configFile['system'];
7 - 20
unset($configFile);
21
 
121 - 22
session_set_cookie_params(604800, '/', '.' . $systemConf["domain_name"], true, true);
7 - 23
session_set_save_handler($handler, true);
35 - 24
if (!empty($_COOKIE['PHPSESSID'])) {
25
    session_id($_COOKIE['PHPSESSID']);
26
}
2 - 27
session_start();
35 - 28
 
138 - 29
initSessionVariables($systemConf);
30
 
119 - 31
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/csp.php");
32
 
35 - 33
// Check whether user ID is available in cookie
65 - 34
if (!empty($_COOKIE['rememberUserId']) && !empty($_COOKIE['hash']) && empty($_SESSION['sessData']['loginType'])) {
35 - 35
    require_once 'login/includes/config.php';
36
    require_once 'login/includes/User.class.php';
37
    require_once 'login/includes/password.php';
38
    $user = new User();
39
    $conditions['where'] = array(
40
        'id' => $_COOKIE['rememberUserId']
41
    );
42
    $conditions['return_type'] = 'single';
43
    $userData = $user->getRows($conditions);
44
    if (!empty($userData) && password_verify($userData['password'] . $userData['id'], $_COOKIE['hash'])) {
65 - 45
        $_SESSION['sessData']['userLoggedIn'] = true;
35 - 46
        $_SESSION['sessData']['userID'] = $_COOKIE['rememberUserId'];
141 - 47
        $_SESSION["userPicture"] = getUserImage($userData);
48
        $_SESSION["colorTheme"] = $userData['theme'];
59 - 49
        $_SESSION["currentLayout"] = ($userData['cardView'] == '1' ? 'CardView' : 'TableView');
137 - 50
        $_SESSION['buyer']['Zip'] = $userData['zip'];
51
        $_SESSION['buyer']['Country'] = 'United States';
52
        $_SESSION['buyer']['Currency'] = 'USD';
53
        $_SESSION["filterCondition"]["New"] = $userData['conditionNew'];
54
        $_SESSION["filterCondition"]["Used"] = $userData['conditionUsed'];
55
        $_SESSION["filterMediaType"]["CD"] = $userData['mediaCD'];
56
        $_SESSION["filterMediaType"]["Record"] = $userData['mediaRecord'];
57
        $_SESSION["filterMediaType"]["Digital"] = $userData['mediaDigital'];
58
        $_SESSION["filterMediaType"]["Book"] = $userData['mediaBook'];
65 - 59
    }
60
    else {
35 - 61
        unsetSessData();
62
    }
137 - 63
// or if the user has already logged in
64
} else if (isLoggedIn()) {
35 - 65
    require_once 'login/includes/config.php';
66
    require_once 'login/includes/User.class.php';
67
    require_once 'login/includes/password.php';
68
    $user = new User();
69
    $conditions['where'] = array(
70
        'id' => $_SESSION['sessData']['userID']
71
    );
72
    $conditions['return_type'] = 'single';
73
    $userData = $user->getRows($conditions);
57 - 74
 
35 - 75
    if (!empty($userData)) {
141 - 76
        $_SESSION["userPicture"] = getUserImage($userData);
77
        $_SESSION["colorTheme"] = $userData['theme'];
59 - 78
        $_SESSION["currentLayout"] = ($userData['cardView'] == '1' ? 'CardView' : 'TableView');
137 - 79
        $_SESSION['buyer']['Zip'] = $userData['zip'];
80
        $_SESSION['buyer']['Country'] = 'United States';
81
        $_SESSION['buyer']['Currency'] = 'USD';
82
        $_SESSION["filterCondition"]["New"] = $userData['conditionNew'];
83
        $_SESSION["filterCondition"]["Used"] = $userData['conditionUsed'];
84
        $_SESSION["filterMediaType"]["CD"] = $userData['mediaCD'];
85
        $_SESSION["filterMediaType"]["Record"] = $userData['mediaRecord'];
86
        $_SESSION["filterMediaType"]["Digital"] = $userData['mediaDigital'];
87
        $_SESSION["filterMediaType"]["Book"] = $userData['mediaBook'];
65 - 88
    }
89
    else {
35 - 90
        unsetSessData();
91
    }
137 - 92
// or user is not logged in
138 - 93
} else {
35 - 94
    unsetSessData();
141 - 95
    $_SESSION["colorTheme"] = 'default';
35 - 96
}
57 - 97
 
78 - 98
checkPriceMonitor();
114 - 99
 
127 - 100
echo "<!DOCTYPE html>"; // html5
2 - 101
 
127 - 102
$xh = new Html;
103
$xh->init($_SESSION["htmlIndent"]);
104
$xh->add_attribute("lang", "en-US");
105
$xh->tag('html');
106
$xh->tag('head');
134 - 107
    $xh->insert_code(headTitle(getPGV('submitBtn')));
127 - 108
    $xh->add_attribute('name', "keywords");
109
    $xh->add_attribute('content', "Cheap,Music,Album,Single,Promo,CD,Compact Disc,Vinyl,Record,Digital,Download,Sheet,Book");
110
    $xh->single_tag('meta');
134 - 111
    $xh->insert_code(metaDescription(getPGV('submitBtn')));
127 - 112
    $xh->insert_code(htmlHeader());
113
    $xh->insert_code(file_get_contents('snippets/fb_tw.txt'));
143 - 114
    if (!empty($_SESSION["gtmId"])) {
115
        $xh->add_attribute('nonce', base64_encode($_SESSION["nonce"]));
116
        $xh->tag('style');
117
           $xh->insert_code(".gtm-noscript{display:none;visibility:hidden;}");
118
        $xh->close(); // style
119
    }
127 - 120
    $xh->close(); // head
121
$xh->tag('body');
122
 
134 - 123
if (!empty($_SESSION["gtmId"])) {
143 - 124
    //$xh->add_attribute('nonce', base64_encode($_SESSION["nonce"]));
127 - 125
    $xh->tag('noscript');
134 - 126
        $xh->add_attribute("src", "https://www.googletagmanager.com/ns.html?id=" . $_SESSION["gtmId"]);
127 - 127
        $xh->add_attribute("height", "0");
128
        $xh->add_attribute("width", "0");
138 - 129
        $xh->add_attribute("class", "gtm-noscript");
127 - 130
        $xh->add_attribute("title", "Tagmanager");
131
        $xh->tag('iframe', "");
132
    $xh->close(); // noscript
119 - 133
}
134
 
2 - 135
if ($_SERVER["REQUEST_METHOD"] == "POST") {
134 - 136
    if ($_POST["submitBtn"] == "Search") {
137 - 137
        buildDiscogsSearchTerm();
2 - 138
 
137 - 139
        if (!empty($_SESSION["searchTerm"])) {
138 - 140
            $_SESSION["mode"] = SIMPLE_SEARCH;
116 - 141
            performSearch();
141 - 142
            $xh->insert_code(jumpToSection("discogsTable"));
65 - 143
        }
137 - 144
    } else if ($_POST["submitBtn"] == "advSearch") {
145
        buildDiscogsSearchTerm();
146
        if (!empty($_SESSION["advSearch"])) {
138 - 147
            $_SESSION["mode"] = ADVANCED_SEARCH;
116 - 148
            performSearch();
141 - 149
            $xh->insert_code(jumpToSection("discogsTable"));
65 - 150
        }
137 - 151
    } else if ($_POST["submitBtn"] == "discogsSearch") {
152
        buildDiscogsSearchTerm();
153
        if (!empty($_SESSION["searchTerm"])) {
141 - 154
            $_SESSION["mode"] = ADVANCED_SEARCH;
155
            performSearch(true);
156
            $xh->insert_code(jumpToSection("productTable"));
65 - 157
        }
137 - 158
    } else if ($_POST["submitBtn"] == "unsubscribe") {
73 - 159
// bugbug
160
    }
65 - 161
}
162
else if ($_SERVER["REQUEST_METHOD"] == "GET") {
151 - 163
    $_GET["submitBtn"] = $_GET["submit"] ?? "";
137 - 164
    buildDiscogsSearchTerm();
165
    if (!empty($_SESSION["searchTerm"])) {
138 - 166
/*
167
        $xh->insert_code(printProgessbarModal());
168
        $xh->add_attribute('nonce', base64_encode($_SESSION["nonce"]));
169
        $xh->tag('script');
170
        $str = 'progressBar(' . $_SESSION["searchTerm"] . ');';
171
        $xh->insert_code($str);
172
        $xh->flush();
173
        $xh->close();  // script
174
*/
116 - 175
        performSearch();
65 - 176
    }
2 - 177
}
178
 
141 - 179
$xh->insert_code(navigationPane());
127 - 180
 
181
    $xh->add_attribute("class", "page-header bg-primary");
182
    $xh->tag('div');
183
        $xh->add_attribute("class", "container text-center py-3");
184
        $xh->tag('div');
185
 
134 - 186
if (getPGV('submitBtn') == "terms") {
127 - 187
    $xh->tag('h1', "Terms of Service");
137 - 188
} else if (getPGV('submitBtn') == "privacy") {
127 - 189
    $xh->tag('h1', "Privacy Policy");
137 - 190
} else if (getPGV('submitBtn') == "coupons") {
127 - 191
    $xh->tag('h1', "Special Offers &amp; Coupon Codes");
137 - 192
} else if (getPGV('submitBtn') == "wishlist") {
127 - 193
    $xh->tag('h1', "Wishlist");
78 - 194
    if (!empty($_SESSION['priceMonitor'])) {
127 - 195
        $xh->add_attribute("method", "post");
196
        $xh->add_attribute("action", "/index.php");
197
        $xh->tag('form');
198
            $xh->insert_code(inputSessionTab());
199
            $xh->insert_code(inputNonce());
200
            $xh->add_attribute("class", "btn btn-info rounded");
201
            $xh->add_attribute("id", "priceMonitor");
202
            $xh->add_attribute("type", "submit");
134 - 203
            $xh->add_attribute("name", "submitBtn");
127 - 204
            $xh->add_attribute("value", "priceMonitor");
205
            $xh->tag('button', "Price Monitor Results");
206
            if (!empty($_SESSION['priceMonitor']['newFlag']) && $_SESSION['priceMonitor']['newFlag'] === true) {
207
                $xh->add_attribute("class", "badge badge-pill badge-dark");
134 - 208
                 $xh->tag('span', "New");
127 - 209
            }
210
        $xh->close(); // form
78 - 211
    }
137 - 212
} else if (getPGV('submitBtn') == "priceMonitor") {
127 - 213
    $xh->tag('h1', "Price Monitor Results");
137 - 214
} else if (getPGV('submitBtn') == "help") {
127 - 215
    $xh->tag('h1', "Getting Started");
137 - 216
} else if (getPGV('submitBtn') == "barcode") {
127 - 217
    $xh->tag('h1', "Barcode Checker");
137 - 218
} else if (getPGV('submitBtn') == "unsubscribe") {
127 - 219
    $xh->tag('h1', "Unsubscribe Wishlist");
137 - 220
} else {
127 - 221
    $xh->tag('h1', "Find Cheap CDs, Records, Digital, Books and Sheets");
222
    $xh->add_attribute("id", "textslide");
223
    $xh->add_attribute("class", "d-none d-sm-block");
224
    $xh->tag('p', "Bookmark FindCheapMusic.com");
65 - 225
}
2 - 226
 
127 - 227
        $xh->close(); // div
228
    $xh->close(); // div
73 - 229
 
127 - 230
    $xh->insert_code(mainSearchForm());
138 - 231
    $xh->insert_code(mainAdvSearchForm());
2 - 232
 
134 - 233
if (getPGV('submitBtn') == "terms") {
120 - 234
    $snip = file_get_contents('snippets/terms.txt');
235
    $snip = str_replace("<script>", "<script nonce=\"" . base64_encode($_SESSION["nonce"]) . "\">", $snip);
127 - 236
    $xh->insert_code($snip);
137 - 237
} else if (getPGV('submitBtn') == "privacy") {
120 - 238
    $snip = file_get_contents('snippets/privacy.txt');
239
    $snip = str_replace("<script>", "<script nonce=\"" . base64_encode($_SESSION["nonce"]) . "\">", $snip);
127 - 240
    $xh->insert_code($snip);
137 - 241
} else if (getPGV('submitBtn') == "help") {
127 - 242
    $xh->insert_code(printHelp());
137 - 243
} else if (getPGV('submitBtn') == "barcode") {
127 - 244
    $xh->insert_code(barcodePage());
137 - 245
} else if (getPGV('submitBtn') == "coupons") {
65 - 246
    //get_linkshareCoupons(); // bugbug
127 - 247
    $xh->insert_code(getCouponCodes());
137 - 248
} else if (getPGV('submitBtn') == "wishlist") {
127 - 249
    $xh->insert_code(getWishlist());
137 - 250
} else if (getPGV('submitBtn') == "priceMonitor") {
127 - 251
    $xh->add_attribute("class", "container");
252
    $xh->add_attribute("id", "productTable");
253
    $xh->tag('div');
254
    $xh->insert_code(getPriceMonitor());
255
    $xh->close(); // div
137 - 256
} else if (getPGV('submitBtn') == "unsubscribe") {
127 - 257
    $xh->insert_code(unsubscribeWishlist($_GET));
137 - 258
} else if (getPGV('submitBtn') == "random") {
138 - 259
    findDiscogsMaster(true);
119 - 260
    if (!empty($_SESSION["discogs"])) {
127 - 261
        $xh->insert_code(str_replace("xxxNONCExxx", base64_encode($_SESSION["nonce"]), $_SESSION["discogs"]));
119 - 262
    }
137 - 263
} else {
65 - 264
    if ($_SESSION["lowestPrice"]["All"] > 0.00 || !empty($_SESSION["searchTerm"])) {
127 - 265
        $xh->insert_code(str_replace("xxxNONCExxx", base64_encode($_SESSION["nonce"]), $_SESSION["discogs"]));
266
        $xh->add_attribute("class", "container border py-2");
267
        $xh->add_attribute("id", "productTable");
268
        $xh->tag('div');
269
        $xh->insert_code(storeOfferHeader());
104 - 270
        if ($_SESSION["lowestPrice"]["All"] > 0.00) {
127 - 271
            $xh->insert_code(printResultHeader());
104 - 272
        }
127 - 273
        $xh->insert_code(printResult());
274
        $xh->close(); // div
133 - 275
        $xh->insert_code(productTableEventListeners());
65 - 276
    }
277
    else if (!empty($_SESSION["discogs"])) {
127 - 278
        $xh->insert_code(str_replace("xxxNONCExxx", base64_encode($_SESSION["nonce"]), $_SESSION["discogs"]));
65 - 279
    }
280
    else {
127 - 281
        $xh->insert_code(startscreen());
14 - 282
    }
127 - 283
 
284
    $xh->insert_code(printSearchInfoModal());
65 - 285
}
2 - 286
 
127 - 287
$xh->insert_code(printProgessbarModal());
14 - 288
 
128 - 289
$xh->insert_code(printSocialIconBar());
81 - 290
 
127 - 291
$xh->insert_code(htmlFooter());
2 - 292
 
127 - 293
$xh->insert_code(headerQuoteSlides());
294
 
295
$xh->insert_code(downloadAtOnload());
296
 
297
$xh->tag('form');
298
    $xh->add_attribute("type", "hidden");
299
    $xh->add_attribute("id", "nonce");
300
    $xh->add_attribute("name", "nonce");
301
    $xh->add_attribute("value", $_SESSION["nonce"]);
302
    $xh->single_tag('input');
303
$xh->close(); // form
304
 
305
$xh->close(); // body
306
$xh->close(); // html
307
 
308
$html = $xh->flush();
309
//error_log(print_r($html, 1));
310
 
311
echo $html;
312
 
313
MySessionHandler::commit(session_id());