forked from exponentcms/exponent-cms
/
index.php
124 lines (105 loc) · 3.93 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
<?php
##################################################
#
# Copyright (c) 2004-2011 OIC Group, Inc.
# Copyright (c) 2006 Maxim Mueller
# Written and Designed by James Hunt
#
# This file is part of Exponent
#
# Exponent is free software; you can redistribute
# it and/or modify it under the terms of the GNU
# General Public License as published by the Free
# Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# GPL: http://www.gnu.org/licenses/gpl.txt
#
##################################################
/** @define "BASE" "." */
define('SCRIPT_EXP_RELATIVE','');
define('SCRIPT_FILENAME','index.php');
/**
* @param $buffer
* @param $mode
* @return string
*/
function epb($buffer, $mode) {
//@ob_gzhandler($buffer, $mode);
@ob_gzhandler($buffer);
//return $buffer; // uncomment if you're messing with output buffering so errors show. ~pb
return expProcessBuffer($buffer);
}
ob_start('epb');
$microtime_str = explode(' ',microtime());
$i_start = $microtime_str[0] + $microtime_str[1];
// Initialize the Exponent Framework
require_once('exponent.php');
//active global timer if in DEVELOPMENT mode
if(DEVELOPMENT) $timer = new expTimer();
// if the user has turned on sef_urls then we need to route the request, otherwise we can just
// skip it and default back to the old way of doing things.
$router->routeRequest();
// initialize this users cart if they have ecom installed.
// define whether or not ecom is enabled
if ($db->selectValue('modstate', 'active', 'module="storeController"')) {
define('ECOM',1);
$order = order::getUserCart();
// Create a globle store config
// We're forcing the location. Global store setting will always have this loc
$cfg->mod = "ecomconfig";
$cfg->src = "@globalstoresettings";
$cfg->int = "";
$storeConfig = new expConfig($cfg);
} else {
define('ECOM',0);
}
if (isset($_GET['id']) && !is_numeric($_GET['id'])) $_GET['id'] = intval($_GET['id']);
$section = $router->getSection();
if ($db->havedb) $sectionObj = $router->getSectionObj($section);
if (ENABLE_TRACKING) $router->updateHistory($section);
// set the output header
header("Content-Type: text/html; charset=".LANG_CHARSET);
// Check to see if we are in maintenance mode.
if (MAINTENANCE_MODE && !$user->isAdmin() && (!isset($_REQUEST['controller']) || $_REQUEST['controller'] != 'login') && !expJavascript::inAjaxAction()) {
//only admins/acting_admins are allowed to get to the site, all others get the maintenance view
$template = new standalonetemplate('_maintenance');
$template->output();
} else {
if (MAINTENANCE_MODE > 0) flash('error', gt('Maintenance Mode is Enabled'));
//the default user is anonymous
// if (!expSession::loggedIn()) {
//TODO: Maxims initial anonymous user implementation
//user::login("anonymous", "anonymous");
// }
// check to see if we need to install or upgrade the system
expVersion::checkVersion();
// Handle sub themes
$page = expTheme::getTheme();
// If we are in a printer friendly request then we need to change to our printer friendly subtheme
if (PRINTER_FRIENDLY == 1) {
expSession::set("uilevel",0);
$pftheme = expTheme::getPrinterFriendlyTheme(); // get the printer friendly theme
$page = $pftheme == null ? $page : $pftheme; // if there was no theme found then just use the current subtheme
}
if (is_readable($page)) {
if (!expJavascript::inAjaxAction()) {
include_once($page);
expTheme::satisfyThemeRequirements();
} else {
expTheme::runAction();
}
} else {
echo sprintf(gt('Page "%s" not readable.'), $page);
}
if (PRINTER_FRIENDLY == 1) {
//$levels = expSession::get('uilevels');
//if (!empty($levels)) expSession::set('uilevel',max(array_keys($levels)));
expSession::un_set('uilevel');
}
}
//$microtime_str = explode(' ',microtime());
//$i_end = $microtime_str[0] + $microtime_str[1];
//echo "\r\n<!--".sprintf(gt('Execution time : %d seconds'),round($i_end - $i_start,4)).'-->';
ob_end_flush();
?>