Exemplo n.º 1
0
	public function init($pathIniFileUser = null, $pathIniFileGlobal = null)
	{
		if(is_null($pathIniFileGlobal))
		{
			$pathIniFileGlobal = PIWIK_USER_PATH . '/config/global.ini.php'; 
		}
		$this->configGlobal = _parse_ini_file($pathIniFileGlobal, true);

		if(is_null($pathIniFileUser))
		{
			$pathIniFileUser = PIWIK_USER_PATH . '/config/config.ini.php'; 
		}
		$this->configUser = _parse_ini_file($pathIniFileUser, true);
		if($this->configUser)
		{
			foreach($this->configUser as $section => &$sectionValues)
			{ 
				foreach($sectionValues as $name => &$value)
				{
					if(is_array($value)) 
					{
						$value = array_map("html_entity_decode", $value);
					} 
					else 
					{
						$value = html_entity_decode($value);
					}
				}
			}
		}
		$this->initialized = true;
	}
 /**
  *
  */
 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");
 }
Exemplo n.º 3
0
 /**
  * Load ini file configuration
  *
  * Derived from Zend_Config_Ini->_loadIniFile() and Zend_Config_Ini->_parseIniFile()
  * @license New BSD License
  *
  * @param string $filename
  * @return array
  */
 protected function _loadIniFile($filename)
 {
     set_error_handler(array($this, '_parseFileErrorHandler'));
     $iniArray = _parse_ini_file($filename, true);
     restore_error_handler();
     // Check if there was an error while loading the file
     if ($this->_loadFileErrorStr !== null) {
         throw new Zend_Config_Exception($this->_loadFileErrorStr);
     }
     return $iniArray;
 }
Exemplo n.º 4
0
 /**
  *
  *
  * @param
  * @return
  */
 function getHTTPSSettings()
 {
     global $application;
     $settings = array("URLS" => array("HTTPS_URL" => ""), "SECURE_SECTIONS" => array("AllAdminArea" => false, "SignIn_AdminMembers" => false, "Orders_Customers" => false, "Payment_Shipping" => false));
     $https_config_file = $application->getAppIni('PATH_CONF_DIR') . 'https_config.php';
     if (file_exists($https_config_file)) {
         $_settings = @_parse_ini_file($https_config_file, true);
         if (is_array($_settings)) {
             $settings = $_settings;
         }
     }
     return $settings;
 }
