/** * Constructor */ function MultiLang_Core() { // getting if mb_string is installed $this->_mb_enabled = in_array('mbstring', get_loaded_extensions()); if ($this->_mb_enabled) { CTrace::inf('mb_string is enabled.'); } else { CTrace::inf('mb_string is NOT enabled, it disabled multilang support.'); } // analyzing mb_string settings if ($this->_mb_enabled) { // getting if mb_output_handler is set $this->_mb_output = strpos(ini_get('output_handler'), 'mb_output_handler') !== false; } }
function SendMailToAdmin() { $value = ""; $Nvalue = ""; $Mod = modApiFunc('SecureStore', 'checkSessionForModifiedFile'); $New = modApiFunc('SecureStore', 'checkSessionForNewlyAddedFile'); $Msg = getMsg('SS', 'FIND_UPDATE_NO_RESULT_MSG'); $NewA = getMsg('SS', 'NEWLY_ADDED_FILE'); $NewM = getMsg('SS', 'MODIFIED_FILE'); if ($Mod !== $Msg) { $value = $NewM . "<br/><br/>" . $Mod; } if ($New !== $Msg) { $Nvalue = "<br/><br/>" . $NewA . "<br/><br/>" . $New; } if ($value !== "" || $Nvalue !== "") { $Mail_Body = $value . $Nvalue; $email = modApiFunc('Configuration', 'getValue', SYSCONFIG_STORE_OWNER_SITE_ADMINISTRATOR_EMAIL); loadCoreFile('ascHtmlMimeMail.php'); $mail = new ascHtmlMimeMail(); $mail->setText($Mail_Body); $mail->setSubject(getMsg('SS', 'SS_SEND_FILES_DETAILS_SUBJECT')); $mail->setFrom(modApiFunc('Notifications', 'getExtendedEmail', $email, 'EMAIL_STORE_OWNER', true)); $mail->send(array($email)); if (!$mail->send(array($email))) { CTrace::wrn('Mailer error: ' . $mail->ErrorInfo); } else { CTrace::inf('Mail has been sent for file changes in last days'); } $tl_type = getMsg('NTFCTN', 'NTFCTN_TL_TYPE'); $to = $email; $subj = getMsg('SS', 'SS_SEND_FILES_DETAILS_SUBJECT'); $tl_header = getMsg('SS', 'SS_SEND_FILES_DETAILS_SUBJECT'); $tl_body = $Mail_Body; modApiFunc('Timeline', 'addLog', $tl_type, $tl_header, $tl_body); $Msg = getMsg('SS', 'MAIL_SENT'); modApiFunc('Session', 'set', 'MailSendResultMessage', $Msg); } else { $Msg = getMsg('SS', 'ERROR_TO_SEND_MAIL'); modApiFunc('Session', 'set', 'MailSendResultMessage', $Msg); } modApiFunc('Session', 'set', 'ModifiedFileResult', ""); modApiFunc('Session', 'set', 'NewlyAddedFileResult', ""); }
/** * Initializes the languages * Note: cannot be executed in constructor * since the class is created before creating the factory */ function initLanguages() { global $application; global $zone; // if no mb_string then no language selection is available if (!$application->multilang_core->_mb_enabled) { return; } $active_only = $zone == 'CustomerZone'; // setting the default language $this->_default_language = $this->_readDefaultLanguage(); CTrace::inf('Default language is ' . CTrace::var2str($this->_default_language)); // selecting the current language $this->_language = $this->_default_language; CTrace::inf('Current language is ' . CTrace::var2str($this->_language)); // if customer is registered if ($zone == 'CustomerZone' && ($customer = modApiFunc('Customer_Account', 'getCurrentSignedCustomer'))) { $lng = modApiFunc('Customer_Account', 'getAccountLanguage', $customer); if ($lng && $this->checkLanguage($lng, $active_only)) { $this->_language = $lng; CTrace::inf('Customer is signed in, change current language to ' . $this->_language . ' because of the account settings.'); } } // if admin is registered if ($zone == 'AdminZone' && ($adminID = modApiFunc('Users', 'getCurrentUserID'))) { $lng = modApiFunc('Users', 'getAccountLanguageById', $adminID); if ($lng && $this->checkLanguage($lng, $active_only)) { $this->_language = $lng; CTrace::inf('Admin is signed in, change current language to ' . $this->_language . ' because of the account settings.'); } } // if cookie is set if (isset($_COOKIE['current_language_az']) && $zone == 'AdminZone') { $lng = $_COOKIE['current_language_az']; if ($this->checkLanguage($lng, $active_only)) { $this->_language = $lng; CTrace::inf('Change current language to ' . $this->_language . ' because of cookies.'); } } if (isset($_COOKIE['current_language']) && $zone == 'CustomerZone') { $lng = $_COOKIE['current_language']; if ($this->checkLanguage($lng, $active_only)) { $this->_language = $lng; CTrace::inf('Change current language to ' . $this->_language . ' because of cookies.'); } } // if language is set in the query string if (isset($_GET['current_language']) || isset($_POST['current_language'])) { if (isset($_GET['current_language'])) { $lng = $_GET['current_language']; } else { $lng = $_POST['current_language']; } if ($this->checkLanguage($lng, $active_only)) { $this->_language = $lng; CTrace::inf('Change current language to ' . $this->_language . ' because of GET params.'); } } // checking the language if (!$this->checkLanguage($this->_language, $active_only)) { $this->_language = $this->_getAnyLanguage($active_only); if (!$this->_language) { $this->_default_language = ''; CTrace::inf('Set default language to "".'); } } // saving the current language // (only in case if the language was not provided in URL) if ($this->_language && !isset($_GET['current_language']) && !isset($_POST['current_language'])) { // setting the cookie for 30 days if ($zone == 'CustomerZone') { setcookie('current_language', $this->_language, time() + 2592000); } else { setcookie('current_language_az', $this->_language, time() + 2592000); } // updating the customer_account if needed if ($zone == 'CustomerZone' && $customer) { modApiFunc('Customer_Account', 'setAccountLanguage', $customer, $this->_language); } // updating the admin_account if needed if ($zone == 'AdminZone' && $adminID) { modApiFunc('Users', 'updateAccountLanguage', $adminID, $this->_language); } } $this->_default_language_number = $this->_readLanguageNumber($this->_default_language); $this->_language_number = $this->_readLanguageNumber($this->_language); $this->_resource_language = $this->_language; $this->_resource_language_number = $this->_language_number; // getting the page language if set if ($zone == 'AdminZone' && modApiFunc('Session', 'is_set', 'PageLanguages')) { $PageLanguages = modApiFunc('Session', 'get', 'PageLanguages'); $request =& $application->getInstance('Request'); $view = $request->getValueByKey('page_view'); $action = $request->getCurrentAction(); $pagelanguage = ''; $script_name = array_pop(explode('/', $_SERVER['SCRIPT_NAME'])); if (isset($PageLanguages['pages'][$script_name])) { $pagelanguage = $PageLanguages['pages'][$script_name]; } elseif (isset($PageLanguages['views'][$view])) { $pagelanguage = $PageLanguages['views'][$view]; } elseif (isset($PageLanguages['actions'][$action])) { $pagelanguage = $PageLanguages['actions'][$action]; } if ($pagelanguage && $this->checkLanguage($pagelanguage, $active_only)) { $this->_language = $pagelanguage; $this->_language_number = $this->_readLanguageNumber($this->_language); CTrace::inf('Change current language to ' . $this->_language . ' because it is page language.'); } } }
/** * * * @return null */ function initModules() { global $application, $zone; $lang = _ml_strtolower($application->getAppIni('LANGUAGE')); $moduleListCache = $application->getMMCache(); if (isset($_SERVER['QUERY_STRING']) and $_SERVER['QUERY_STRING'] == 'update_all_modules') { CCacheFactory::clearAll(); $this->resetAllModulesStatus(); $_die_after_init = true; } else { $_die_after_init = false; } if (!$this->isModuleInstalled('Modules_Manager')) { $this->installModule($this->getModuleInfoFromFile($this->modules_directory . 'Modules_Manager')); CCacheFactory::clearAll(); } else { /* Upgrade Main Store SQL- start*/ $mmInfo = $this->getModuleInfoFromFile($this->modules_directory . 'Modules_Manager'); if (version_compare($this->getModuleVersion($mmInfo->name), $mmInfo->version) < 0) { $oldVersionexplode = explode(".", $this->getModuleVersion($mmInfo->name)); $oldModuleVersion = $oldVersionexplode[2]; $upgradeFolder = $application->appIni['PATH_SYSTEM_DIR'] . "dbupdates/"; $this->executeUpgradeSQL($oldModuleVersion, $upgradeFolder); } /* Upgrade Main Store SQL-end */ } if (!$this->isModuleInstalled('Resources')) { $this->installModule($this->getModuleInfoFromFile($this->modules_directory . 'Resources')); // aquire system and CZ messages modApiFunc("Resources", "addResourceIniToDB", $application->getAppIni('PATH_ADMIN_RESOURCES') . 'system-messages-' . $lang . '.ini', 'SYS', 'system_messages', 'AZ'); $_path = dirname(dirname(dirname(dirname(__FILE__)))) . '/avactis-themes/system/resources/messages.ini'; modApiFunc("Resources", "addResourceIniToDB", $_path, 'CZ', 'customer_messages', 'CZ'); CCacheFactory::clearAll(); } if (!$this->isModuleInstalled('MultiLang')) { modApiFunc("Resources", "addResourceIniToDB", $application->getAppIni('PATH_ADMIN_RESOURCES') . 'multilang-messages-' . $lang . '.ini', 'ML', 'MultiLang', 'AZ'); $this->installModule($this->getModuleInfoFromFile($this->modules_directory . 'multilang')); $this->isModuleInstalled('MultiLang', true); // , CCacheFactory::clearAll(); } if (!$this->isModuleInstalled('Configuration')) { modApiFunc("Resources", "addResourceIniToDB", $application->getAppIni('PATH_ADMIN_RESOURCES') . 'configuration-messages-' . $lang . '.ini', 'CFG', 'Configuration', 'AZ'); $this->installModule($this->getModuleInfoFromFile($this->modules_directory . 'configuration')); $this->isModuleInstalled('Configuration', true); // , CCacheFactory::clearAll(); } if (!$this->isModuleInstalled('EventsManager')) { $this->installModule($this->getModuleInfoFromFile($this->modules_directory . 'eventsmanager')); $this->isModuleInstalled('EventsManager', true); // , CCacheFactory::clearAll(); } if ($application->db->DB_isTableExists($application->getAppIni('DB_TABLE_PREFIX') . "sessions") == false) { $tables['sessions'] = array(); $tables['sessions']['columns'] = array('ses_id' => 'sessions.ses_id', 'ses_time' => 'sessions.ses_time', 'ses_value' => 'sessions.ses_value', 'ses_locked' => 'sessions.ses_locked'); $tables['sessions']['types'] = array('ses_id' => DBQUERY_FIELD_TYPE_CHAR32 . ' NOT NULL DEFAULT \'\'', 'ses_time' => DBQUERY_FIELD_TYPE_INT . ' NOT NULL DEFAULT 0', 'ses_value' => DBQUERY_FIELD_TYPE_LONGTEXT . ' NOT NULL ', 'ses_locked' => DBQUERY_FIELD_TYPE_INT . ' NOT NULL DEFAULT 0'); $tables['sessions']['primary'] = array('ses_id'); $tables['sessions']['indexes'] = array('IDX_time' => 'ses_time', 'IDX_locked' => 'ses_locked'); $query = new DB_Table_Create($application->addTablePrefix($tables)); } $this->moduleList = $moduleListCache->read('ModulesList'); $this->apiFiles = $moduleListCache->read('apiFiles'); $this->modulesResFiles = $moduleListCache->read('modulesResFiles'); $this->shortNamesToResFiles = $moduleListCache->read('shortNamesToResFiles'); $this->actionList = $moduleListCache->read('actionList'); $this->czViewList = $moduleListCache->read('czViewList'); $this->azViewList = $moduleListCache->read('azViewList'); $this->czAliasesList = $moduleListCache->read('czAliasesList'); $this->hookList = $moduleListCache->read('hookList'); $this->blocksList = $moduleListCache->read('blocksList'); $this->SectionByView = $moduleListCache->read('SectionByView'); $this->ViewBySection = $moduleListCache->read('ViewBySection'); $this->storefrontLayout = $moduleListCache->read('storefrontLayout'); if (!$this->hookList) { $this->hookList = array(); } if (!isset($this->moduleList)) { $this->moduleList = array(); /** installed Extensions Array **/ $installedExtensionArray = $this->getInstalledExtensionModuleInfo(); /* Processing for avactis-extensions directory-Begin*/ $dir = @dir($application->getAppIni("PATH_ADD_MODULES_DIR")); if (is_dir($application->getAppIni("PATH_ADD_MODULES_DIR")) && is_readable($application->getAppIni("PATH_ADD_MODULES_DIR"))) { while ($file = $dir->read()) { if ($file != '..' && $file != '.' && is_dir($application->getAppIni("PATH_ADD_MODULES_DIR") . $file)) { $moduleInfo = $this->getModuleInfoFromFile($this->add_modules_directory . $file); $isExtensionNotInstalled = true; if (isset($installedExtensionArray[$moduleInfo->name])) { $isExtensionNotInstalled = $installedExtensionArray[$moduleInfo->name]['module_active']; } if ($isExtensionNotInstalled && $moduleInfo != null) { $this->moduleList[$moduleInfo->name] = $moduleInfo; } } } } /* Processing for avactis-extensions directory-End*/ $dir = @dir($application->getAppIni("PATH_MODULES_DIR")); while ($file = $dir->read()) { if ($file != '..' && $file != '.' && !is_dir($application->getAppIni("PATH_ADD_MODULES_DIR") . $file) && is_dir($application->getAppIni("PATH_MODULES_DIR") . $file)) { $moduleInfo = $this->getModuleInfoFromFile($this->modules_directory . $file); if ($moduleInfo != null) { // $this->moduleList[$moduleInfo->name] = $moduleInfo; } } } asort($this->moduleList); foreach ($this->moduleList as $module_name => $moduleInfo) { // check if the files of the module exist. $this->checkModuleFiles($moduleInfo); // save the class name of the module and the whole path to its main file in the list $this->apiFiles[_ml_strtolower($moduleInfo->name)] = $moduleInfo->mainFile; // save all extra API classes and their files if (is_array($moduleInfo->extraAPIFiles)) { foreach ($moduleInfo->extraAPIFiles as $class => $file) { $this->apiFiles[_ml_strtolower($class)] = $file; } } if ($moduleInfo->shortName != null and isset($this->modulesResFiles[$moduleInfo->shortName])) { unset($this->moduleList[$moduleInfo->name]); CTrace::err('Duplicate Short Name ' . $moduleInfo->shortName); continue; } $res_file_suffix = '-' . _ml_strtolower($application->getAppIni('LANGUAGE')) . '.ini'; $res_files_common_location = $application->getAppIni('PATH_ADMIN_RESOURCES'); if ($moduleInfo->resFile != null and $moduleInfo->shortName != null) { /* * $this->modulesResFiles * . . */ $res_file_in_module = $this->store_dir . $moduleInfo->directory . 'resources/' . $moduleInfo->resFile . $res_file_suffix; $res_file_in_common_location = $res_files_common_location . $moduleInfo->resFile . $res_file_suffix; if ($moduleInfo->shortName == null) { _fatal("Module {$moduleInfo->name} has no short name."); } if (isset($this->shortNamesToResFiles[$moduleInfo->resFile])) { _fatal("Duplicate Res File for {$moduleInfo->name}."); } else { $this->shortNamesToResFiles[$moduleInfo->resFile] = $moduleInfo->shortName; } if (file_exists($res_file_in_module)) { $this->modulesResFiles[$moduleInfo->shortName] = $res_file_in_module; } else { if (file_exists($res_file_in_common_location)) { $this->modulesResFiles[$moduleInfo->shortName] = $res_file_in_common_location; } } } // API . // . if (PRODUCT_VERSION_TYPE == 'TRUNK') { $this->checkModuleAPIClass($moduleInfo); } // , // , . // get text resources from the res file and put it into the database if (!$this->isModuleInstalled($moduleInfo->name)) { if (!isset($moduleInfo->shortName)) { _fatal("No short name for {$moduleInfo->name}!"); } if (isset($this->modulesResFiles[$moduleInfo->shortName]) && file_exists($this->modulesResFiles[$moduleInfo->shortName])) { modApiFunc("Resources", "dropMessageMetaByMetaId", $moduleInfo->shortName); modApiFunc("Resources", "dropMessageGroupByMetaId", $moduleInfo->shortName); modApiFunc("Resources", "addResourceIniToDB", $this->modulesResFiles[$moduleInfo->shortName], $moduleInfo->shortName, $moduleInfo->name, 'AZ'); } else { // no res file for module } } $this->installModule($moduleInfo); // update , // , modules updated . $this->updateModule($moduleInfo); // actions foreach ($moduleInfo->actionFiles as $actionName => $actionFile) { $this->actionList[$actionName] = $actionFile; } // save the list of all views for CustomerZone foreach ($moduleInfo->czViewFiles as $viewName => $viewFile) { $this->czViewList[$viewName] = $viewFile; } // save the list of all views for AdminZone foreach ($moduleInfo->czAliases as $alias => $viewName) { $this->czAliasesList[$alias] = $viewName; } // save the list of all views for AdminZone foreach ($moduleInfo->azViewFiles as $viewName => $viewFile) { $this->azViewList[$viewName] = $viewFile; } // save a list of all hooks foreach ($moduleInfo->hookMap as $hookName => $actionList) { foreach ($actionList as $actionName) { if (!key_exists($actionName, $this->hookList)) { $this->hookList[$actionName] = array(); } $this->hookList[$actionName][$hookName] = $moduleInfo->hookFiles[$hookName]; } } // save a list of blocks if (file_exists($this->store_dir . $moduleInfo->directory . 'blocks.yml')) { $this->blocksList[] = $this->store_dir . $moduleInfo->directory . 'blocks.yml'; } // sections by view if (!empty($moduleInfo->SectionByView)) { $this->SectionByView = $moduleInfo->SectionByView; } // views by section if (!empty($moduleInfo->ViewBySection)) { $this->ViewBySection = $moduleInfo->ViewBySection; } // storefront Layout addition if ($moduleInfo->storefrontLayout && file_exists($this->store_dir . $moduleInfo->directory . $moduleInfo->storefrontLayout)) { if (!$this->storefrontLayout) { $this->storefrontLayout = array(); } $this->storefrontLayout = array_merge($this->storefrontLayout, _parse_ini_file($this->store_dir . $moduleInfo->directory . $moduleInfo->storefrontLayout, true)); } } if (PRODUCT_VERSION_TYPE != 'TRUNK') { $moduleListCache->write('ModulesList', $this->moduleList); $moduleListCache->write('apiFiles', $this->apiFiles); $moduleListCache->write('modulesResFiles', $this->modulesResFiles); $moduleListCache->write('shortNamesToResFiles', $this->shortNamesToResFiles); $moduleListCache->write('actionList', $this->actionList); $moduleListCache->write('czViewList', $this->czViewList); $moduleListCache->write('azViewList', $this->azViewList); $moduleListCache->write('czAliasesList', $this->czAliasesList); $moduleListCache->write('hookList', $this->hookList); $moduleListCache->write('blocksList', $this->blocksList); $moduleListCache->write('SectionByView', $this->SectionByView); $moduleListCache->write('ViewBySection', $this->ViewBySection); $moduleListCache->write('storefrontLayout', $this->storefrontLayout); } } else { CTrace::inf('Bypass loading of module list (use cached).'); } if (!defined('COMPILED_MODULES_LOADED')) { foreach ($this->moduleList as $module_name => $moduleInfo) { // if the file of module constants is specfifed, then load it. if ($moduleInfo->constantsFile !== null) { $this->includeFile($moduleInfo->constantsFile); } // load common db queries $common_db_queries_file = $moduleInfo->directory . 'dbqueries/common.php'; if (file_exists($this->store_dir . $common_db_queries_file)) { $this->includeFile($common_db_queries_file); } //load extension default hooks if ($moduleInfo->ext_def_hooks !== null) { $this->includeFile($moduleInfo->ext_def_hooks); } $this->includeFile($moduleInfo->directory . '/asc-hooks.php'); } } else { CTrace::inf('Bypass constants and queries including (use precompiled).'); } if (!defined('MODULES_VIEWS_REGISTERED')) { if ($zone == 'CustomerZone') { foreach ($this->moduleList as $module_name => $moduleInfo) { $this->registerViewList($moduleInfo->czViewFiles); $this->registerAliasesList($moduleInfo->czAliases); } } else { foreach ($this->moduleList as $module_name => $moduleInfo) { $this->registerViewList($moduleInfo->azViewFiles); } } } else { CTrace::inf('Bypass modules views registering (use precompiled).'); } if ($_die_after_init === true) { die('Message'); } }
CTrace::startScript(); CTrace::setId(getmypid()); foreach ($tracelog as $trace_cfg) { if ($trace_cfg['enabled'] == 'yes') { $r = new CTraceLogRotation($trace_cfg['file'], $trace_cfg['rotation']['size'], $trace_cfg['rotation']['rotate']); $r->rotate(); $tw = new CTraceWriter($trace_cfg['file'], $trace_cfg['template'], new CTraceFilter($trace_cfg['filter'])); CTrace::registerWriter($tw); } } } // must be defined after CTrace initialization. // all php notices, warnings and errors will be logged, so we need to set E_ALL level //error_reporting(E_ERROR); //set_error_handler('__error_handler__', E_ERROR); CTrace::inf('Request: ' . getCurrentURL()); CProfiler::start('init'); $bootstrap = new Bootstrap(); $bootstrap->preboot(); //CTrace::inf('Point 1 (after preboot)'); $bootstrap->preloadCorePHP(); do_action('init'); //CTrace::inf('Point 2 (after preloading core php)'); $bootstrap->preloadModulesPHP(); //CTrace::inf('Point 3 (after preloading modules php)'); global $zone; if ($zone == 'CustomerZone') { $bootstrap->preloadModulesViewsCzPHP(); //CTrace::inf('Point 3 (after preloading modules views php)'); } $bootstrap->boot();