-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.php
More file actions
147 lines (124 loc) · 6.35 KB
/
index.php
File metadata and controls
147 lines (124 loc) · 6.35 KB
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
<?php
// +----------------------------------------------------------------------+
// | bitcommerce, http://www.bitcommerce.org |
// +----------------------------------------------------------------------+
// | Copyright (c) 2013 bitcommerce.org |
// | This source file is subject to version 3.0 of the GPL license |
// | Portions Copyrigth (c) 2005 http://www.zen-cart.com |
// | Portions Copyright (c) 2003 osCommerce |
// +----------------------------------------------------------------------+
// These classes need to be included first so they get written to the session properly
require_once('includes/classes/navigation_history.php');
require_once('../kernel/includes/setup_inc.php');
require_once('includes/application_top.php');
global $gBitUser, $gBitCustomer, $gBitSmarty, $gCommercePopupTemplate;
// Maybe customer registered with an inline form
if( !$gBitUser->isRegistered() && !empty( $_REQUEST['inline_registration'] ) ) {
if( $gBitCustomer->register( $_REQUEST ) ) {
} else {
$gBitSmarty->assign( 'userErrors', $gBitUser->mErrors );
}
}
// determine the page directory
if( empty( $_REQUEST['main_page'] ) ) {
if( @BitBase::verifyId( $_REQUEST['user_id'] ) ) {
$_REQUEST['main_page'] = 'user_products';
} elseif( $infoPage = $gBitProduct->getInfoPage() ) {
$_REQUEST['main_page'] = $infoPage;
global $gContent, $gBitSmarty;
// we are viewing a product, assume it is gContent if nothing else was created so services work
if( empty( $gContent ) ) {
$gContent = &$gBitProduct;
$gBitSmarty->assignByRef( 'gContent', $gContent );
}
} else {
$_REQUEST['main_page'] = 'index';
}
// compatibility for shite code
$_GET['main_page'] = $_REQUEST['main_page'];
}
if( !file_exists( DIR_FS_PAGES . $_REQUEST['main_page'] ) ) {
$_REQUEST['main_page'] = 'index';
}
$current_page = $_REQUEST['main_page'];
$current_page_base = $current_page;
$code_page_directory = DIR_FS_PAGES . $current_page_base;
$page_directory = $code_page_directory;
$gBitSmarty->assignByRef( 'current_page_base', $current_page_base );
$language_page_directory = DIR_WS_LANGUAGES . $gBitCustomer->getLanguage() . '/';
// We need to buffer output
ob_start();
// load all files in the page directory starting with 'header_php'
$directory_array = $gCommerceSystem->get_template_part($code_page_directory, '/^header_php/');
foreach( $directory_array as $key=>$value ) {
require($code_page_directory . '/' . $value);
}
//new smarty based pages are doing away with this call
require_once( DIR_FS_MODULES . 'require_languages.php' );
// require($gCommerceSystem->get_template_dir('html_header.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/html_header.php');
// Define Template Variables picked up from includes/main_template_vars.php unless a file exists in the
// includes/pages/{page_name}/directory to overide. Allowing different pages to have different overall
//templates.
require($gCommerceSystem->get_template_dir('main_template_vars.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/main_template_vars.php');
// Read the "on_load" scripts for the individual page, and from the site-wide template settings
// NOTE: on_load_*.js files must contain just the raw code to be inserted in the <body> tag in the on_load="" parameter.
// Looking in "/includes/modules/pages" for files named "on_load_*.js"
$directory_array = $gCommerceSystem->get_template_part(DIR_FS_PAGES . $current_page_base, '/^on_load_/', '.js');
foreach( $directory_array as $key => $value ) {
$onload_file = DIR_FS_PAGES . $current_page_base . '/' . $value;
$read_contents='';
$lines = @file($onload_file);
foreach($lines as $line) {
$read_contents.=$line;
}
$za_onload_array[]=$read_contents;
}
//now read "includes/templates/TEMPLATE/jscript/on_load/on_load_*.js", which would be site-wide settings
$directory_array=array();
$tpl_dir=$gCommerceSystem->get_template_dir('.js', DIR_WS_TEMPLATE, 'jscript/on_load', 'jscript/on_load_');
$directory_array = $gCommerceSystem->get_template_part($tpl_dir ,'/^on_load_/', '.js');
foreach( $directory_array as $key => $value ) {
$onload_file = $tpl_dir . '/' . $value;
$read_contents='';
$lines = @file($onload_file);
foreach($lines as $line) {
$read_contents.=$line;
}
$za_onload_array[]=$read_contents;
}
if( !empty( $zc_first_field ) ) $za_onload_array[] = $zc_first_field; // for backwards compatibility with previous $zc_first_field usage
$zv_onload = '';
if( !empty( $za_onload_array ) ) $zv_onload=implode(';',$za_onload_array);
$zv_onload = str_replace(';;',';',$zv_onload.';'); //ensure we have just one ';' between each, and at the end
if (trim($zv_onload) == ';') $zv_onload=''; // ensure that a blank list is truly blank and thus ignored.
// Define the template that will govern the overall page layout, can be done on a page by page basis
// or using a default template. The default template installed will be a standard 3 column layout. This
// template also loads the page body code based on the variable $body_code.
require($gCommerceSystem->get_template_dir('tpl_main_page.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_main_page.php');
require(DIR_FS_INCLUDES . 'application_bottom.php');
$content = ob_get_contents();
$gBitSmarty->assignByRef( 'bitcommerceCenter', $content );
ob_end_clean();
if( !empty( $gCommercePopupTemplate ) ) {
$gBitSmarty->display( $gCommercePopupTemplate );
} else {
if( BitBase::getParameter( $_REQUEST, 'content-type' ) == 'json' ) {
if( $gBitProduct->isValid() ) {
$gBitSystem->outputJson( $gBitProduct->exportHash(), HttpStatusCodes::HTTP_OK );
}
} elseif( $current_page_base == 'index' && empty( $_REQUEST['cPath'] ) ) {
// Display the template
$gDefaultCenter = 'bitpackage:bitcommerce/default_index.tpl';
$gBitSmarty->assignByRef( 'gDefaultCenter', $gDefaultCenter );
if( !empty( $_REQUEST['products_id'] ) && !$gBitProduct->isValid() ) {
$gBitSystem->setHttpStatus( HttpStatusCodes::HTTP_NOT_FOUND );
}
$pageTitle = (defined( 'HEADING_TITLE' ) ? constant( 'HEADING_TITLE' ) : '');
// Display the template
$gBitSystem->display( 'bitpackage:kernel/dynamic.tpl', $pageTitle, array( 'display_mode' => 'display' ));
} else {
$pageTitle = defined( 'HEADING_TITLE' ) ? constant( 'HEADING_TITLE' ) : '';
$gBitSystem->display( 'bitpackage:bitcommerce/view_bitcommerce.tpl', $pageTitle, array( 'display_mode' => 'display' ));
}
}
?>