Exemplo n.º 5
0
 /**
  *
  */
 function outputBackupFilesList()
 {
     if (_ml_strtoupper(_ml_substr(PHP_OS, 0, 3)) === 'WIN') {
         $retval = modApiFunc('TmplFiller', 'fill', "tools/backup/", "item_win_os.tpl.html", array());
         return $retval;
     }
     global $application;
     $retval = "";
     $directory = $application->getAppIni('PATH_SYSTEM_DIR') . "backup/";
     $n = 0;
     $backup_list = array();
     if ($dir = dir($directory)) {
         while ($file = $dir->read()) {
             if (_ml_substr($file, _ml_strrpos($file, '.') + 1) == "abi") {
                 $backup_file_name = _ml_substr($file, 0, _ml_strrpos($file, '.'));
                 if (file_exists($directory . $backup_file_name . ".tar.gz")) {
                     $backup_info = _parse_ini_file($directory . $backup_file_name . ".abi");
                     if (isset($backup_info["asc_version"]) && $backup_info["asc_version"] == PRODUCT_VERSION_NUMBER) {
                         $request = new Request();
                         $request->setView('Downdoad');
                         $request->setKey('directory', 'backup');
                         $request->setKey('file', $backup_file_name . ".tar.gz");
                         $DownloadLink = $request->getURL();
                         $request = new Request();
                         $request->setView('AdminBackup');
                         $request->setAction('BackupDeleteAction');
                         $request->setKey('file', $backup_file_name);
                         $DeleteFormAction = $request->getURL();
                         $this->_Template_Contents = array('BackupFileName' => $backup_file_name, 'DownloadLink' => $DownloadLink, 'InfoLink' => "", 'BackupFileDate' => modApiFunc("Localization", "timestamp_date_format", $backup_info['backup_date']) . " " . modApiFunc("Localization", "timestamp_time_format", $backup_info['backup_date']), 'BackupFileSize' => modApiFunc("Localization", "num_format", $backup_info['backup_file_size'] / 1024) . " Kb", 'N' => $n);
                         $backup_list[] = $this->_Template_Contents;
                         $n++;
                     }
                 }
             }
         }
         $dir->close();
     }
     for ($i = sizeof($backup_list) - 1; $i >= 0; $i--) {
         $this->_Template_Contents = $backup_list[$i];
         $application->registerAttributes($this->_Template_Contents);
         $retval .= modApiFunc('TmplFiller', 'fill', "tools/backup/", "item.tpl.html", array());
     }
     if ($n == 0) {
         $retval .= modApiFunc('TmplFiller', 'fill', "tools/backup/", "item_na.tpl.html", array());
     }
     $retval .= modApiFunc('TmplFiller', 'fill', "tools/backup/", "item_empty.tpl.html", array());
     return $retval;
 }
 /**
  *
  */
 function output()
 {
     global $application;
     $request = new Request();
     $request->setView('AdminBackupInfo');
     $request->setAction('UpdateBackupInfo');
     $FormAction = $request->getURL();
     $backup_name = modApiFunc("Tools", "getCurrentBackupFile");
     $backup_dir = $application->getAppIni('PATH_BACKUP_DIR');
     $backup_info = _parse_ini_file($backup_dir . $backup_name . "/info/backup.ini");
     $log_file_content = @file_get_contents($backup_dir . $backup_name . "/info/backup.log");
     //        $txt_file_content = @file_get_contents($backup_dir.$backup_name."/info/backup.txt");
     $template_contents = array('FormAction' => $FormAction, 'BackupName' => $backup_name, 'BackupSQLSize' => modApiFunc("Localization", "num_format", $backup_info['sql_file_size'] / 1024) . " Kb", 'BackupImgSize' => modApiFunc("Localization", "num_format", $backup_info['img_dir_size'] / 1024) . " Kb", 'BackupCreationDate' => modApiFunc("Localization", "timestamp_date_format", $backup_info['backup_start_time']), 'BackupCreationStartTime' => modApiFunc("Localization", "timestamp_time_format", $backup_info['backup_start_time']), 'BackupCreationFinishTime' => modApiFunc("Localization", "timestamp_time_format", $backup_info['backup_end_time']), 'History' => $log_file_content, 'Comments' => "", 'CommentsHash' => "", 'ResultMessage' => $this->outputResultMessage());
     $this->_Template_Contents = $template_contents;
     $application->registerAttributes($this->_Template_Contents);
     return modApiFunc('TmplFiller', 'fill', "tools/backup_info/", "container.tpl.html", array());
 }
Exemplo n.º 7
0
 public function test_checkThatConfigurationValuesAreProductionValues()
 {
     $this->globalConfig = _parse_ini_file(PIWIK_PATH_TEST_TO_ROOT . '/config/global.ini.php', true);
     //    	var_dump($globalConfig);
     $this->checkEqual(array('Debug' => 'always_archive_data_day'), '0');
     $this->checkEqual(array('Debug' => 'always_archive_data_period'), '0');
     $this->checkEqual(array('Debug' => 'enable_sql_profiler'), '0');
     $this->checkEqual(array('General' => 'time_before_today_archive_considered_outdated'), '10');
     $this->checkEqual(array('General' => 'enable_browser_archiving_triggering'), '1');
     $this->checkEqual(array('General' => 'default_language'), 'en');
     $this->checkEqual(array('Tracker' => 'record_statistics'), '1');
     $this->checkEqual(array('Tracker' => 'visit_standard_length'), '1800');
     $this->checkEqual(array('Tracker' => 'trust_visitors_cookies'), '0');
     // logging messages are disabled
     $this->checkEqual(array('log' => 'logger_message'), '');
     $this->checkEqual(array('log' => 'logger_exception'), array('screen'));
     $this->checkEqual(array('log' => 'logger_error'), array('screen'));
     $this->checkEqual(array('log' => 'logger_api_call'), null);
 }
