-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.php
executable file
·201 lines (187 loc) · 6.5 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<?php
/*
+--------------------------------------------------------------------------
| CubeCart 4
| ========================================
| CubeCart is a registered trade mark of CubeCart Limited
| Copyright CubeCart Limited 2014. All rights reserved.
| UK Private Limited Company No. 5323904
| ========================================
| Web: http://www.cubecart.com
| Email: [email protected]
| License: GPL-3.0 https://www.gnu.org/licenses/quick-guide-gplv3.html
+--------------------------------------------------------------------------
| index.php
+--------------------------------------------------------------------------
*/
$debugStart = microtime();
header('X-Frame-Options: SAME-ORIGIN');
## v3 Compatbility from old search Links
if(isset($_GET['act']) && !empty($_GET['act'])) {
switch($_GET['act']) {
case 'viewProd':
$url = 'Location: index.php?_a=viewProd&productId='.$_GET['productId'];
break;
case 'viewCat':
$url = ($_GET['catId']=='saleItems') ? 'Location: index.php?_a=viewCat&catId=saleItems' : 'Location: index.php?_a=viewCat&catId='.$_GET['catId'];
break;
case 'viewDoc':
$url = 'Location: index.php?_a=viewDoc&docId='.$_GET['docId'];
break;
default:
$url = 'index.php';
break;
}
header($url, false, 301);
}
if (isset($_GET['_a']) && $_GET['_a'] == 'search') {
## Do nothing yet...
} else {
if(preg_match('#([a-z]{1,6})_([a-z0-9\+]+)\.?([a-z]+)?(\?.*)?$#i', $_SERVER['REQUEST_URI'], $matches)) {
if(is_numeric($matches[2])) {
switch ($matches[1]) {
case 'c':
case 'cat':
$_GET['_a'] = 'viewCat';
$_GET['catId'] = $matches[2];
break;
case 'i':
case 'info':
$_GET['_a'] = 'viewDoc';
$_GET['docId'] = $matches[2];
break;
case 'p':
case 'prod':
$_GET['_a'] = 'viewProd';
$_GET['productId'] = $matches[2];
break;
case 't':
case 'taf':
case 'tell':
$_GET['_a'] = 'tellafriend';
$_GET['productId'] = $matches[2];
break;
}
} elseif($matches[1]=='s' || $matches[1]=='search') {
$_GET['_a'] = 'viewCat';
$_GET['searchStr'] = $matches[2];
}
}
}
require_once 'ini.inc.php';
## If global.inc.php doesn't exist, the store probably needs to be installed
if (!file_exists('includes'.CC_DS.'global.inc.php')) {
header('Location: setup/index.php');
exit;
}
require_once 'includes'.CC_DS.'global.inc.php';
## If it does exist, then check that the install worked, and that the admin file exists
if (!$glob['installed'] || !isset($glob['adminFile'])) {
# Nope, lets do the install
header('Location: setup/index.php');
exit;
}
$debugTime['start'] = microtime();
require_once ("includes" . CC_DS . "functions.inc.php");
require_once ("classes" . CC_DS . "db" . CC_DS . "db.php");
$db = new db();
require_once ("classes" . CC_DS . "cache" . CC_DS . "cache.php");
$config = fetchdbconfig("config");
if(($config['offLine']==1 && isset($_SESSION[CC_ADMIN_SESSION_NAME]) && $config['offLineAllowAdmin']==0) || ($config['offLine']==1 && !isset($_SESSION[CC_ADMIN_SESSION_NAME])))
{
$offlineContent = false;
$offlineFiles = glob("offline.{php,htm,html}", GLOB_BRACE);
if (!empty($offlineFiles) || is_array($offlineFiles))
{
foreach ($offlineFiles as $file)
{
include ($file);
exit();
}
}
echo stripslashes(base64_decode($config['offLineContent']));
exit();
}
require_once ("classes" . CC_DS . "xtpl" . CC_DS . "xtpl.php");
if ($_REQUEST['_g'] !== "rm")
{
require_once ("includes" . CC_DS . "sef_urls.inc.php");
require_once ("includes" . CC_DS . "sslSwitch.inc.php");
require_once ("classes" . CC_DS . "session" . CC_DS . "cc_session.php");
$cc_session = new session();
$lang = getlang("common.inc.php");
}
require_once ("includes" . CC_DS . "currencyVars.inc.php");
switch ($_REQUEST['_g'])
{
case "ajax":
case "json":
case "xmlhttp":
$skipload = true;
require_once ("xml.php");
exit();
case "co":
require_once ("includes" . CC_DS . "global" . CC_DS . "cart.inc.php");
break;
case "sw":
require_once ("includes" . CC_DS . "global" . CC_DS . "switch.inc.php");
break;
case "dl":
require_once ("includes" . CC_DS . "global" . CC_DS . "download.inc.php");
break;
case "ex":
require_once ("includes" . CC_DS . "global" . CC_DS . "extra.inc.php");
exit();
case "rm":
require_once ("includes" . CC_DS . "remote" . CC_DS . "remote.inc.php");
exit();
case "cs":
$decodedPath = get_magic_quotes_gpc() ? stripslashes(urldecode($_GET['_p'])):
urldecode($_GET['_p']);
if (in_array($decodedPath, $allowed_modules))
{
include_once ($decodedPath);
exit();
}
default:
require_once ("includes" . CC_DS . "global" . CC_DS . "index.inc.php");
}
if ($config['debug'])
{
$debug = "<div style='margin-top: 15px; font-family: Courier New, Courier, mono; border: 1px dashed #666; padding: 10px; color: #000; background: #FFF'>";
$debug .= "<strong>\$_POST Variables:</strong><br />" . cc_print_array($_POST) . "<hr size=1 />";
$debug .= "<strong>\$_GET Variables:</strong><br />" . cc_print_array($_GET) . "<hr size=1 />";
$debug .= "<strong>\$_COOKIE Variables:</strong><br />" . cc_print_array($_COOKIE) . "<hr size=1 />";
$debug .= "<strong>\$basket Variables:</strong> (unserialize(\$cc_session->ccUserData['basket']))<br />" . cc_print_array(unserialize($cc_session->ccUserData['basket'])) . "<hr size=1 />";
$debug .= "<strong>\$cc_session->ccUserData Variables:</strong><br />" . cc_print_array($cc_session->ccUserData) . "<hr size=1 />";
$debug .= "<strong>MySQL Queries (" . count($db->queryArray) . "):</strong><br />" . cc_print_array($db->queryArray);
$debug .= "</div>";
}
if (isset($body) && is_object($body))
{
$body->assign("PAGE_CONTENT", $page_content);
$body->assign("VAL_ROOTREL", $glob['rootRel']);
$body->assign("DEBUG_INFO", $debug);
$body->parse("body");
$htmlOut = $body->text("body");
if (isset($config['google_analytics'], $config['google_analytics']))
{
$googleAnalytics = "
<script type=\"text/javascript\">
var gaJsHost = ((\"https:\" == document.location.protocol) ? \"https://ssl.\" : \"http://www.\");
document.write(unescape(\"%3Cscript src='\" + gaJsHost + \"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E\"));
</script>
<script type=\"text/javascript\">
var pageTracker = _gat._getTracker(\"" . $config['google_analytics'] . "\");
pageTracker._initData();
pageTracker._trackPageview();
</script>";
}
else
{
$googleAnalytics = "";
}
$htmlOut = preg_replace("/(\\<\\/head\\>)/i", $googleAnalytics . "\$1", $htmlOut);
echo $htmlOut;
}
?>