Subversion Repositories cheapmusic

Rev

Rev 138 | Rev 143 | 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'));
114
    $xh->close(); // head
115
$xh->tag('body');
116
 
134 - 117
if (!empty($_SESSION["gtmId"])) {
127 - 118
    $xh->add_attribute('nonce', base64_encode($_SESSION["nonce"]));
138 - 119
    $xh->tag('style');
120
        $xh->insert_code(".gtm-noscript{display:none;visibility:hidden;}");
121
    $xh->close(); // style
122
    $xh->add_attribute('nonce', base64_encode($_SESSION["nonce"]));
127 - 123
    $xh->tag('noscript');
134 - 124
        $xh->add_attribute("src", "https://www.googletagmanager.com/ns.html?id=" . $_SESSION["gtmId"]);
127 - 125
        $xh->add_attribute("height", "0");
126
        $xh->add_attribute("width", "0");
138 - 127
        $xh->add_attribute("class", "gtm-noscript");
127 - 128
        $xh->add_attribute("title", "Tagmanager");
129
        $xh->tag('iframe', "");
130
    $xh->close(); // noscript
119 - 131
}
132
 
2 - 133
if ($_SERVER["REQUEST_METHOD"] == "POST") {
134 - 134
    if ($_POST["submitBtn"] == "Search") {
137 - 135
        buildDiscogsSearchTerm();
2 - 136
 
137 - 137
        if (!empty($_SESSION["searchTerm"])) {
138 - 138
            $_SESSION["mode"] = SIMPLE_SEARCH;
116 - 139
            performSearch();
141 - 140
            $xh->insert_code(jumpToSection("discogsTable"));
65 - 141
        }
137 - 142
    } else if ($_POST["submitBtn"] == "advSearch") {
143
        buildDiscogsSearchTerm();
144
        if (!empty($_SESSION["advSearch"])) {
138 - 145
            $_SESSION["mode"] = ADVANCED_SEARCH;
116 - 146
            performSearch();
141 - 147
            $xh->insert_code(jumpToSection("discogsTable"));
65 - 148
        }
137 - 149
    } else if ($_POST["submitBtn"] == "discogsSearch") {
150
        buildDiscogsSearchTerm();
151
        if (!empty($_SESSION["searchTerm"])) {
141 - 152
            $_SESSION["mode"] = ADVANCED_SEARCH;
153
            performSearch(true);
154
            $xh->insert_code(jumpToSection("productTable"));
65 - 155
        }
137 - 156
    } else if ($_POST["submitBtn"] == "unsubscribe") {
73 - 157
// bugbug
158
    }
65 - 159
}
160
else if ($_SERVER["REQUEST_METHOD"] == "GET") {
137 - 161
    buildDiscogsSearchTerm();
162
    if (!empty($_SESSION["searchTerm"])) {
138 - 163
/*
164
        $xh->insert_code(printProgessbarModal());
165
        $xh->add_attribute('nonce', base64_encode($_SESSION["nonce"]));
166
        $xh->tag('script');
167
        $str = 'progressBar(' . $_SESSION["searchTerm"] . ');';
168
        $xh->insert_code($str);
169
        $xh->flush();
170
        $xh->close();  // script
171
*/
116 - 172
        performSearch();
65 - 173
    }
2 - 174
}
175
 
141 - 176
$xh->insert_code(navigationPane());
127 - 177
 
178
    $xh->add_attribute("class", "page-header bg-primary");
179
    $xh->tag('div');
180
        $xh->add_attribute("class", "container text-center py-3");
181
        $xh->tag('div');
182
 
134 - 183
if (getPGV('submitBtn') == "terms") {
127 - 184
    $xh->tag('h1', "Terms of Service");
137 - 185
} else if (getPGV('submitBtn') == "privacy") {
127 - 186
    $xh->tag('h1', "Privacy Policy");
137 - 187
} else if (getPGV('submitBtn') == "coupons") {
127 - 188
    $xh->tag('h1', "Special Offers &amp; Coupon Codes");
137 - 189
} else if (getPGV('submitBtn') == "wishlist") {
127 - 190
    $xh->tag('h1', "Wishlist");
78 - 191
    if (!empty($_SESSION['priceMonitor'])) {
127 - 192
        $xh->add_attribute("method", "post");
193
        $xh->add_attribute("action", "/index.php");
194
        $xh->tag('form');
195
            $xh->insert_code(inputSessionTab());
196
            $xh->insert_code(inputNonce());
197
            $xh->add_attribute("class", "btn btn-info rounded");
198
            $xh->add_attribute("id", "priceMonitor");
199
            $xh->add_attribute("type", "submit");
134 - 200
            $xh->add_attribute("name", "submitBtn");
127 - 201
            $xh->add_attribute("value", "priceMonitor");
202
            $xh->tag('button', "Price Monitor Results");
203
            if (!empty($_SESSION['priceMonitor']['newFlag']) && $_SESSION['priceMonitor']['newFlag'] === true) {
204
                $xh->add_attribute("class", "badge badge-pill badge-dark");
134 - 205
                 $xh->tag('span', "New");
127 - 206
            }
207
            $xh->close(); // button
208
        $xh->close(); // form
78 - 209
    }
137 - 210
} else if (getPGV('submitBtn') == "priceMonitor") {
127 - 211
    $xh->tag('h1', "Price Monitor Results");
137 - 212
} else if (getPGV('submitBtn') == "help") {
127 - 213
    $xh->tag('h1', "Getting Started");
137 - 214
} else if (getPGV('submitBtn') == "barcode") {
127 - 215
    $xh->tag('h1', "Barcode Checker");
137 - 216
} else if (getPGV('submitBtn') == "unsubscribe") {
127 - 217
    $xh->tag('h1', "Unsubscribe Wishlist");
137 - 218
} else {
127 - 219
    $xh->tag('h1', "Find Cheap CDs, Records, Digital, Books and Sheets");
220
    $xh->add_attribute("id", "textslide");
221
    $xh->add_attribute("class", "d-none d-sm-block");
222
    $xh->tag('p', "Bookmark FindCheapMusic.com");
65 - 223
}
2 - 224
 
