Esempio n. 1
0
	public function edit() 
	{
		$server_type = $this->uri->segment(5);
	
		if ($this->input->post('submit'))
		{
			//echo '<pre>'; print_r($_POST); die();
		
			unset($_POST['server_type'], $_POST['submit']);
		
			if (write_db_config(array($server_type => $_POST)) == TRUE)
			{
				Template::set_message('Your settings were successfully saved.', 'success');
			} else 
			{
				Template::set_message('There was an error saving the settings.', 'error');
			}
		}
		
		$settings = read_db_config($server_type);
		
		Template::set('db_settings', $settings[$server_type]);
	
		Template::set('server_type', $server_type);
		Template::render();
	}
Esempio n. 2
0
 public function edit()
 {
     $this->load->library('form_validation');
     $server_type = $this->uri->segment(5);
     if ($this->input->post('submit')) {
         $this->form_validation->set_rules('server_type', lang('db_server_type'), 'required|trim|max_length[20]|xss_clean');
         $this->form_validation->set_rules('hostname', lang('db_hostname'), 'required|trim|max_length[120]|xss_clean');
         $this->form_validation->set_rules('database', lang('db_dbname'), 'required|trim|max_length[120]|xss_clean');
         $this->form_validation->set_rules('username', lang('bf_username'), 'trim|xss_clean');
         $this->form_validation->set_rules('password', lang('bf_password'), 'trim|xss_clean');
         if ($this->form_validation->run() !== FALSE) {
             unset($_POST['server_type'], $_POST['submit']);
             if (write_db_config(array($server_type => $_POST)) == TRUE) {
                 Template::set_message(lang('db_successful_save'), 'success');
                 $this->activity_model->log_activity($this->auth->user_id(), $server_type . ' : ' . lang('db_successful_save_act'), 'database');
             } else {
                 Template::set_message(lang('db_erroneous_save'), 'error');
                 $this->activity_model->log_activity($this->auth->user_id(), $server_type . ' : ' . lang('db_erroneous_save_act'), 'database');
             }
         }
     }
     $settings = read_db_config($server_type);
     if (!empty($settings)) {
         Template::set('db_settings', $settings[$server_type]);
     }
     Template::set('server_type', $server_type);
     Template::render();
 }
