/
virtuemart.php
143 lines (117 loc) · 4.52 KB
/
virtuemart.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
<?php
if( !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
/**
*
* @version $Id: virtuemart.php 8768 2015-03-02 12:22:14Z Milbo $
* @package VirtueMart
* @subpackage core
* @author Max Milbers
* @copyright Copyright (C) 2009-14 by the authors of the VirtueMart Team listed at /administrator/com_virtuemart/copyright.php - All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
/* Require the config */
defined('DS') or define('DS', DIRECTORY_SEPARATOR);
if (!class_exists( 'VmConfig' )) require(JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'helpers'.DS.'config.php');
VmConfig::loadConfig();
vmRam('Start');
vmSetStartTime('Start');
VmConfig::loadJLang('com_virtuemart', true);
if(VmConfig::get('shop_is_offline',0)){
//$cache->setCaching (1);
$_controller = 'virtuemart';
require (VMPATH_SITE.DS.'controllers'.DS.'virtuemart.php');
vRequest::setVar('view', 'virtuemart');
$task='';
$basePath = VMPATH_SITE;
} else {
// Front-end helpers
if(!class_exists('VmImage')) require(VMPATH_ADMIN.DS.'helpers'.DS.'image.php'); //dont remove that file it is actually in every view except the state view
if(!class_exists('shopFunctionsF'))require(VMPATH_SITE.DS.'helpers'.DS.'shopfunctionsf.php'); //dont remove that file it is actually in every view
$_controller = vRequest::getCmd('view', vRequest::getCmd('controller', 'virtuemart')) ;
$trigger = 'onVmSiteController';
// $task = vRequest::getCmd('task',vRequest::getCmd('layout',$_controller) ); $this makes trouble!
$task = vRequest::getCmd('task','') ;
$session = JFactory::getSession();
$manage = vRequest::getCmd('manage',$session->get('manage', false,'vm'));
if(!$manage) $session->set('manage', 0,'vm');
$feViews = array('askquestion','cart','invoice','pdf','pluginresponse','productdetails','recommend','vendor','vmplg');
if($manage and !in_array($_controller,$feViews)){
$app = JFactory::getApplication();
$user = JFactory::getUser();
$vendorIdUser = VmConfig::isSuperVendor();
if ($vendorIdUser) {
VmConfig::loadJLang('com_virtuemart');
$jlang = JFactory::getLanguage();
$tag = $jlang->getTag();
$jlang->load('', JPATH_ADMINISTRATOR,$tag,true);
VmConfig::loadJLang('com_virtuemart');
$basePath = VMPATH_ADMIN;
$trigger = 'onVmAdminController';
vmdebug('$vendorIdUser use FE managing '.$vendorIdUser);
$session->set('manage', 1,'vm');
vRequest::setVar('manage','1');
vmJsApi::jQuery(false);
vmJsApi::loadBECSS();
$app = JFactory::getApplication();
$router = $app->getRouter();
$router->setMode(0);
} else {
$session->set('manage', 0,'vm');
$app->redirect('index.php?option=com_virtuemart', vmText::_('COM_VIRTUEMART_RESTRICTED_ACCESS') );
}
vRequest::setVar('tmpl','component') ;
} elseif($_controller) {
if($_controller!='productdetails'){
$session->set('manage', 0,'vm');
vRequest::setVar('manage','0');
}
vmJsApi::jQuery();
vmJsApi::jSite();
vmJsApi::cssSite();
$basePath = VMPATH_SITE;
}
}
// controller alias
if ($_controller=='pluginresponse') {
$_controller='vmplg';
}
/* Create the controller name */
$_class = 'VirtuemartController'.ucfirst($_controller);
if (file_exists($basePath.DS.'controllers'.DS.$_controller.'.php')) {
if (!class_exists($_class)) {
require ($basePath.DS.'controllers'.DS.$_controller.'.php');
}
}
else {
// try plugins
JPluginHelper::importPlugin('vmextended');
$dispatcher = JDispatcher::getInstance();
$rets = $dispatcher->trigger($trigger, array($_controller));
foreach($rets as $ret){
if($ret) return true;
}
}
if (class_exists($_class)) {
$controller = new $_class();
$controller->execute($task);
//vmTime($_class.' Finished task '.$task,'Start');
vmRam('End');
vmRamPeak('Peak');
/* Redirect if set by the controller */
$controller->redirect();
} else {
vmDebug('VirtueMart controller not found: '. $_class);
if (VmConfig::get('handle_404',1)) {
$mainframe = Jfactory::getApplication();
$mainframe->redirect(JRoute::_ ('index.php?option=com_virtuemart&view=virtuemart', FALSE));
} else {
JError::raise(E_ERROR,'404','Not found');
}
}