Exemplo n.º 8
0
function ini_read($filename)
{
    $ini = _parse_ini_file($filename);
    return $ini;
}
Exemplo n.º 9
0
 public function dropDatabase($dbName = null)
 {
     $dbName = $dbName ?: $this->dbName ?: Config::getInstance()->database_tests['dbname'];
     $this->log("Dropping database '{$dbName}'...");
     $config = _parse_ini_file(PIWIK_INCLUDE_PATH . '/config/config.ini.php', true);
     $originalDbName = $config['database']['dbname'];
     if ($dbName == $originalDbName && $dbName != 'piwik_tests') {
         // santity check
         throw new \Exception("Trying to drop original database '{$originalDbName}'. Something's wrong w/ the tests.");
     }
     DbHelper::dropDatabase($dbName);
 }
Exemplo n.º 10
0
 /**
  *
  *
  * @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');
     }
 }
Exemplo n.º 11
0
 /**
  * Read configuration from files into memory
  *
  * @throws Exception if local config file is not readable; exits for other errors
  */
 public function init()
 {
     $this->initialized = true;
     $reportError = !empty($GLOBALS['PIWIK_TRACKER_MODE']);
     // read defaults from global.ini.php
     if (!is_readable($this->pathGlobal) && $reportError) {
         Piwik_ExitWithMessage(Piwik::translate('General_ExceptionConfigurationFileNotFound', array($this->pathGlobal)));
     }
     $this->configGlobal = _parse_ini_file($this->pathGlobal, true);
     if (empty($this->configGlobal) && $reportError) {
         Piwik_ExitWithMessage(Piwik::translate('General_ExceptionUnreadableFileDisabledMethod', array($this->pathGlobal, "parse_ini_file()")));
     }
     $this->configCommon = _parse_ini_file($this->pathCommon, true);
     if ($reportError) {
         $this->checkLocalConfigFound();
     }
     $this->configLocal = _parse_ini_file($this->pathLocal, true);
     if (empty($this->configLocal) && $reportError) {
         Piwik_ExitWithMessage(Piwik::translate('General_ExceptionUnreadableFileDisabledMethod', array($this->pathLocal, "parse_ini_file()")));
     }
 }
Exemplo n.º 12
0
 /**
  * Read configuration from files into memory
  *
  * @throws Exception if local config file is not readable; exits for other errors
  */
 public function init()
 {
     $this->initialized = true;
     // read defaults from global.ini.php
     if (!is_readable($this->pathGlobal)) {
         Piwik_ExitWithMessage(Piwik_TranslateException('General_ExceptionConfigurationFileNotFound', array($this->pathGlobal)));
     }
     $this->configGlobal = _parse_ini_file($this->pathGlobal, true);
     if (empty($this->configGlobal)) {
         Piwik_ExitWithMessage(Piwik_TranslateException('General_ExceptionUnreadableFileDisabledMethod', array($this->pathGlobal, "parse_ini_file()")));
     }
     // read the local settings from config.ini.php
     if (!is_readable($this->pathLocal)) {
         throw new Exception(Piwik_TranslateException('General_ExceptionConfigurationFileNotFound', array($this->pathLocal)));
     }
     $this->configLocal = _parse_ini_file($this->pathLocal, true);
     if (empty($this->configLocal)) {
         Piwik_ExitWithMessage(Piwik_TranslateException('General_ExceptionUnreadableFileDisabledMethod', array($this->pathLocal, "parse_ini_file()")));
     }
 }
Exemplo n.º 13
0
 public function setUp()
 {
     $this->globalConfig = _parse_ini_file(PIWIK_PATH_TEST_TO_ROOT . '/config/global.ini.php', true);
     parent::setUp();
 }
 /**
  * loads resource strings from file
  *
  */
 function loadResFromFile($filename = "", $zone = "CustomerZone")
 {
     global $application;
     $lang = _ml_strtolower($application->getAppIni('LANGUAGE'));
     if (file_exists($filename) && $filename != "") {
         $full_filename = $filename;
         $this->file_messages = _parse_ini_file($full_filename);
     } else {
         if ($filename == "") {
             $path = $application->getAppIni('PATH_ADMIN_RESOURCES');
             $filename = 'system-messages-' . $lang . '.ini';
         } elseif ($zone == "CustomerZone") {
             $filename .= '.ini';
             $path = getTemplateDirAbsolutePath('resources/');
         } else {
             $path = $application->getAppIni('PATH_ADMIN_RESOURCES');
             $filename = $filename . '-' . $lang . '.ini';
         }
         $full_filename = $path . $filename;
         if (@file_exists($full_filename)) {
             $this->file_messages = _parse_ini_file($full_filename);
         } else {
             $this->file_messages = _parse_ini_file($path . "system-messages-eng.ini");
         }
     }
 }
