| Server IP : 85.158.181.41 / Your IP : 216.73.217.12 Web Server : Apache System : Linux cloud9-vm129 6.1.178+1-ph #ph SMP PREEMPT_DYNAMIC Wed Jul 29 09:00:54 UTC 2026 x86_64 User : moncbefd ( 1024) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/moncbefd/www.moneta.at/system/extender/ |
Upload File : |
<?php
/* --------------------------------------------------------------
ApplicationBottomExtenderComponent.inc.php 2019-10-15
Gambio GmbH
http://www.gambio.de
Copyright (c) 2019 Gambio GmbH
Released under the GNU General Public License (Version 2)
[http://www.gnu.org/licenses/gpl-2.0.html]
--------------------------------------------------------------
*/
MainFactory::load_class('ExtenderComponent');
/**
* Class ApplicationBottomExtenderComponent
*/
class ApplicationBottomExtenderComponent extends ExtenderComponent
{
public $v_page = false;
public function init_page(): void
{
$t_script_name = $this->get_script_name();
$t_page = '';
if ($this->v_data_array['GET']['coID'] == 13) {
$t_page = PageType::GUESTBOOK;
} elseif ($this->v_data_array['GET']['coID'] == 14) {
$t_page = PageType::CALLBACK_SERVICE;
} elseif (!empty($this->v_data_array['GET']['manufacturers_id'])
&& substr_count($t_script_name,
'index.php') > 0) {
$t_page = PageType::MANUFACTURERS;
} elseif (substr_count($t_script_name, 'product_info.php') > 0) {
$t_page = PageType::PRODUCT_INFO;
} elseif (!empty($this->v_data_array['GET']['cat'])
|| substr_count($_SERVER["QUERY_STRING"],
'cat=') > 0
|| substr_count($_SERVER["REQUEST_URI"],
'cat/') > 0
|| isset($this->v_data_array['GET']['filter_fv_id'])
|| isset($this->v_data_array['GET']['filter_price_min'])
|| isset($this->v_data_array['GET']['filter_price_max'])
|| isset($this->v_data_array['GET']['filter_id'])) {
$t_page = PageType::CAT;
} elseif (substr_count($t_script_name, 'advanced_search_result.php') > 0) {
$t_page = PageType::SEARCH;
} elseif (substr_count($t_script_name, 'gm_price_offer.php') > 0) {
$t_page = PageType::PRICE_OFFER;
} elseif (substr_count($t_script_name, 'shopping_cart.php') > 0) {
$t_page = PageType::CART;
} elseif (substr_count($t_script_name, 'shop_content.php') > 0) {
$t_page = PageType::CONTENT;
} elseif (substr_count($t_script_name, 'wish_list.php') > 0) {
$t_page = PageType::WISH_LIST;
} elseif (substr_count($t_script_name, 'address_book_process.php') > 0) {
$t_page = PageType::ADDRESS_BOOK_PROCESS;
} elseif (substr_count($t_script_name, 'gv_send.php') > 0) {
$t_page = PageType::GV_SEND;
} elseif (substr_count($t_script_name, 'checkout_') > 0) {
$t_page = PageType::CHECKOUT;
} elseif (substr_count($t_script_name, 'account_history_info.php') > 0) {
$t_page = PageType::ACCOUNT_HISTORY;
} elseif ((substr_count($t_script_name, 'account.php') > 0)
|| (substr_count($t_script_name, 'address_book.php') > 0)
|| (substr_count($t_script_name, 'account_password.php') > 0)
|| (substr_count($t_script_name, 'gm_account_delete.php') > 0)
|| (substr_count($t_script_name, 'shop.php') > 0
&& (substr_count($_GET['do'], 'CreateRegistree') > 0
|| substr_count($_GET['do'], 'CreateGuest') > 0))) {
$t_page = PageType::ACCOUNT;
} elseif (substr_count(strtolower($t_script_name), 'index.php') > 0) {
$t_page = PageType::INDEX;
} elseif (substr_count($t_script_name, 'withdrawal.php') > 0) {
$t_page = PageType::WITHDRAWAL;
}
$this->v_page = $t_page;
}
/**
* @return string
*/
protected function get_script_name(): string
{
if (strpos($_SERVER['SCRIPT_NAME'], '.php') !== false) {
if (strpos($_SERVER['SCRIPT_NAME'], DIR_WS_CATALOG) !== false) {
return $_SERVER['SCRIPT_NAME'];
} elseif (strpos($_SERVER['PHP_SELF'], DIR_WS_CATALOG) !== false) {
return $_SERVER["PHP_SELF"];
} elseif (strpos($_SERVER['SCRIPT_FILENAME'], DIR_WS_CATALOG) !== false) {
return $_SERVER['SCRIPT_FILENAME'];
}
}
return $PHP_SELF;
}
function init_js()
{
$this->v_output_buffer = [];
if ((gm_get_conf('GM_SHOP_OFFLINE') != 'checked'
|| $_SESSION['customers_status']['customers_status_id'] == 0)) {
$t_get_data_array = [];
$t_page = $this->get_page();
if ($t_page == PageType::PRODUCT_INFO) {
$t_get_data_array[] = 'cPath=' . $this->v_data_array['cPath'];
$t_get_data_array[] = 'products_id=' . $this->v_data_array['products_id'];
} elseif ($t_page == PageType::CAT) {
$t_get_data_array[] = 'cPath=' . $this->v_data_array['cPath'];
}
if (!empty($t_page)) {
$t_get_data_array[] = 'page=' . $t_page;
}
// open the MiniWK with this param
if (isset($_GET['open_cart_dropdown']) && $_GET['open_cart_dropdown'] == 1) {
$t_get_data_array[] = 'open_cart_dropdown=1';
}
$t_get_data_array[] = 'current_template=' . StaticGXCoreLoader::getThemeControl()->getCurrentTheme();
if (gm_get_env_info('TEMPLATE_VERSION') >= 3) {
$cacheToken = MainFactory::create('CacheTokenHelper')->getCacheToken();
$isDebugMode = file_exists(DIR_FS_CATALOG . '.dev-environment');
$suffix = '.min';
$bustParameter = '?bust=' . $cacheToken;
$bustSuffix = '';
if ($isDebugMode) {
$suffix = '';
$bustParameter = '';
}
if ($isDebugMode === false
&& isset($_SERVER['gambio_mod_rewrite_working'], $_SERVER['gambio_htaccessVersion'])
&& (bool)$_SERVER['gambio_mod_rewrite_working']
&& version_compare($_SERVER['gambio_htaccessVersion'], '2.8') >= 0
&& @constant('USE_BUSTFILES') === 'true') {
$bustSuffix = '-bust_' . $cacheToken;
$bustParameter = '';
}
$dataCache = DataCache::get_instance();
$renewInitJs = false;
if ($dataCache->get_persistent_data('init_js-' . $_SESSION['language_code']) !== $cacheToken) {
$renewInitJs = true;
}
$initJsFilename = DIR_FS_CATALOG . StaticGXCoreLoader::getThemeControl()->getThemeJsPath() . 'init-'
. $_SESSION['language_code'] . $suffix . '.js';
if ($renewInitJs || !file_exists($initJsFilename)) {
// page token will be set in separate script block to avoid caching problems
$pageToken = '';
$jsEngineConfig = MainFactory::create('JSEngineConfiguration',
new NonEmptyStringType(GM_HTTP_SERVER . DIR_WS_CATALOG),
new NonEmptyStringType(StaticGXCoreLoader::getThemeControl()
->getThemePath()),
new LanguageCode(new StringType($_SESSION['language_code'])),
MainFactory::create_object('LanguageTextManager',
[],
true),
new EditableKeyValueCollection([
'buttons' => 'buttons',
'general' => 'general',
'labels' => 'labels',
'messages' => 'messages'
]),
new BoolType($isDebugMode),
new StringType($pageToken),
new StringType($cacheToken));
$viewType = StaticGXCoreLoader::getThemeControl()->isThemeSystemActive() ? 'theme' : 'template';
$initJsContent = $jsEngineConfig->getJavaScript() . "\n";
$initJsContent .= $this->load_file('JSEngine/build/vendor' . $suffix . '.js');
$initJsContent .= $this->load_file_from_js_path('vendor' . $suffix . '.js');
$initJsContent .= $this->load_file('JSEngine/build/jse' . $suffix . '.js');
$initJsContent .= $this->load_file_from_js_path("initialize_$viewType" . $suffix . '.js');
$initJsContent .= $this->load_file_from_js_path("{$viewType}_helpers" . $suffix . '.js');
# Add global JS from GXModule directory
$gxModuleFiles = GXModulesCache::getInstalledModuleFiles();
$directoryName = StaticGXCoreLoader::getThemeControl()
->isThemeSystemActive() ? 'Themes' : 'Templates';
$addedJsFiles = [];
foreach (array_reverse(StaticGXCoreLoader::getThemeControl()
->getCurrentThemeHierarchy()) as $currentTheme) {
foreach ($gxModuleFiles as $file) {
if (substr($file, -3) === '.js' && !in_array($file, $addedJsFiles)
&& (stripos($file,
'/' . $directoryName . '/' . $currentTheme . '/Javascript/Global/')
!== false
|| stripos($file, '/' . $directoryName . '/All/Javascript/Global/') !== false)) {
$initJsContent .= file_get_contents($file) . "\n";
$addedJsFiles[] = $file;
}
}
}
if (file_exists($initJsFilename)) {
unlink($initJsFilename);
}
file_put_contents($initJsFilename, $initJsContent);
$dataCache->write_persistent_data('init_js-' . $_SESSION['language_code'], $cacheToken);
}
if ($isDebugMode) {
// page token will be set in separate script block to avoid caching problems
$pageToken = '';
$jsEngineConfig = MainFactory::create('JSEngineConfiguration',
new NonEmptyStringType(GM_HTTP_SERVER . DIR_WS_CATALOG),
new NonEmptyStringType(StaticGXCoreLoader::getThemeControl()
->getThemePath()),
new LanguageCode(new StringType($_SESSION['language_code'])),
MainFactory::create_object('LanguageTextManager',
[],
true),
new EditableKeyValueCollection([
'buttons' => 'buttons',
'general' => 'general',
'labels' => 'labels',
'messages' => 'messages'
]),
new BoolType($isDebugMode),
new StringType($pageToken),
new StringType($cacheToken));
$this->v_output_buffer['GM_JAVASCRIPT_CODE'] = '<script>' . $jsEngineConfig->getJavaScript()
. '</script>' . "\n\t\t";
$this->v_output_buffer['GM_JAVASCRIPT_CODE'] .= '<script src="JSEngine/build/vendor' . $suffix
. '.js"></script>' . "\n\t\t";
$this->v_output_buffer['GM_JAVASCRIPT_CODE'] .= '<script src="'
. StaticGXCoreLoader::getThemeControl()
->getThemeJsPath() . 'vendor' . $suffix
. '.js"></script>' . "\n\t\t";
$this->v_output_buffer['GM_JAVASCRIPT_CODE'] .= '<script src="JSEngine/build/jse' . $suffix
. '.js"></script>' . "\n\t\t";
if (!StaticGXCoreLoader::getThemeControl()->isThemeSystemActive()) {
$this->v_output_buffer['GM_JAVASCRIPT_CODE'] .= '<script src="'
. StaticGXCoreLoader::getThemeControl()
->getThemeJsPath() . 'initialize_template'
. $suffix . '.js"></script>' . "\n\t\t";
$this->v_output_buffer['GM_JAVASCRIPT_CODE'] .= '<script src="'
. StaticGXCoreLoader::getThemeControl()
->getThemeJsPath() . 'template_helpers'
. $suffix . '.js"></script>' . "\n\t\t";
} else {
$this->v_output_buffer['GM_JAVASCRIPT_CODE'] .= '<script src="'
. StaticGXCoreLoader::getThemeControl()
->getThemeJsPath() . 'initialize_theme'
. $suffix . '.js"></script>' . "\n\t\t";
$this->v_output_buffer['GM_JAVASCRIPT_CODE'] .= '<script src="'
. StaticGXCoreLoader::getThemeControl()
->getThemeJsPath() . 'theme_helpers'
. $suffix . '.js"></script>' . "\n\t\t";
}
# Add global JS from GXModule directory
$gxModuleFiles = GXModulesCache::getInstalledModuleFiles();
$directoryName = StaticGXCoreLoader::getThemeControl()
->isThemeSystemActive() ? 'Themes' : 'Templates';
$addedJsFiles = [];
foreach (array_reverse(StaticGXCoreLoader::getThemeControl()
->getCurrentThemeHierarchy()) as $currentTheme) {
foreach ($gxModuleFiles as $file) {
if (substr($file, -3) === '.js' && !in_array($file, $addedJsFiles)
&& (stripos($file,
'/' . $directoryName . '/' . $currentTheme . '/Javascript/Global/')
!== false
|| stripos($file, '/' . $directoryName . '/All/Javascript/Global/') !== false)) {
$file = substr($file, strlen(DIR_FS_CATALOG));
$this->v_output_buffer['GM_JAVASCRIPT_CODE'] .= '<script src="' . $file . '"></script>'
. "\n\t\t";
$addedJsFiles[] = $file;
}
}
}
} else {
$this->v_output_buffer['GM_JAVASCRIPT_CODE'] = '<script src="'
. StaticGXCoreLoader::getThemeControl()
->getThemeJsPath() . 'init-'
. $_SESSION['language_code'] . $bustSuffix . $suffix
. '.js' . $bustParameter . '" data-page-token="'
. $_SESSION['coo_page_token']->generate_token()
. '" id="init-js"></script>' . "\n\t\t";
}
$usermodJsMaster = MainFactory::create('UsermodJSMaster', $t_page);
if (count($usermodJsMaster->get_files())) {
$this->v_output_buffer['GM_JAVASCRIPT_CODE'] .= '<script src="gm_javascript.js.php?'
. implode('&', $t_get_data_array)
. '"></script>' . "\n\t\t";
}
} else {
$this->v_output_buffer['GM_JAVASCRIPT_CODE'] = '<script src="gm_javascript.js.php?' . implode('&',
$t_get_data_array)
. '"></script>';
}
}
if (StaticGXCoreLoader::getThemeControl()->isThemeSystemActive()) {
$this->init_custom_theme_js(isset($t_page) ? $t_page : null);
}
}
function get_page()
{
return $this->v_page;
}
/**
* @param $filename
*
* @return string
*/
protected function load_file($filename)
{
$result = '';
$filename = DIR_FS_CATALOG . $filename;
if (file_exists($filename)) {
$result = file_get_contents($filename) . "\n";
}
return $result;
}
/**
* @param $filename
*
* @return string
*/
protected function load_file_from_js_path($filename)
{
$filename = StaticGXCoreLoader::getThemeControl()->getThemeJsPath() . $filename;
return $this->load_file($filename);
}
/**
* Includes theme custom scripts to the bottom
*
* @param string|null $page
*/
protected function init_custom_theme_js($page)
{
// Set correct path of the theme
$publishedThemePath = StyleEditServiceFactory::service()->getPublishedThemePath();
$arguments = $publishedThemePath ?
[ "{$publishedThemePath}/javascripts/system" ] :
null;
$customThemeJavaScriptCacheControl = MainFactory::create_object(
'CustomThemeJavaScriptController',
$arguments
);
$this->append_custom_js($customThemeJavaScriptCacheControl->getJavaScripts($page));
$variantDirectoryPath = DIR_FS_CATALOG . StaticGXCoreLoader::getThemeControl()->getPublishedThemePath() . '/variants';
if (is_dir($variantDirectoryPath)) {
$variantDirectory = new ExistingDirectory($variantDirectoryPath);
$themeJavaScriptOverloadControl = MainFactory::create_object('ThemeJavaScriptOverloadController',
[$variantDirectory]);
$this->v_output_buffer['GM_JAVASCRIPT_CODE'] = $themeJavaScriptOverloadControl->overloadJavaScripts($this->v_output_buffer['GM_JAVASCRIPT_CODE']);
}
}
/**
* appends a list of custom javascript's
*
* @param string[] $javaScriptPaths
*/
protected function append_custom_js($javaScriptPaths)
{
if (count($javaScriptPaths) > 0) {
foreach ($javaScriptPaths as $js) {
$path = explode(DIRECTORY_SEPARATOR, $js);
$script = array_pop($path);
$directory = array_pop($path);
$parameters = ['script' => $script, 'directory' => $directory];
$queryString = http_build_query($parameters);
$this->v_output_buffer['GM_JAVASCRIPT_CODE'] .= "<script src=\"customThemeJavaScriptCacheControl.php?$queryString\"></script>\n\t\t";
}
}
}
function proceed()
{
$t_page = $this->get_page();
if ($t_page === false) {
trigger_error('need call of init_page() method before proceed', E_USER_ERROR);
}
parent::proceed();
}
}