function load_configuration() { // allow there to be a local config file (as it were). $ini_files = ['survey.ini.php', 'survey.ini.local.php']; foreach ($ini_files as $file) { $ini_file = dirname(__FILE__) . '/../' . $file; //Load values from .ini. file if (file_exists($ini_file)) { $config = parse_ini_file($ini_file); foreach ($config as $key => $value) { $this->CONF[$key] = $value; } } } //Version of Survey System $this->CONF['version'] = 'v1.9.1'; $this->CONF['path'] = dirname(__FILE__) . '/../'; if (empty($this->CONF)) { die("No configuration found; Check survey.ini.php and/or survey.ini.local.php"); } //Ensure install.php file has be removed if (!isset($this->CONF['skip_install_warning']) && !isset($_REQUEST['config_submit']) && file_exists('install.php')) { $this->error("WARNING: install.php file still exists. Survey System will not run with this file present. Click <a href=\"install.php\">here</a> to run the installation program or move/rename the install.php file so that the installation program can not be re-run."); return; } //Create Smarty object and set //paths within object $this->smarty = new SmartyBC(); $this->smarty->template_dir = dirname(__FILE__) . '/../templates/'; $this->smarty->compile_dir = dirname(__FILE__) . '/../templates_c/'; // name of directory for compiled templates if (!is_writeable($this->smarty->compile_dir)) { $this->smarty->compile_dir = sys_get_temp_dir(); } if (!$this->set_template_paths($this->CONF['default_template'])) { $this->error("WARNING: Cannot find default template path. Expecting: {$this->CONF['template_path']}"); return; } //If SAFE_MODE is ON in PHP, turn off subdirectory use for Smarty if (ini_get('safe_mode')) { $this->smarty->use_sub_dirs = FALSE; } //Establish Connection to database $this->db = NewADOConnection($this->CONF['db_type']); $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; $conn = $this->db->Connect($this->CONF['db_host'], $this->CONF['db_user'], $this->CONF['db_password'], $this->CONF['db_database']); if (!$conn) { $this->error('Error connecting to database: ' . $this->db->ErrorMsg()); return; } $this->CONF['orientation'] = array('Vertical', 'Horizontal', 'Dropdown', 'Matrix'); $this->CONF['text_modes'] = array('Text Only', 'Limited HTML', 'Full HTML'); $this->CONF['dependency_modes'] = array('Hide', 'Require', 'Show'); //Validate and set default survey and user text modes $this->CONF['survey_text_mode'] = (int) $this->CONF['survey_text_mode']; if ($this->CONF['survey_text_mode'] < 0 || $this->CONF['survey_text_mode'] > 2) { $this->CONF['survey_text_mode'] = 0; } $this->CONF['user_text_mode'] = (int) $this->CONF['user_text_mode']; if ($this->CONF['user_text_mode'] < 0 || $this->CONF['user_text_mode'] > 2) { $this->CONF['user_text_mode'] = 0; } if (strcasecmp($this->CONF['create_access'], 'public') == 0) { $this->CONF['create_access'] = 0; } else { $this->CONF['create_access'] = 1; } if (isset($_SESSION['priv'][0][ADMIN_PRIV])) { $this->CONF['show_admin_link'] = 1; } //Create SafeString object for escaping user text require $this->CONF['path'] . '/classes/safestring.class.php'; $this->SfStr = new SafeString($this->CONF['db_type'], $this->CONF['charset']); $this->SfStr->setHTML($this->CONF['html']); $this->SfStr->setImagesHTML($this->CONF['images_html']); //Assign configuration values to template $this->smarty->assign_by_ref('conf', $this->CONF); return; }