Exemplo n.º 15
0
 /**
  * Constructor.
  *
  * Create new JsHttpRequest backend object and attach it
  * to script output buffer. As a result - script will always return
  * correct JavaScript code, even in case of fatal errors.
  *
  * QUERY_STRING is in form of: PHPSESSID=<sid>&a=aaa&b=bbb&JsHttpRequest=<id>-<loader>
  * where <id> is a request ID, <loader> is a loader name, <sid> - a session ID (if present),
  * PHPSESSID - session parameter name (by default = "PHPSESSID").
  *
  * If an object is created WITHOUT an active AJAX query, it is simply marked as
  * non-active. Use statuc method isActive() to check.
  */
 function JsHttpRequest($enc = '', $admin_zone = true)
 {
     global $JsHttpRequest_Active;
     // getting the page charset
     if (!$enc) {
         $system_folder = dirname(dirname(__FILE__));
         include_once $system_folder . '/core/conf.php';
         include_once $system_folder . '/core/functions.php';
         include_once $system_folder . '/core/bootstrap.php';
         include_once $system_folder . '/core/const.php';
         include_once $system_folder . '/core/ctimer.php';
         include_once $system_folder . '/core/profiler.php';
         include_once $system_folder . '/core/cfile.php';
         include_once $system_folder . '/core/trace.php';
         include_once $system_folder . '/core/tracefilter.php';
         include_once $system_folder . '/core/tracelogrotation.php';
         include_once $system_folder . '/core/tracewriter.php';
         $ini_array = @_parse_ini_file($system_folder . '/config.def.php');
         if ($admin_zone) {
             $enc = $ini_array['ADMIN_ZONE_CHARSET'];
         } else {
             $enc = $ini_array['STOREFRONT_CHARSET'];
         }
     }
     // Parse QUERY_STRING.
     if (preg_match('/^(.*)(?:&|^)JsHttpRequest=(?:(\\d+)-)?([^&]+)((?:&|$).*)$/s', @$_SERVER['QUERY_STRING'], $m)) {
         $this->ID = $m[2];
         $this->LOADER = strtolower($m[3]);
         $_SERVER['QUERY_STRING'] = preg_replace('/^&+|&+$/s', '', preg_replace('/(^|&)' . session_name() . '=[^&]*&?/s', '&', $m[1] . $m[4]));
         unset($_GET['JsHttpRequest'], $_REQUEST['JsHttpRequest'], $_GET[session_name()], $_POST[session_name()], $_REQUEST[session_name()]);
         // Detect Unicode conversion method.
         $this->_unicodeConvMethod = function_exists('mb_convert_encoding') ? 'mb' : (function_exists('iconv') ? 'iconv' : null);
         // Fill an emergency buffer. We erase it at the first line of OB processor
         // to free some memory. This memory may be used on memory_limit error.
         $this->_emergBuffer = str_repeat('a', 1024 * 200);
         // Intercept fatal errors via display_errors (seems it is the only way).
         $this->_uniqHash = md5('JsHttpRequest' . microtime() . getmypid());
         $this->_prevDisplayErrors = ini_get('display_errors');
         @ini_set('display_errors', $this->_magic);
         //
         @ini_set('error_prepend_string', $this->_uniqHash . ini_get('error_prepend_string'));
         @ini_set('error_append_string', ini_get('error_append_string') . $this->_uniqHash);
         // Start OB handling early.
         ob_start(array(&$this, "_obHandler"));
         $JsHttpRequest_Active = false;
         // Set up the encoding.
         $this->setEncoding($enc);
         // Check if headers are already sent (see Content-Type library usage).
         // If true - generate a debug message and exit.
         $file = $line = null;
         $headersSent = version_compare(PHP_VERSION, "4.3.0") < 0 ? headers_sent() : headers_sent($file, $line);
         if ($headersSent) {
             trigger_error("HTTP headers are already sent" . ($line !== null ? " in {$file} on line {$line}" : " somewhere in the script") . ". " . "Possibly you have an extra space (or a newline) before the first line of the script or any library. " . "Please note that JsHttpRequest uses its own Content-Type header and fails if " . "this header cannot be set. See header() function documentation for more details", E_USER_ERROR);
             exit;
         }
     } else {
         $this->ID = 0;
         $this->LOADER = 'unknown';
         $JsHttpRequest_Active = false;
     }
 }