Esempio n. 3
0
         echo _('db_configuration');
         echo "<form action=\"{$PHP_SELF}?session={$session}\" method=\"POST\">\n";
         echo "Server :";
         echo '<INPUT type="text" value="localhost" name="dbserver"><br>';
         echo "Database name :";
         echo '<INPUT type="text" value="db_conges" name="dbdb"><br>';
         echo "\n User : "******"text" value="conges" name="dbuser"><br>';
         echo "\n Password : "******"password" name="dbpasswd"><br>';
         echo "<INPUT type=\"hidden\" value=\"" . $lang . "\" name=\"lang\"><br>";
         echo "<br>\n";
         echo "<input type=\"submit\" value=\"OK\">\n";
         echo "</form>\n";
     } else {
         $is_dbconf_ok = write_db_config($dbserver, $dbuser, $dbpasswd, $dbdb);
         if ($is_dbconf_ok != true) {
             echo "le dossier " . CONFIG_PATH . " n'est pas accessible en écriture";
         } else {
             echo _('db_configuration_ok');
             echo "<br><a href=\"{$PHP_SELF}?session={$session}&lang={$lang}\"> continuez....</a><br>\n";
         }
     }
     bottom();
 } else {
     $installed_version = get_installed_version($DEBUG);
     if ($installed_version == 0) {
         install($lang, $DEBUG);
     } else {
         // on compare la version déclarée dans la database avec la version déclarée dans le fichier de config
         if ($installed_version != $config_php_conges_version) {
Esempio n. 4
0
 public function index()
 {
     $this->load->library('form_validation');
     $this->form_validation->CI =& $this;
     $this->form_validation->set_rules('environment', lang('in_environment'), 'required|trim|strip_tags|xss_clean');
     $this->form_validation->set_rules('hostname', lang('in_host'), 'required|trim|strip_tags|xss_clean');
     $this->form_validation->set_rules('username', lang('bf_username'), 'required|trim|strip_tags|xss_clean');
     $this->form_validation->set_rules('database', lang('in_database'), 'required|trim|strip_tags|xss_clean');
     $this->form_validation->set_rules('db_prefix', lang('in_prefix'), 'trim|strip_tags|xss_clean');
     $this->startup_check();
     if ($this->form_validation->run() !== false) {
         // Write the database config files
         $this->load->helper('config_file');
         $dbname = strip_tags($this->input->post('database'));
         // get the chosen environment
         $environment = strip_tags($this->input->post('environment'));
         $data = array('main' => array('hostname' => strip_tags($this->input->post('hostname')), 'username' => strip_tags($this->input->post('username')), 'password' => strip_tags($this->input->post('password')), 'database' => $dbname, 'dbprefix' => strip_tags($this->input->post('db_prefix'))), $environment => array('hostname' => strip_tags($this->input->post('hostname')), 'username' => strip_tags($this->input->post('username')), 'password' => strip_tags($this->input->post('password')), 'database' => $dbname, 'dbprefix' => strip_tags($this->input->post('db_prefix'))));
         if (write_db_config($data)) {
             //
             // Make sure the database exists, otherwise create it.
             // CRAP! dbutil and database_forge require a running database driver,
             // which seems to require a valid database, which we don't have. To get
             // past this, we'll deal only with MySQL for now and create things
             // the old fashioned way. Eventually, we'll make this more generic.
             //
             $db = @mysql_connect(strip_tags($this->input->post('hostname')), strip_tags($this->input->post('username')), strip_tags($this->input->post('password')));
             if (!$db) {
                 Template::set_message('Unable to connect to database: ' . mysql_error(), 'error');
             } else {
                 $db_selected = mysql_select_db($dbname, $db);
                 if (!$db_selected) {
                     // Table doesn't exist, so create it.
                     if (!mysql_query("CREATE DATABASE {$dbname}", $db)) {
                         die('Unable to create database: ' . mysql_error());
                     }
                     mysql_close($db);
                 }
                 redirect('install/account');
             }
         } else {
             Template::set_message('There was an error saving the settings. Please verify that your database and ' . $environment . '/database config files are writeable.', 'attention');
         }
     }
     Template::render();
 }
Esempio n. 5
0
 private function setup()
 {
     // Save the DB details
     $data = $this->session->userdata("db_data");
     $environment = $data['environment'];
     unset($data['environment']);
     $this->load->helper('config_file');
     write_db_config($data);
     if (is_writeable(FCPATH . $this->bonfire_app_path . 'config/')) {
         // Database
         copy(FCPATH . $this->bonfire_app_path . 'config/database.php', FCPATH . $this->bonfire_app_path . 'config/' . $environment . '/database.php');
     }
     $server = $data['main']['hostname'];
     $username = $data['main']['username'];
     $password = $data['main']['password'];
     $database = $data['main']['database'];
     $dbprefix = $data['main']['dbprefix'];
     if (!($this->db = mysql_connect($server, $username, $password))) {
         return array('status' => FALSE, 'message' => lang('in_db_no_connect'));
     }
     // use the entered Database settings to connect before calling the Migrations
     $dsn = 'mysql://' . $username . ':' . $password . '@' . $server . '/' . $database . '?dbprefix=' . $dbprefix . '&db_debug=TRUE';
     $this->load->database($dsn);
     //
     // Now install the database tables.
     //
     $this->load->library('Migrations');
     if (!$this->migrations->install()) {
         $this->errors = $this->migrations->error;
         return false;
     }
     // get the list of custom modules in the main application
     $module_list = $this->get_module_versions();
     if (is_array($module_list) && count($module_list)) {
         foreach ($module_list as $module_name => $module_detail) {
             // install the migrations for the custom modules
             if (!$this->migrations->install($module_name . '_')) {
                 $this->errors = $this->migrations->error;
                 return false;
             }
         }
     }
     //
     // Save the information to the settings table
     //
     $settings = array('site.title' => $this->input->post('site_title'), 'site.system_email' => $this->input->post('email'), 'updates.do_check' => $this->curl_update, 'updates.bleeding_edge' => $this->curl_update);
     foreach ($settings as $key => $value) {
         $setting_rec = array('name' => $key, 'module' => 'core', 'value' => $value);
         $this->db->where('name', $key);
         if ($this->db->update('settings', $setting_rec) == false) {
             $this->errors = lang('in_db_settings_error');
             return false;
         }
     }
     //
     // Install the user in the users table so they can actually login.
     //
     $data = array('role_id' => 1, 'email' => $this->input->post('email'), 'username' => $this->input->post('username'));
     list($password, $salt) = $this->hash_password($this->input->post('password'));
     $data['password_hash'] = $password;
     $data['salt'] = $salt;
     if ($this->db->insert('users', $data) == false) {
         $this->errors = lang('in_db_account_error');
         return false;
     }
     // Create a unique encryption key
     $this->load->helper('string');
     $key = random_string('unique', 40);
     $config_array = array('encryption_key' => $key);
     // check the mod_rewrite setting
     $config_array['index_page'] = $this->rewrite_check() ? '' : 'index.php';
     write_config('config', $config_array);
     // Reverse Folders
     foreach ($this->reverse_writeable_folders as $folder) {
         @chmod(FCPATH . '..' . $folder, 0775);
     }
     // We made it to the end, so we're good to go!
     return true;
 }
Esempio n. 6
0
function install_process_post_request($step, &$vars = array())
{
    $redirect_complete = "";
    try {
        switch ($step) {
            case 2:
                //Check if Config directory is writable
                if (!@touch(APPLICATION_CONFDIR)) {
                    throw new Exception("Configuration directory is not writable", 2);
                }
                break;
            case 3:
                //Database Setup
                write_db_config($_POST['baseserver'], $_POST['basename'], $_POST['baseuser'], $_POST['basepass'], $_POST['tableprefix'], APPLICATION_CONFDIR . 'db.conf.php');
                if ($vars['clean_install']) {
                    install_database_schema();
                }
                break;
            case 4:
                //Wallet Setup
                write_wallet_config($_POST['wallet_type'], $_POST['rpcserver'], $_POST['rpcport'], $_POST['rpcuser'], $_POST['rpcpass'], $_POST['addressV'], $_POST['coldwallet_file'], $_POST['hotwallet_encrypt'], APPLICATION_CONFDIR . 'wallet.conf.php');
                //Check Connection/Permissions
                check_wallet($_POST['wallet_type']);
                break;
            case 5:
                //Basic Site Preferences
                $settings = array('minimum_payout' => sprintf('%.8f', $_POST['minimum_payout']), 'maximum_payout' => sprintf('%.8f', $_POST['maximum_payout']), 'payout_precision' => $_POST['payout_precision'], 'payout_threshold' => sprintf('%.8f', $_POST['payout_threshold']), 'payout_interval' => $_POST['payout_interval'], 'user_check' => $_POST['user_check'], 'use_captcha' => $_POST['captcha_type'], 'captcha_config' => array('simple_captcha_session_name' => $_POST['simple_captcha_session_name'], 'recpatcha_private_key' => $_POST['recpatcha_private_key'], 'recpatcha_public_key' => $_POST['recpatcha_public_key'], 'solvemedia_private_key' => $_POST['solvemedia_private_key'], 'solvemedia_challenge_key' => $_POST['solvemedia_challenge_key'], 'solvemedia_hash_key' => $_POST['solvemedia_hash_key']), 'use_promo_codes' => isset($_POST['use_promo_codes']), 'use_spammerslapper' => isset($_POST['use_spammerslapper']), 'spammerslapper_key' => $_POST['spammerslapper_key'], 'donation_address' => $_POST['donation_address'], 'title' => $_POST['title'], 'sitename' => $_POST['sitename'], 'sitedesc' => $_POST['sitedesc'], 'template' => $_POST['template'], 'coin_code' => $_POST['coin_code'], 'lang' => $_POST['lang']);
                //Save
                write_faucet_config($settings, APPLICATION_CONFDIR . 'faucet.conf.php');
                break;
            case 6:
                //Done Installing
                if ($_POST['install_complete']) {
                    finish_install(@$vars['clean_install']);
                }
                break;
            default:
                //Do nothing
        }
    } catch (Exception $e) {
        //Default error code is 1
        $error = $e->getCode() == 0 ? 1 : $e->getCode();
        $step--;
        //If this fails, the redirect back to previous step and specyfy error code
        if ($step <= 1) {
            //Redirect back to first page
            $redirect_complete = $_SERVER['PHP_SELF'] . "?error={$error}";
        } else {
            //Redirect to previous page
            $redirect_complete = $_SERVER['PHP_SELF'] . "?step={$step}&error={$error}";
        }
    }
    return $redirect_complete;
}