<commit_before><?php

use diversen\conf;
use diversen\file;

/**
 * File containing documentation functions for shell mode
 *
 * @package     shell
 */

/**
 * function for doing a prompt install from shell mode
 * is a wrapper around other shell functions.
 */
function prompt_install(){
    if (defined('NO_CONFIG_FILE')){
        cos_cli_print("No config file (config/config.ini) is loaded");
    }

    cos_cli_print('The following tags can be used:');

    $tags = '';
    $tags.= git_coscms_tags_local ();
    $tags.= "master";

    cos_cli_print ($tags);
    $tag = cos_readline("Enter tag (version) to use:");

    cos_exec("git checkout $tag");

    $profiles = file::getFileList('profiles', array('dir_only' => true));
    cos_cli_print("List of profiles: ");
    foreach ($profiles as $key => $val){
        cos_cli_print("\t".$val);
    }

    // select profile and load it
    $profile = cos_readline('Enter profile, and hit return: ');
    load_profile(array('profile' => $profile, 'config_only' => true));
    cos_cli_print("Main config file (config/config.ini) for $profile is loaded");

    
    
    // Keep base path. Ortherwise we will lose it when loading profile    
    $base_path = conf::pathBase();
    
    // load profile.
    conf::$vars['coscms_main'] = conf::getIniFileArray($base_path . '/config/config.ini', true);
    
    // reset base path
    // all commons are set based on base_path
    conf::setMainIni('base_path', $base_path);
    conf::defineCommon();
    
    // get configuration info
    $host = cos_readline('Enter mysql host, and hit return: ');
    $database = cos_readline('Enter database name, and hit return: ');
    $username = cos_readline('Enter database user, and hit return: ');
    $password = cos_readline('Enter database users password, and hit return: ');
    $server_name = cos_readline('Enter server host name (e.g. www.coscms.org), and hit return: ');

    // assemble configuration info
    conf::$vars['coscms_main']['url'] = "mysql:dbname=$database;host=$host;charset=utf8";
    conf::$vars['coscms_main']['username'] = $username;
    conf::$vars['coscms_main']['password'] = <PASSWORD>;
    conf::$vars['coscms_main']['server_name'] = $server_name;
    conf::$vars['coscms_main']['server_redirect'] = $server_name;
    
    // write it to ini file
    $content = conf::arrayToIniFile(conf::$vars['coscms_main'], false);
    $path = conf::pathBase() . "/config/config.ini";
    file_put_contents($path, $content);

    // install profile.
    $confirm_mes = "Configuration rewritten (config/config.ini). More options can be set here, so check it out at some point.";
    $confirm_mes.= "Will now install system ... ";
    
    cos_cli_print($confirm_mes);

    $options = array();
    $options['profile'] = $profile;
    if ($tag == 'master'){
        $options['master'] = true;
    }
<commit_msg>dont set server_redirect as default when loading profile<commit_after><?php

use diversen\conf;
use diversen\file;

/**
 * File containing documentation functions for shell mode
 *
 * @package     shell
 */

/**
 * function for doing a prompt install from shell mode
 * is a wrapper around other shell functions.
 */
function prompt_install(){
    if (defined('NO_CONFIG_FILE')){
        cos_cli_print("No config file (config/config.ini) is loaded");
    }

    cos_cli_print('The following tags can be used:');

    $tags = '';
    $tags.= git_coscms_tags_local ();
    $tags.= "master";

    cos_cli_print ($tags);
    $tag = cos_readline("Enter tag (version) to use:");

    cos_exec("git checkout $tag");

    $profiles = file::getFileList('profiles', array('dir_only' => true));
    cos_cli_print("List of profiles: ");
    foreach ($profiles as $key => $val){
        cos_cli_print("\t".$val);
    }

    // select profile and load it
    $profile = cos_readline('Enter profile, and hit return: ');
    load_profile(array('profile' => $profile, 'config_only' => true));
    cos_cli_print("Main config file (config/config.ini) for $profile is loaded");

    
    
    // Keep base path. Ortherwise we will lose it when loading profile    
    $base_path = conf::pathBase();
    
    // load profile.
    conf::$vars['coscms_main'] = conf::getIniFileArray($base_path . '/config/config.ini', true);
    
    // reset base path
    // all commons are set based on base_path
    conf::setMainIni('base_path', $base_path);
    conf::defineCommon();
    
    // get configuration info
    $host = cos_readline('Enter mysql host, and hit return: ');
    $database = cos_readline('Enter database name, and hit return: ');
    $username = cos_readline('Enter database user, and hit return: ');
    $password = cos_readline('Enter database users password, and hit return: ');
    $server_name = cos_readline('Enter server host name (e.g. www.coscms.org), and hit return: ');

    // assemble configuration info
    conf::$vars['coscms_main']['url'] = "mysql:dbname=$database;host=$host;charset=utf8";
    conf::$vars['coscms_main']['username'] = $username;
    conf::$vars['coscms_main']['password'] = $password;
    conf::$vars['coscms_main']['server_name'] = $server_name;
    
    // write it to ini file
    $content = conf::arrayToIniFile(conf::$vars['coscms_main'], false);
    $path = conf::pathBase() . "/config/config.ini";
    file_put_contents($path, $content);

    // install profile.
    $confirm_mes = "Configuration rewritten (config/config.ini). More options can be set here, so check it out at some point.";
    $confirm_mes.= "Will now install system ... ";
    
    cos_cli_print($confirm_mes);

    $options = array();
    $options['profile'] = $profile;
    if ($tag == 'master'){
        $options['master'] = true;
    }

{'fraction_non_alphanumeric': 0.1531041739740442, 'fraction_numerical': 0.00035075412136092597, 'mean_word_length': 3.508300395256917, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6060515', 'n_tokens_mistral': 1780, 'n_tokens_neox': 1741, 'n_words': 469}