127 - 225
        $xh->close(); // div
226
    $xh->close(); // div
73 - 227
 
127 - 228
    $xh->insert_code(mainSearchForm());
138 - 229
    $xh->insert_code(mainAdvSearchForm());
2 - 230
 
134 - 231
if (getPGV('submitBtn') == "terms") {
120 - 232
    $snip = file_get_contents('snippets/terms.txt');
233
    $snip = str_replace("<script>", "<script nonce=\"" . base64_encode($_SESSION["nonce"]) . "\">", $snip);
127 - 234
    $xh->insert_code($snip);
137 - 235
} else if (getPGV('submitBtn') == "privacy") {
120 - 236
    $snip = file_get_contents('snippets/privacy.txt');
237
    $snip = str_replace("<script>", "<script nonce=\"" . base64_encode($_SESSION["nonce"]) . "\">", $snip);
127 - 238
    $xh->insert_code($snip);
137 - 239
} else if (getPGV('submitBtn') == "help") {
127 - 240
    $xh->insert_code(printHelp());
137 - 241
} else if (getPGV('submitBtn') == "barcode") {
127 - 242
    $xh->insert_code(barcodePage());
137 - 243
} else if (getPGV('submitBtn') == "coupons") {
65 - 244
    //get_linkshareCoupons(); // bugbug
127 - 245
    $xh->insert_code(getCouponCodes());
137 - 246
} else if (getPGV('submitBtn') == "wishlist") {
127 - 247
    $xh->insert_code(getWishlist());
137 - 248
} else if (getPGV('submitBtn') == "priceMonitor") {
127 - 249
    $xh->add_attribute("class", "container");
250
    $xh->add_attribute("id", "productTable");
251
    $xh->tag('div');
252
    $xh->insert_code(getPriceMonitor());
253
    $xh->close(); // div
137 - 254
} else if (getPGV('submitBtn') == "unsubscribe") {
127 - 255
    $xh->insert_code(unsubscribeWishlist($_GET));
137 - 256
} else if (getPGV('submitBtn') == "random") {
138 - 257
    findDiscogsMaster(true);
119 - 258
    if (!empty($_SESSION["discogs"])) {
127 - 259
        $xh->insert_code(str_replace("xxxNONCExxx", base64_encode($_SESSION["nonce"]), $_SESSION["discogs"]));
119 - 260
    }
137 - 261
} else {
65 - 262
    if ($_SESSION["lowestPrice"]["All"] > 0.00 || !empty($_SESSION["searchTerm"])) {
127 - 263
        $xh->insert_code(str_replace("xxxNONCExxx", base64_encode($_SESSION["nonce"]), $_SESSION["discogs"]));
264
        $xh->add_attribute("class", "container border py-2");
265
        $xh->add_attribute("id", "productTable");
266
        $xh->tag('div');
267
        $xh->insert_code(storeOfferHeader());
104 - 268
        if ($_SESSION["lowestPrice"]["All"] > 0.00) {
127 - 269
            $xh->insert_code(printResultHeader());
104 - 270
        }
127 - 271
        $xh->insert_code(printResult());
272
        $xh->close(); // div
133 - 273
        $xh->insert_code(productTableEventListeners());
65 - 274
    }
275
    else if (!empty($_SESSION["discogs"])) {
127 - 276
        $xh->insert_code(str_replace("xxxNONCExxx", base64_encode($_SESSION["nonce"]), $_SESSION["discogs"]));
65 - 277
    }
278
    else {
127 - 279
        $xh->insert_code(startscreen());
14 - 280
    }
127 - 281
 
282
    $xh->insert_code(printSearchInfoModal());
65 - 283
}
2 - 284
 
127 - 285
$xh->insert_code(printProgessbarModal());
14 - 286
 
128 - 287
$xh->insert_code(printSocialIconBar());
81 - 288
 
127 - 289
$xh->insert_code(htmlFooter());
2 - 290
 
127 - 291
$xh->insert_code(headerQuoteSlides());
292
 
293
$xh->insert_code(downloadAtOnload());
294
 
295
$xh->tag('form');
296
    $xh->add_attribute("type", "hidden");
297
    $xh->add_attribute("id", "nonce");
298
    $xh->add_attribute("name", "nonce");
299
    $xh->add_attribute("value", $_SESSION["nonce"]);
300
    $xh->single_tag('input');
301
$xh->close(); // form
302
 
303
$xh->close(); // body
304
$xh->close(); // html
305
 
306
$html = $xh->flush();
307
//error_log(print_r($html, 1));
308
 
309
echo $html;
310
 
311
MySessionHandler::commit(session_id());