/** * @ a description for the function TemplateFiller->. */ function TemplateFiller($path_templates_dir = null) { parent::TmplIncluder(); global $application; if ($path_templates_dir != null) { $this->TemplateDirPrefix = $path_templates_dir; } $this->MessageResources =& $application->getInstance('MessageResources'); $this->prepared_template_cache = CCacheFactory::getCache('temporary', __CLASS__); if (!$this->www_address) { $this->www_address = $application->getAppIni('HTTP_URL'); if ($application->getCurrentProtocol() == "https" && $application->getAppIni('HTTPS_URL')) { $this->www_address = $application->getAppIni('HTTPS_URL'); } } if (!$this->templates_url) { // $this->templates_url = $application->getAppIni('URL_THEME'); $this->templates_url = $application->getAppIni('URL_TEMPLATES'); if ($application->getCurrentProtocol() == "https" && $application->getAppIni('HTTPS_URL_TEMPLATES')) { $this->templates_url = $application->getAppIni('HTTPS_URL_TEMPLATES'); } } if (!$this->site_url) { $this->site_url = $application->getAppIni('SITE_URL'); if ($application->getCurrentProtocol() == "https" && $application->getAppIni('SITE_HTTPS_URL')) { $this->site_url = $application->getAppIni('SITE_HTTPS_URL'); } } }
/** * */ function onAction() { global $application; $request = $application->getInstance('Request'); $instance = $request->getValueByKey('instance'); $log_clear_type = $request->getValueByKey('log_clear_type'); $value = ''; switch ($instance) { case 'cache': CCacheFactory::clearAll(); $value = getMsg("SYS", "MSG_CACHE_CLEARED"); if (APC_EXTENSION_LOADED) { apc_clear_cache("user"); } break; case 'timeline': modApiFunc('Timeline', 'clearTimeline', $log_clear_type); $timeline = modApiFunc('Timeline', 'getTimelineRecsCount'); if ($timeline == 0) { $value = getMsg("SYS", "ADMIN_PHP_FILES_NO_LOG_RECORDS"); } else { $value = $timeline . getMsg("SYS", "ADMIN_PHP_FILES_LOG_RECORDS"); } break; default: break; } return $value; }
function onAction() { global $application; $mm = $application->getInstance('Modules_Manager'); $lang = _ml_strtolower($application->getAppIni('LANGUAGE')); $_path = dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/avactis-themes/system/resources/messages.ini'; modApiFunc("Resources", "dropMessageGroupByMetaId", 'CZ'); modApiFunc("Resources", "dropMessageMetaByMetaId", 'CZ'); modApiFunc("Resources", "addResourceIniToDB", $_path, 'CZ', 'customer_messages', 'CZ'); modApiFunc("Resources", "dropMessageGroupByMetaId", 'SYS'); modApiFunc("Resources", "dropMessageMetaByMetaId", 'SYS'); modApiFunc("Resources", "addResourceIniToDB", $application->getAppIni('PATH_ADMIN_RESOURCES') . 'system-messages-' . $lang . '.ini', 'SYS', 'system_messages', 'AZ'); modApiFunc("Resources", "dropMessageGroupByMetaId", 'ML'); modApiFunc("Resources", "dropMessageMetaByMetaId", 'ML'); modApiFunc("Resources", "addResourceIniToDB", $application->getAppIni('PATH_ADMIN_RESOURCES') . 'multilang-messages-' . $lang . '.ini', 'ML', 'MultiLang', 'AZ'); modApiFunc("Resources", "dropMessageGroupByMetaId", 'CFG'); modApiFunc("Resources", "dropMessageMetaByMetaId", 'CFG'); modApiFunc("Resources", "addResourceIniToDB", $application->getAppIni('PATH_ADMIN_RESOURCES') . 'configuration-messages-' . $lang . '.ini', 'CFG', 'Configuration', 'AZ'); foreach ($mm->moduleList as $module_name => $moduleInfo) { if (isset($mm->modulesResFiles[$moduleInfo->shortName])) { modApiFunc("Resources", "dropMessageGroupByMetaId", $moduleInfo->shortName); modApiFunc("Resources", "dropMessageMetaByMetaId", $moduleInfo->shortName); modApiFunc("Resources", "addResourceIniToDB", $mm->modulesResFiles[$moduleInfo->shortName], $moduleInfo->shortName, $moduleInfo->name, 'AZ'); } } CCacheFactory::clearAll(); die('done'); }
/** * */ function onAction() { global $application; CCacheFactory::clearAll(); modApiFunc("Tools", "clearBackupSession"); modApiFunc("Tools", "setDBStat", modApiFunc("Modules_Manager", "getTablesAndRecordsCount")); modApiFunc("Tools", "setCurrentBackupTable", 0); modApiFunc("Tools", "setCurrentBackupTableLimit", 0); modApiFunc("Tools", "setDBRecordsExported", 0); $request = $application->getInstance('Request'); $filename = $request->getValueByKey('BackupFile'); if ($filename) { modApiFunc("Tools", "setRestoreStatus", 'BACKUP'); modApiFunc("Tools", "setRestoreFile", $filename); $filename = modApiFunc("Tools", "getRestoreFile"); $full_filename = $application->getAppIni('PATH_BACKUP_DIR') . $filename . "/dump.sql"; $handle = @fopen($full_filename, "rb"); $backup_file_content = @fread($handle, 1024); @fclose($handle); $error = ""; $backup_info = @_parse_ini_file($application->getAppIni('PATH_BACKUP_DIR') . $filename . "/info/backup.ini"); if (!isset($backup_info["asc_version"]) || $backup_info["asc_version"] != PRODUCT_VERSION) { $error = "BCP_RESTORE_ERR_003"; } elseif (!$backup_file_content) { $error = "BCP_RESTORE_ERR_001"; } elseif (_ml_strpos($backup_file_content, "-- HASH: ") === false) { $error = "BCP_RESTORE_ERR_002"; } else { $hash = _byte_substr($backup_file_content, 9, 32); // $handle = fopen($full_filename, "rb"); $md5_temp = ''; // $begin = _byte_strpos($backup_file_content, "\n") + _byte_strlen("\n"); fseek($handle, $begin); while (!feof($handle)) { $contents = fread($handle, 1048576); $md5_temp .= md5($contents); } $counted_file_hash = md5($md5_temp); fclose($handle); // : if ($hash != $counted_file_hash) { $error = "BCP_RESTORE_ERR_002"; } } if ($error) { modApiFunc("Tools", "setRestoreError", $error); } else { modApiFunc("Tools", "setStringsCountInRestoreFile", $filename); } } modApiFunc("Tools", "saveState"); }
/** * */ function onAction() { global $application; $request = $application->getInstance('Request'); $AutoBackup = $request->getValueByKey('AutoBackup'); if ($AutoBackup) { CCacheFactory::clearAll(); modApiFunc("Session", "set", "AutoBackup", true); } else { modApiFunc("Session", "un_set", "AutoBackup"); } }
function onAction() { global $application; $request =& $application->getInstance('Request'); $moduleName = $request->getValueByKey('module_name'); if (!empty($moduleName)) { $moduleInfo = modApiFunc('Modules_Manager', 'getModuleInfoByName', $moduleName); modApiFunc('Modules_Manager', 'uninstallModule', $moduleInfo); CCacheFactory::clearAll(); } $request = new Request(); $request->setView(CURRENT_REQUEST_URL); $application->redirect($request); }
/** * */ function onAction() { global $application; $getRebuildVal = $application->getInstance('Request'); $rebuildval = $getRebuildVal->getValueByKey('rebuildval'); if ($rebuildval == 'yes') { $lang = _ml_strtolower($application->getAppIni('LANGUAGE')); modApiFunc('Resources', 'deleteSYSLabels', 'SYS'); modApiFunc("Resources", "addResourceIniToDB", $application->getAppIni('PATH_ADMIN_RESOURCES') . 'system-messages-' . $lang . '.ini', 'SYS', 'system_messages', 'AZ'); modApiFunc('Session', 'set', 'ResultMessage', 'MSG_CACHE_UPDATED'); } else { CCacheFactory::clearAll(); $request = new Request(); $request->setView(CURRENT_REQUEST_URL); $application->redirect($request); modApiFunc('Session', 'set', 'ResultMessage', 'MSG_CACHE_UPDATED'); } }
function onAction() { global $application; $request = $_POST; $_state = modApiFunc("License", "checkLicense"); $licenseInfo = modApiFunc("License", "getLicenseInfo", $_state); if (class_exists('ZipArchive')) { $this->marketplace_server = $application->getAppIni('MARKETPLACE_SERVER'); $data = array('license' => $licenseInfo["license_key"], 'store_url' => $_SERVER['HTTP_HOST'] . $_SERVER['CONTEXT_PREFIX'], 'store_version' => PRODUCT_VERSION_NUMBER); loadCoreFile('bouncer.php'); $bnc = new Bouncer(); $bnc->setMethod('POST'); $bnc->setPOSTstring($bnc->prepareDATAstring($data)); $bnc->setURL($this->marketplace_server . "/download_extension.php?asc_action=SendLatestCoreFile"); $bnc->setProto('HTTPS'); $result = $bnc->RunRequest(); $response = $result['body']; if ($response != false && $bnc->responseCode < 400) { if (strpos($response, "ERR_") === 0) { modApiFunc("Session", "set", "ErrorMessage", $response); } else { $file = fopen($application->getAppIni('PATH_CACHE_DIR') . "avactis-upgrade.zip", 'w+'); fwrite($file, $response); fclose($file); $core_response = modApiFunc("Extension_Manager", "upgradeCore"); if (strpos($core_response, "ERR_") === 0) { modApiFunc("Session", "set", "ErrorMessage", $core_response); } else { CCacheFactory::clearAll(); $request = new Request(); $request->setView(CURRENT_REQUEST_URL); $application->redirect($request); } } } else { $error = "ERR_MARKETPLACE_NOT_AVAILABLE"; modApiFunc("Session", "set", "ErrorMessage", $error); } } else { $error = "ERR_CHK_ZIP_OR_PERMISSIONS"; modApiFunc("Session", "set", "ErrorMessage", $error); } }
function onAction() { global $application; $request = $_POST; $extension_name = $request["extn_name"]; $_state = modApiFunc("License", "checkLicense"); $licenseInfo = modApiFunc("License", "getLicenseInfo", $_state); $data = array('license' => $licenseInfo["license_key"], 'store_url' => $_SERVER['HTTP_HOST'] . $_SERVER['CONTEXT_PREFIX'], 'extn_name' => $extension_name, 'store_version' => PRODUCT_VERSION_NUMBER); $marketplace_server = $application->getAppIni('MARKETPLACE_SERVER'); loadCoreFile('bouncer.php'); $bnc = new Bouncer(); $bnc->setMethod('POST'); $bnc->setPOSTstring($bnc->prepareDATAstring($data)); $bnc->setURL($marketplace_server . "/download_extension.php?asc_action=SendExtension"); $bnc->setProto('HTTPS'); $result = $bnc->RunRequest(); $response = $result['body']; if ($response != false && $bnc->responseCode < 400) { if (strpos($response, "ERR_") === 0) { modApiFunc("Session", "set", "ErrorMessage", $response); //return $response['err_msg']; } else { $file = fopen($application->getAppIni(PATH_CACHE_DIR) . $extension_name . ".zip", 'w+'); fwrite($file, $response); fclose($file); $installed = modApiFunc("Extension_Manager", "installExtension", $extension_name); if ($installed) { modApiFunc("Session", "set", "InstallMessage", "1"); CCacheFactory::clearAll(); $request = new Request(); $request->setView(CURRENT_REQUEST_URL); $request->setKey('identifier', 'ExtensionManager_ListView'); $application->redirect($request); } else { modApiFunc("Session", "set", "ErrorMessage", "ERR_CHK_ZIP_OR_PERMISSIONS"); } } } else { modApiFunc("Session", "set", "ErrorMessage", "ERR_MARKETPLACE_NOT_AVAILABLE"); } }
function onAction() { global $application; $request =& $application->getInstance('Request'); $pi_target = $request->getValueByKey('pi_target'); global $_RESULT; switch ($pi_target) { case 'init': /* $sets['script_code'] = 'Products_CSV_DB'; $sets['script_step'] = $request->getValueByKey('script_step'); $sets['src_file'] = $request->getValueByKey('src_file'); $sets['csv_delimiter'] = $this->CSV_DELIMITERS[$request->getValueByKey('csv_delimiter')]; $sets['target_ptype'] = $request->getValueByKey('target_ptype'); $sets['target_category'] = $request->getValueByKey('target_category'); $sets['cache_dir'] = $application->getAppIni('PATH_CACHE_DIR').'_import_cache/'; $sets['src_images_dir'] = $request->getValueByKey('src_images_dir'); $sets['autoclear'] = $request->getValueByKey('autoclear')=='Y' ? true : false;*/ CCacheFactory::clearAll(); $sets = array('script_code' => 'Products_CSV_DB', 'script_step' => $request->getValueByKey('script_step'), 'cache_dir' => $application->getAppIni('PATH_CACHE_DIR') . '_import_cache/'); if ($sets['script_step'] == 1) { $sets = array_merge($sets, array('src_file' => $request->getValueByKey('src_file'), 'header_rx' => "/^Product[A-Za-z0-9_]+\$/")); } if ($sets['script_step'] == 2) { $sets = array_merge($sets, array('target_ptype' => $request->getValueByKey('target_ptype'), 'target_category' => $request->getValueByKey('target_category'), 'src_images_dir' => $request->getValueByKey('src_images_dir'), 'src_images_tar' => $request->getValueByKey('src_images_tar'), 'autoclear' => true)); } modApiFunc('Data_Converter', 'initDataConvert', $sets); $_RESULT["errors"] = modApiFunc('Data_Converter', 'getErrors'); $_RESULT["warnings"] = modApiFunc('Data_Converter', 'getWarnings'); $_RESULT["messages"] = modApiFunc('Data_Converter', 'getMessages'); $_RESULT["process_info"] = modApiFunc('Data_Converter', 'getProcessInfo'); break; case 'do': modApiFunc('Data_Converter', 'doDataConvert'); $_RESULT["errors"] = modApiFunc('Data_Converter', 'getErrors'); $_RESULT["warnings"] = modApiFunc('Data_Converter', 'getWarnings'); $_RESULT["messages"] = modApiFunc('Data_Converter', 'getMessages'); $_RESULT["process_info"] = modApiFunc('Data_Converter', 'getProcessInfo'); break; } }
function onAction() { global $application; $request =& $application->getInstance('Request'); $il_target = $request->getValueByKey('il_target'); global $_RESULT; switch ($il_target) { case 'init': // clearing cache CCacheFactory::clearAll(); // : here will come checking if the file is csv or xliff // for now: assuming it is a csv file $sets = array('script_code' => 'Labels_CSV_DB', 'script_step' => $request->getValueByKey('script_step'), 'cache_dir' => $application->getAppIni('PATH_CACHE_DIR') . '_import_cache/'); if ($sets['script_step'] == 1) { $sets['src_file'] = $request->getValueByKey('src_file'); } if ($sets['script_step'] == 2) { $sets['filter'] = array('tt' => array('found' => $request->getValueByKey('tt_found'), 'new' => $request->getValueByKey('tt_new')), 'lang' => array('found' => explode('|', $request->getValueByKey('l_found')), 'new' => explode('|', $request->getValueByKey('l_new'))), 'type' => array('found' => explode('|', $request->getValueByKey('t_found')), 'new' => explode('|', $request->getValueByKey('t_new')))); $sets['autoclear'] = true; $sets['def_lng'] = modApiFunc('MultiLang', 'getDefaultLanguage'); } modApiFunc('Data_Converter', 'initDataConvert', $sets); $_RESULT["errors"] = modApiFunc('Data_Converter', 'getErrors'); $_RESULT["warnings"] = modApiFunc('Data_Converter', 'getWarnings'); $_RESULT["messages"] = modApiFunc('Data_Converter', 'getMessages'); $_RESULT["process_info"] = modApiFunc('Data_Converter', 'getProcessInfo'); break; case 'do': modApiFunc('Data_Converter', 'doDataConvert'); $_RESULT["errors"] = modApiFunc('Data_Converter', 'getErrors'); $_RESULT["warnings"] = modApiFunc('Data_Converter', 'getWarnings'); $_RESULT["messages"] = modApiFunc('Data_Converter', 'getMessages'); $_RESULT["process_info"] = modApiFunc('Data_Converter', 'getProcessInfo'); break; } }
static function writeCSV() { if (!self::$write_csv) { return; } $profiler_dir = CConf::get('cache_dir'); $request_id = substr(md5(microtime(true)), 0, 6); global $zone; $requests_csv = $profiler_dir . 'requests.csv'; self::prepareCSV($requests_csv, array('zone', 'script', 'request')); self::writeCSVRecords($requests_csv, $request_id, array(array($zone == 'AdminZone' ? 'AZ' : 'CZ', $_SERVER['SCRIPT_NAME'], $_SERVER['QUERY_STRING']))); $general_csv = $profiler_dir . 'general.total.csv'; self::prepareCSV($general_csv, self::$profiler->getFields()); self::writeCSVRecords($general_csv, $request_id, array(self::$profiler->getData())); foreach (self::$stack as $key => $p) { $general_csv = $profiler_dir . 'general.' . self::prepareProfilerFileName($key) . '.csv'; self::prepareCSV($general_csv, $p->getFields()); self::writeCSVRecords($general_csv, $request_id, array($p->getData())); } if (self::$display_cache) { $cache_stat = CCacheFactory::getStat('array'); foreach ($cache_stat as $key => $cache_data) { $cache_csv = $profiler_dir . 'cache.' . strtolower($key) . '.csv'; unset($cache_data['storage']['log']); $fields_storage = array_keys($cache_data['storage']); $fields_driver = array_keys($cache_data['driver']); array_walk($fields_storage, 'self::addCacheFieldPrefix', 'storage_'); array_walk($fields_driver, 'self::addCacheFieldPrefix', 'driver_'); self::prepareCSV($cache_csv, array_merge($fields_storage, $fields_driver)); self::writeCSVRecords($cache_csv, $request_id, array(array_merge($cache_data['storage'], $cache_data['driver']))); } } if (self::$display_include) { $include_csv = $profiler_dir . 'include.csv'; self::prepareCSV($include_csv, array('counter', 'file_path')); $records = array(); foreach (self::$profiler->cnt_include as $file => $ctr) { $records[] = array($ctr, $file); } self::writeCSVRecords($include_csv, $request_id, $records); } if (self::$display_queries) { $queries_csv = $profiler_dir . 'queries.csv'; self::prepareCSV($queries_csv, array('total', 'unique', 'executed', 'time_db_layer', 'query_name')); $records = array(); foreach (self::$profiler->cnt_queries_executed as $query => $counter) { if ($counter > 1) { $records[] = array(@$counter['all'], sizeof(@$counter['unique']), @$counter['really'], self::$profiler->timer_db_layer_queries[$query]->getTime(), $query); } } self::writeCSVRecords($queries_csv, $request_id, $records); } if (self::$display_file_io) { $file_io_csv = $profiler_dir . 'file_io.csv'; self::prepareCSV($file_io_csv, array('read', 'write', 'read-write', 'parse', 'test', 'delete', 'file')); $records = array(); foreach (self::$profiler->cnt_file_io as $file => $cntrs) { $records[] = array((int) @$cntrs['read'], (int) @$cntrs['write'], (int) @$cntrs['read-write'], (int) @$cntrs['parse'], (int) @$cntrs['test'], (int) @$cntrs['delete'], $file); } self::writeCSVRecords($file_io_csv, $request_id, $records); } if (self::$display_block_tags) { $block_tags_csv = $profiler_dir . 'block_tags.csv'; self::prepareCSV($block_tags_csv, array('counter', 'time', 'block_tag')); $records = array(); foreach (self::$profiler->timer_block_tags as $block_tag => $time) { $records[] = array($time->getTotalCounter(), $time->getTime(), $block_tag); } self::writeCSVRecords($block_tags_csv, $request_id, $records); } }
function CQueryExecuter() { global $application; $this->cache = CCacheFactory::getCache('database'); }
function __shutdown__() { global $application, $zone; if (class_exists('CProfiler')) { CProfiler::stop('API & Render'); if (CProfiler::isEnabled()) { CTrace::dbg(CProfiler::getProfiler()); } CProfiler::writeCSV(); } if (class_exists('CCacheFactory')) { CCacheFactory::shutdown(); } if (function_exists('error_get_last')) { $error = error_get_last(); if (is_array($error) && in_array($error['type'], array(E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR))) { _fatal($error); // CTrace::err($error); // if(class_exists('EventsManager')) // modApiFunc('EventsManager','throwEvent','ApplicationShutdown'); } } }
/** * Flatten layout data of specified page into 2D KV data * @param $page Page name */ function getPageMap($page) { global $application; $fb = modApiFunc('Look_Feel', 'isFacebook') ? '.fb' : ''; $theme = modApiFunc('Look_Feel', 'getCurrentSkin'); $cache = CCacheFactory::getCache('persistent', 'page_manager'); $cached_map = $cache->read(md5($theme . $page . $fb)); if ($cached_map !== null) { return $cached_map; } $map = array(); $layout = $this->getLayoutTmpl($theme, $page, null, true); foreach ($layout['settings'] as $set) { $map[$set['name']] = $this->_desanitize_tags($set['content']); } foreach ($layout['rows'] as $row) { switch ($row['name']) { case 'header': case 'main_menu': case 'footer': case 'topslideshow': $PHdata = $row['data']['placeholders'][0]['data']; if (empty($PHdata['blocks']) || !is_array($PHdata['blocks'])) { continue; } foreach ($PHdata['blocks'] as $block) { if (empty($block['name'])) { continue; } $map[$block['name']] = ''; if ($block['visibility'] == 'visible' && $PHdata['visibility'] == 'visible') { $InfoBlock = $this->getBlockInfo($block['name'], $page); $map[$block['name']] = $this->_unquote($InfoBlock['template']); } } break; case 'main_content': default: foreach ($row['data']['placeholders'] as $PH) { $map[$PH['name']] = ''; if (empty($PH['data']['visibility']) || $PH['data']['visibility'] != 'visible' || empty($PH['data']['blocks']) || !is_array($PH['data']['blocks'])) { continue; } foreach ($PH['data']['blocks'] as $block) { if ($block['visibility'] == 'visible') { $InfoBlock = $this->getBlockInfo($block['name'], $page); $map[$PH['name']] .= $this->_unquote($InfoBlock['template']); } } } break; } } $cache->write(md5($theme . $page . $fb), $map); return $map; }
/** * Changes the storefront skin */ function changeSkin($skin) { if ($this->checkSkin($skin)) { modApiFunc('Configuration', 'setValue', array(STOREFRONT_ACTIVE_SKIN => $skin)); global $application; $cache = CCacheFactory::getCache('persistent', 'page_manager'); $cache->erase(); return $skin; } return ''; }
/** * Divides cart into orders * Note: currently the function is turned off... */ function buildOrders($throw_event = true) { global $application; $this->CartOrders = array(); // paranoidal check... if (!is_array($this->CartContent)) { modApiFunc('Session', 'set', 'CartOrders', array()); return; } $this->CartOrders[0] = array('Products' => array(), 'Content' => array(), 'Totals' => $this->getInitialTotals(), 'Entry' => 0, 'Lang' => modApiFunc('MultiLang', 'getLanguage'), 'Protocol' => $application->getCurrentProtocol()); $this->CartOrders[0]['Products'] = $this->CartContent; // here we have cart divided... // calculating the order totals... foreach ($this->CartOrders as $k => $v) { $this->buildOrder($k); } // saving the result in the session modApiFunc('Session', 'set', 'CartOrders', $this->CartOrders); $this->buildDetailedCartContent(); $taxes = modApiFunc('Taxes', 'getTax'); foreach ($this->CartOrders as $k => $v) { $this->buildOrderTaxes($k, $taxes); } $this->buildDetailedCartContent(); // saving the result in the session modApiFunc('Session', 'set', 'CartOrders', $this->CartOrders); if ($throw_event) { modApiFunc('EventsManager', 'throwEvent', 'CartChanged'); } $cache = CCacheFactory::getCache('temporary'); $cache->write('cart_content_hash', md5(serialize($this->CartContent))); }
/** * Initializes the session: e.g. retrieves session data from the database. */ function start($sid = "") { global $zone, $application; $drop_session_cookie = false; if ($zone == "AdminZone") { ini_set("session.cookie_lifetime", 0); session_name("AZSESSID"); if ($application->db->DB_isTableExists($application->getAppIni('DB_TABLE_PREFIX') . "settings") != null) { $duration_cfg = (int) modApiFunc("Settings", "getParamValue", "ADMIN_SESSION_DURATION", "ADM_SESSION_DURATION_VALUE"); } else { $duration_cfg = 3600; } $ClientSessionLifetime = $duration_cfg; } else { if (isset($_COOKIE['save_session']) && $_COOKIE['save_session'] == "save") { if ($application->db->DB_isTableExists($application->getAppIni('DB_TABLE_PREFIX') . "settings") != null) { $cz_duration_cfg = (int) modApiFunc("Settings", "getParamValue", "CUSTOMER_ACCOUNT_SETTINGS", "CUSTOMER_SESSION_DURATION_VALUE"); } else { $cz_duration_cfg = 3600 * 24 * 30; //30 days } ini_set("session.cookie_lifetime", $cz_duration_cfg); ini_set("session.gc_maxlifetime", $cz_duration_cfg); } else { ini_set("session.cookie_lifetime", 0); #ini_set("session.gc_maxlifetime", 0); $drop_session_cookie = true; } session_name("CZSESSID"); } if ($sid) { session_id($sid); } $session_save_handler = $application->getAppIni('SESSION_SAVE_HANDLER'); if ($session_save_handler == 'DB') { // redefine session handler __set_session_db_handler(); } elseif ($session_save_handler != 'PHP_INI') { ini_set("session.save_handler", $session_save_handler); } $session_save_path = $application->getAppIni('SESSION_SAVE_PATH'); if ($session_save_path == 'AVACTIS_CACHE_DIR') { session_save_path($application->getAppIni("PATH_CACHE_DIR")); } elseif ($session_save_path != 'PHP_INI') { session_save_path($session_save_path); } session_start(); global $application; $HTTP_URL = md5($application->getAppIni('HTTP_URL')); if (!isset($_COOKIE['HTTP_URL'])) { setcookie('HTTP_URL', $HTTP_URL, time()); } elseif ($_COOKIE['HTTP_URL'] != $HTTP_URL) { setcookie('HTTP_URL', $HTTP_URL, time()); session_destroy(); if ($session_save_handler == 'DB') { // redefine session handler (http://bugs.php.net/bug.php?id=32330) // redefine session handler __set_session_db_handler(); } session_start(); } if ($zone == "CustomerZone") { $sess = session_get_cookie_params(); if ($drop_session_cookie) { $t = 0; } else { $t = time() + $sess['lifetime']; } setcookie(session_name(), session_id(), $t, '/'); if ($application->getCurrentProtocol() == 'http') { $temp_url = $application->getAppIni('SITE_HTTPS_URL'); } else { $temp_url = $application->getAppIni('SITE_URL'); } $temp_url = parse_url($temp_url); if (isset($temp_url['host'])) { setcookie(session_name(), session_id(), $t, '/', $temp_url['host']); } } // // , . // , . // , , . // . // IP . // . // . // $CURRENT_PRODUCT_VERSION = PRODUCT_VERSION; $current_hash = ""; if ($zone != "AdminZone") { loadModuleFile('configuration/const.php'); /*_use(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.'configuration'.DIRECTORY_SEPARATOR.'configuration_api.php'); $tables = Configuration::getTables(); $ss = $tables['store_settings']['columns']; $s = new DB_Select(); $s->addSelectTable('store_settings'); $s->addSelectValue('variable_value','value'); $s->WhereValue($ss['name'], DB_EQ, SYSCONFIG_CHECKOUT_FORM_HASH); $v = $application->db->getDB_Result($s); $current_hash = $v[0]['value'];*/ $cache = CCacheFactory::getCache('hash'); $current_hash = $cache->read(SYSCONFIG_CHECKOUT_FORM_HASH); } $current_ips = getClientIPs(); if (!array_key_exists('PRODUCT_VERSION', $_SESSION) || $_SESSION['PRODUCT_VERSION'] != $CURRENT_PRODUCT_VERSION && $zone != "AdminZone" || (!array_key_exists(SYSCONFIG_CHECKOUT_FORM_HASH, $_SESSION) || $current_hash != $_SESSION[SYSCONFIG_CHECKOUT_FORM_HASH] && $zone != "AdminZone")) { if (!empty($_SESSION['CartContent']) && is_array($_SESSION['CartContent'])) { foreach ($_SESSION['CartContent'] as $cart_id => $cart_content) { modApiFunc('Cart', 'removeGCfromDB', $cart_content['product_id']); } } //see this::session_clean1() session_unset(); session_destroy(); if ($session_save_handler == 'DB') { // redefine session handler (http://bugs.php.net/bug.php?id=32330) // redefine session handler __set_session_db_handler(); } session_start(); } $_SESSION['PRODUCT_VERSION'] = $CURRENT_PRODUCT_VERSION; $_SESSION[SYSCONFIG_CHECKOUT_FORM_HASH] = $current_hash; $_SESSION['REMOTE_ADDR'] = $current_ips; $_SESSION['HTTP_USER_AGENT'] = @$_SERVER['HTTP_USER_AGENT']; // foreach ($_SESSION as $key => $val) { $this->keyvalList[$key] = $val; // $this->set($key, $val); } $this->started = TRUE; if ($zone == "AdminZone") { if (!$this->is_Set('ClientSessionLifetime')) { $this->set('ClientSessionLifetime', time()); } else { $delta_time = time() - $this->get('ClientSessionLifetime'); if ($delta_time > $ClientSessionLifetime && $ClientSessionLifetime != 0) { $this->un_Set('currentUserID'); } $this->set('ClientSessionLifetime', time()); } } }
/** * $this->TaxDebug: * $this->TaxDebug = array( * "ProductsList" => array( * "0" => array( * "ID" => 1, * "Quantity_In_Cart" => 1, * "attributes" => array( * "SalePrice" => array( * "value"=>$CartItemSalePrice * ), * "ShippingPrice" => array( * "value"=>$ShippingPrice * ), * "TaxClass" => array( * "value"=>$ProductTaxClass * ), * ), * "CartItemSalePrice" => $CartItemSalePrice * ) * ), * "AddressesList"=> array( * "1" => array(//ShippingAddress * "CountryId" => $sa_c_id, * "StateId" => $sa_s_id * ), * "2" => array(//CustomerAddress * "CountryId" => $ca_c_id, * "StateId" => $ca_s_id * ), * "3" => array(//BillingAddress * "CountryId" => $ba_c_id, * "StateId" => $ba_s_id * ) * ) * ); */ function getTax($included_only = false, $debug = false, $trace = false, $symbolic = false, $use_default_address_for_not_included_taxes = false) { static $__cache__ = array(); global $application; $cache = CCacheFactory::getCache('temporary'); $cart_content_hash = $cache->read('cart_content_hash'); $__cache_key__ = md5($cart_content_hash . serialize($included_only) . serialize($debug) . serialize($trace) . serialize($symbolic) . serialize($use_default_address_for_not_included_taxes)); if (isset($__cache__[$__cache_key__])) { // disabled due to http://projects.simbirsoft.com/issues/1391 //return $__cache__[$__cache_key__]; } //$fake_parameter_this_tax_debug = $this -> TaxDebug; $currency_id = modApiFunc("Localization", "getMainStoreCurrency"); $TaxNames = modApiFunc("Taxes", "getTaxNames"); if ($debug) { $ProductsList = $this->TaxDebug["ProductsList"]; $CartSubtotal = $this->TaxDebug["CartSubtotal"]; $OrderLevelShippingCost = $this->TaxDebug["OrderLevelShippingCost"]; $TotalShippingCost = $OrderLevelShippingCost; $OrderLevelDiscount = $this->TaxDebug["OrderLevelDiscount"]; $TotalDiscount = $OrderLevelDiscount; foreach ($this->TaxDebug["ProductsList"] as $productInfo) { $TotalShippingCost += $productInfo["Quantity_In_Cart"] * ($productInfo["attributes"]["PerItemShippingCost"]["value"] + $productInfo["attributes"]["PerItemHandlingCost"]["value"]); $TotalDiscount += $productInfo["Quantity_In_Cart"] * $productInfo["PerItemDiscount"]; } $ShippingMethod = $this->TaxDebug["ShippingMethod"]; $AddressesList = $this->TaxDebug["AddressesList"]; } else { $ProductsList = modApiFunc("Cart", "getCartContentExt"); #12.01 $CartSubtotal = modApiFunc("Cart", "getCartSubtotal"); $CartSubtotal = modApiFunc("Cart", "getCartSubtotalExcludingTaxes"); $ShippingMethod = modApiFunc("Checkout", "getChosenShippingModuleIdCZ"); $TotalShippingCost = modApiFunc("Checkout", "getOrderPrice", "TotalShippingAndHandlingCost", $currency_id); $OrderLevelShippingCost = $TotalShippingCost - modApiFunc("Checkout", "getOrderPrice", "PerItemShippingCostSum", $currency_id) - modApiFunc("Checkout", "getOrderPrice", "PerItemHandlingCostSum", $currency_id); if ($OrderLevelShippingCost < 0) { $OrderLevelShippingCost = 0; } $OrderLevelDiscount = COMPUTATION_POSTPONED; $TotalDiscount = COMPUTATION_POSTPONED; $ShippingInfo = modApiFunc("Checkout", "getPrerequisiteValidationResults", "shippingInfo"); $BillingInfo = modApiFunc("Checkout", "getPrerequisiteValidationResults", "billingInfo"); $StoreOwnerInfo = modApiFunc("Checkout", "getPrerequisiteValidationResults", "storeOwnerInfo"); // Checkout::storeOwnerInfo isMet // - storeOwnerInfo - , // ? $store_owner_country = modApiFunc('Configuration', 'getValue', SYSCONFIG_STORE_OWNER_COUNTRY); $store_owner_state = modApiFunc('Configuration', 'getValue', SYSCONFIG_STORE_OWNER_STATE); $b_store_owner_address_correct = is_numeric($store_owner_country) && is_numeric($store_owner_state); $AddressesList = array("0" => !$b_store_owner_address_correct ? null : array("CountryId" => $store_owner_country, "StateId" => $store_owner_state), "1" => $ShippingInfo["isMet"] == false ? !$b_store_owner_address_correct || !$use_default_address_for_not_included_taxes ? null : array("CountryId" => $store_owner_country, "StateId" => $store_owner_state) : array("CountryId" => isset($ShippingInfo["validatedData"]["Country"]["value"]) ? $ShippingInfo["validatedData"]["Country"]["value"] : 0, "StateId" => empty($ShippingInfo["validatedData"]["Statemenu"]["value"]) ? STATE_ID_ALL : $ShippingInfo["validatedData"]["Statemenu"]["value"]), "2" => $BillingInfo["isMet"] == false ? !$b_store_owner_address_correct || !$use_default_address_for_not_included_taxes ? null : array("CountryId" => $store_owner_country, "StateId" => $store_owner_state) : array("CountryId" => isset($BillingInfo["validatedData"]["Country"]["value"]) ? $BillingInfo["validatedData"]["Country"]["value"] : 0, "StateId" => empty($BillingInfo["validatedData"]["Statemenu"]["value"]) ? STATE_ID_ALL : $BillingInfo["validatedData"]["Statemenu"]["value"]), TAXES_STORE_OWNER_ADDRESS_ID . "" => $StoreOwnerInfo["isMet"] == false ? !$b_store_owner_address_correct || !$use_default_address_for_not_included_taxes ? null : array("CountryId" => $store_owner_country, "StateId" => $store_owner_state) : array("CountryId" => isset($StoreOwnerInfo["validatedData"]["Country"]["value"]) ? $StoreOwnerInfo["validatedData"]["Country"]["value"] : 0, "StateId" => empty($StoreOwnerInfo["validatedData"]["Statemenu"]["value"]) ? STATE_ID_ALL : $StoreOwnerInfo["validatedData"]["Statemenu"]["value"])); } if (sizeof($ProductsList) > 0) { #Gets the Product Tax Class array $ProductTaxClassArray = array(); #A products( of each type) array $productsQuantity = array(); foreach ($ProductsList as $ProductInfo) { if (!in_array($ProductInfo["attributes"]["TaxClass"]["value"], $ProductTaxClassArray)) { $ProductTaxClassArray[] = $ProductInfo["attributes"]["TaxClass"]["value"] ? $ProductInfo["attributes"]["TaxClass"]["value"] : 1; } $productsQuantity[$ProductInfo["CartID"]] = $ProductInfo["Quantity_In_Cart"]; } /* if(!in_array(1, $ProductTaxClassArray)) { $ProductTaxClassArray[] = 1; }*/ #Gets an Address array $AddressArray = array("CountryId" => array(), "StateId" => array()); foreach ($AddressesList as $AddressInfo) { if ($AddressInfo) { if (!in_array($AddressInfo["CountryId"], $AddressArray["CountryId"])) { $AddressArray["CountryId"][] = $AddressInfo["CountryId"]; } if (!in_array($AddressInfo["StateId"], $AddressArray["StateId"])) { $AddressArray["StateId"][] = $AddressInfo["StateId"]; } } } if (!in_array((int) 0, $AddressArray["StateId"])) { $AddressArray["StateId"][] = (int) 0; } if (sizeof($AddressArray["CountryId"]) == 0) { $AddressArray["CountryId"][] = (int) 0; } #Gets a list of applicable tax rates $ApplicableTaxes = array(); $TaxRatesList = $this->getApplicableTaxRates($ProductTaxClassArray, $AddressArray); // if ($trace) // { // // $TraceInfo = array( // "ProductList" => $ProductsList // ,"ProductTaxClassArray" => $ProductTaxClassArray // ,"AddressesList" => $AddressesList // ,"TaxRatesList" => $TaxRatesList // ); // $this->addTraceInfo("1", $TraceInfo); // } $Taxes = $this->getTaxes($included_only); foreach ($TaxRatesList as $TaxRateInfo) { if (isset($Taxes[$TaxRateInfo['TaxNameId']])) { $Taxes[$TaxRateInfo['TaxNameId']]["applicable"] = true; } } if ($included_only === true) { // : $TaxRatesList_new = array(); foreach ($TaxRatesList as $TaxRateInfo) { if (isset($Taxes[$TaxRateInfo['TaxNameId']])) { $TaxRatesList_new[] = $TaxRateInfo; } } $TaxRatesList = $TaxRatesList_new; } // if ($trace) // { // $TraceInfo = array( // "TaxesArray" => $Taxes // ); // $this->addTraceInfo("2", $TraceInfo); // } /* $TaxAmounts $TaxAmounts = array( "products" => array( "ProdId1" = array( "TaxId1" => $amount1, "TaxId2" => $amount2, ... ), "ProdId2" = array( "TaxId1" => $amount3, "TaxId2" => $amount4, ... ), ), "TaxSubtotalAmount" = array( "TaxId1" => $amount1 + $amount3 + ..., "TaxId2" => $amount2 + $amount4 + ..., ... ), "TaxSubtotalAmountView" => array(), - Tax Display Options "TaxTotalAmount" => sum(TaxSubtotalAmount) ); */ $thisTaxAmounts = array("products" => array(), "tax_on_shipping" => true, "TaxSubtotalAmount" => array(), "TaxSubtotalAmountView" => array(), "TaxTotalAmount" => (int) PRICE_N_A, "IncludedTaxTotalAmount" => (int) PRICE_N_A); #Calculate the tax foreach ($Taxes as $TaxId => $TaxInfo) { $thisTaxAmounts["TaxSubtotalAmount"][$TaxId] = (int) PRICE_N_A; $retval = $this->calculateTax($thisTaxAmounts, $Taxes, $TaxId, $TaxRatesList, $AddressesList, $ProductsList, $CartSubtotal, $OrderLevelShippingCost, $TotalShippingCost, $ShippingMethod, $OrderLevelDiscount, $TotalDiscount, $currency_id, $debug, $trace, $symbolic, NULL); //$flag); if ($retval == "fatal") { return $thisTaxAmounts; } } $CartIDs = array(); foreach ($ProductsList as $info) { $CartIDs[] = "" . $info['CartID']; } foreach ($thisTaxAmounts["products"] as $prodId => $taxAmountInfo) { //PATCH: : . calculateTax $this->TaxAmounts["products"] // , $ProductsList, . . if (!in_array("" . $prodId, $CartIDs)) { continue; } //print prepareArrayDisplay($prodId); //print prepareArrayDisplay($taxAmountInfo); //$i = 1; //print $i.' '.prepareArrayDisplay($thisTaxAmounts["TaxTotalAmount"]); foreach ($taxAmountInfo as $taxId => $taxAmount) { //$i++; if (is_array($taxAmount)) { continue; } if ($taxAmount == PRICE_N_A) { // $this->TaxAmounts["TaxTotalAmount"] = (int)PRICE_N_A; continue; } if ($thisTaxAmounts["TaxSubtotalAmount"][$taxId] == PRICE_N_A) { $thisTaxAmounts["TaxSubtotalAmount"][$taxId] = 0; } if ($thisTaxAmounts["IncludedTaxTotalAmount"] == PRICE_N_A) { $thisTaxAmounts["IncludedTaxTotalAmount"] = 0; } if ($thisTaxAmounts["TaxTotalAmount"] == PRICE_N_A) { $thisTaxAmounts["TaxTotalAmount"] = 0; } if (!isset($productsQuantity[$prodId])) { } $thisTaxAmounts["TaxSubtotalAmount"][$taxId] += modApiFunc("Localization", "roundMonetaryUnit", $productsQuantity[$prodId] * $taxAmount); if ($TaxNames[$taxId]["included_into_price"] == "true") { $thisTaxAmounts["IncludedTaxTotalAmount"] += modApiFunc("Localization", "roundMonetaryUnit", $productsQuantity[$prodId] * $taxAmount); } $thisTaxAmounts["TaxTotalAmount"] += modApiFunc("Localization", "roundMonetaryUnit", $productsQuantity[$prodId] * $taxAmount); //print $i.' '.prepareArrayDisplay($thisTaxAmounts["TaxTotalAmount"]); } //print prepareArrayDisplay($thisTaxAmounts["TaxTotalAmount"]); } } else { $Taxes = $this->getTaxes(); $TaxSubtotalAmount = array(); foreach ($Taxes as $TaxId => $TaxInfo) { $TaxSubtotalAmount[$TaxId] = (int) PRICE_N_A; } $thisTaxAmounts = array("products" => array(), "tax_on_shipping" => true, "TaxSubtotalAmount" => $TaxSubtotalAmount, "TaxSubtotalAmountView" => array(), "TaxTotalAmount" => (int) PRICE_N_A); } $replace = array(); foreach ($thisTaxAmounts["TaxSubtotalAmount"] as $taxId => $taxAmount) { $replace["{" . $taxId . "}"] = $taxAmount; } $DisplayOptions = $this->getTaxDisplayOptionsList(); // included , // . if ($included_only === true) { $DisplayOptions_new = array(); foreach ($DisplayOptions as $tdo) { if (isset($Taxes[$tdo['Id']])) { $DisplayOptions_new[] = $tdo; } } $DisplayOptions = $DisplayOptions_new; } foreach ($DisplayOptions as $DisplayOptionInfo) { if ($DisplayOptionInfo['tdoId'] != 3) { $_replace = $replace; if ($DisplayOptionInfo['tdoId'] == 1) { foreach ($replace as $taxIdTag => $TaxAmount) { if (!(_ml_strpos($DisplayOptionInfo['Formula'], $taxIdTag) === false) && $TaxAmount != PRICE_N_A) { foreach ($_replace as $taxIdTag => $TaxAmount) { if ($TaxAmount == PRICE_N_A) { $_replace[$taxIdTag] = 0; } } break; } } } $is_included = false; $this_one_is_included = false; foreach ($thisTaxAmounts["TaxSubtotalAmount"] as $taxId => $taxAmount) { if (!(_ml_strpos($DisplayOptionInfo['Formula'], "{" . $taxId . "}") === false)) { $this_one_is_included = $Taxes[$taxId]["included_into_price"]; } } $DisplayOptionInfo['Formula'] = strtr($DisplayOptionInfo['Formula'], $_replace); if (_ml_strpos($DisplayOptionInfo['Formula'], sprintf("%d", PRICE_N_A)) === false) { $TaxAmount = eval("return " . $DisplayOptionInfo['Formula'] . ";"); } else { $TaxAmount = (int) PRICE_N_A; } if (!($TaxAmount == PRICE_N_A && $DisplayOptionInfo['tdoId'] == 2)) { $thisTaxAmounts["TaxSubtotalAmountView"][] = array("id" => $DisplayOptionInfo["Id"], 'view' => prepareHTMLDisplay($DisplayOptionInfo['View']), 'value' => $TaxAmount, "is_included" => $this_one_is_included); } } } $__cache__[$__cache_key__] = $thisTaxAmounts; return $thisTaxAmounts; }
/** * * * @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'); } }
function updateExtensionStatus($extensionName, $status) { execQuery('UPDATE_EXTENSION_STATUS', array('name' => $extensionName, 'active' => $status)); CCacheFactory::clearAll(); }
/** * */ function onAction() { CCacheFactory::clearAll(); modApiFunc("Tools", "RestoreBackup"); }
/** * This function calculates hash from checkout form fields array. * @author Andrei V. Zhuravlev * */ function updateCheckoutFormHash() { global $application; $tables = $this->getTables(); $pa = $tables['person_attributes']['columns']; $piva = $tables['person_info_variants_to_attributes']['columns']; $s = new DB_Select(); $s->addSelectTable('person_attributes'); $s->addSelectTable('person_info_variants_to_attributes'); $s->WhereField($piva['attribute_id'], DB_EQ, $pa['id']); $checkout_data = $application->db->getDB_Result($s); //query fields $hash = md5(serialize($checkout_data)); /*$tables = Configuration::getTables(); $ss = $tables['store_settings']['columns']; $u = new DB_Update('store_settings'); $u->addUpdateValue('variable_value',$hash); $u->WhereValue('variable_name', DB_EQ, SYSCONFIG_CHECKOUT_FORM_HASH); $application->db->getDB_Result($u);*/ $cache = CCacheFactory::getCache('hash'); $cache->write(SYSCONFIG_CHECKOUT_FORM_HASH, $hash); return $hash; }
function CSV_Dynamic_Writer($uid) { $this->__uid = md5($uid); $this->__cache = CCacheFactory::getCache('persistent', $this->__uid); if (null === ($this->__csv_headers = $this->__cache->read('headers'))) { $this->__csv_headers = array(); } if (null === ($this->__counter = $this->__cache->read('counter'))) { $this->__counter = 1; } $this->csv_delimitr = ';'; }