Exemplo n.º 16
0
function _parse_cz_layout_ini_file($filename, $process_sections = false)
{
    global $application;
    $ini_cache = $application->getIniCache();
    $ini_mtime = @filemtime($filename);
    if ($ini_mtime == $ini_cache->read($filename . '-mtime')) {
        $layout_array = $ini_cache->read($filename);
    } else {
        $layout_array = _parse_ini_file($filename, $process_sections);
        $ini_cache->write($filename . '-mtime', $ini_mtime);
        $ini_cache->write($filename, $layout_array);
    }
    $layout_array = LayoutConfigurationManager::add_https_settings($layout_array, $filename);
    return $layout_array;
}
Exemplo n.º 17
0
 /**
  * Read configuration from files into memory
  *
  * @throws Exception if local config file is not readable; exits for other errors
  */
 public function init()
 {
     $this->initialized = true;
     $reportError = SettingsServer::isTrackerApiRequest();
     // read defaults from global.ini.php
     if (!is_readable($this->pathGlobal) && $reportError) {
         Piwik_ExitWithMessage(Piwik::translate('General_ExceptionConfigurationFileNotFound', array($this->pathGlobal)));
     }
     $this->configGlobal = _parse_ini_file($this->pathGlobal, true);
     if (empty($this->configGlobal) && $reportError) {
         Piwik_ExitWithMessage(Piwik::translate('General_ExceptionUnreadableFileDisabledMethod', array($this->pathGlobal, "parse_ini_file()")));
     }
     $this->configCommon = _parse_ini_file($this->pathCommon, true);
     // Check config.ini.php last
     $this->checkLocalConfigFound();
     $this->configLocal = _parse_ini_file($this->pathLocal, true);
     if (empty($this->configLocal) && $reportError) {
         Piwik_ExitWithMessage(Piwik::translate('General_ExceptionUnreadableFileDisabledMethod', array($this->pathLocal, "parse_ini_file()")));
     }
 }
Exemplo n.º 18
0
 function addResourceIniToDB($path, $shortname, $module_name, $flag)
 {
     if (!file_exists($path)) {
         _fatal("Tried to upload not existing meta via path '{$path}', shortname '{$shortname}', module_name '{$module_name}', flag '{$flag}'!");
     }
     $data = _parse_ini_file($path);
     if (!is_array($data) || empty($data)) {
         return false;
     }
     $meta_id = $this->addMetaToDB(array('filename' => basename($path), 'shortname' => $shortname, 'module' => $module_name, 'flag' => $flag, 'md5' => md5_file($path)));
     //============================
     // multiple insert, possible bugs
     return $this->addLabelsArrayToDB($data, $shortname);
     //============================
     //============================
     // insert in foreach, slow but always true
     //        foreach ($data as $key => $value)
     //        {
     //            $this->addLabelToDB($key, $value, $prefix);
     //        }
     //============================
 }
Exemplo n.º 19
0
 function removeDirectory($directory, $start_time)
 {
     if ($dir = @dir($directory)) {
         if ($this->DeletedImgQty === NULL) {
             $this->DeletedImgQty = 0;
             $backupInfo = @_parse_ini_file($directory . "info/backup.ini");
             $this->ImgQtyTotal = $backupInfo["img_files_qty"] + 3;
         }
         while ($file = $dir->read()) {
             if (time() - $start_time >= 5) {
                 $dir->close();
                 $this->SaveState();
                 return;
             }
             if (!is_dir($directory . $file)) {
                 @unlink($directory . $file);
                 $this->DeletedImgQty++;
             } elseif ($file != "." && $file != "..") {
                 $this->removeDirectory($directory . $file . "/", $start_time);
             }
         }
         $dir->close();
     }
     @rmdir($directory);
     $this->SaveState();
 }
Exemplo n.º 20
0
 /**
  *  appendToLocalConfig
  *
  *  Reads another config file and appends the contents to the existing
  *  local config
  *
  *  @param string   $pathLocal path to the config file to be appended
  *  @return void
  */
 public function appendToLocalConfig($pathLocal)
 {
     $temp = _parse_ini_file($pathLocal, true);
     $this->configLocal = array_merge($this->configLocal, $temp);
 }