<commit_before><?
$file = is_file('vkwf_branch') ? 'vkwf_branch' : 'kwf_branch';
file_put_contents($file, "master\n");
echo "Changed $file to master\n";

<commit_msg>add update script for converting web to support running in subfolder<commit_after><?
$file = is_file('vkwf_branch') ? 'vkwf_branch' : 'kwf_branch';
file_put_contents($file, "master\n");
echo "Changed $file to master\n";

function updateAclMenuUrls()
{
    $c = file_get_contents('app/Acl.php');
    $c = preg_replace_callback(
        '#(new Kwf_Acl_Resource_MenuUrl\\(\'([^\']+)\',(.*?)),\s*\'(/(admin|kwf|vkwf)[^\']+)\'(\s*\)\s*(,\s*\'[^\']+\'\)?);)#s',
        function($m) {
            if ('/'.str_replace('_', '/', $m[2]) == $m[4]) {
                return $m[1].$m[6];
            } else {
                return $m[0];
            }
        },
        $c
    );
    file_put_contents('app/Acl.php', $c);
    echo "updated app/Acl.php to set url only where required\n";
}

function updateHtaccess()
{
    $c = file_get_contents('.htaccess');
    $c = str_replace('RewriteRule ^(.*)$ /bootstrap.php [L]', 'RewriteRule ^(.*)$ bootstrap.php [L]', $c);
    file_put_contents('.htaccess', $c);
    echo "updated .htaccess to support running in subfolder\n";
}

updateAclMenuUrls();
updateHtaccess();

{'fraction_non_alphanumeric': 0.2192429022082019, 'fraction_numerical': 0.003943217665615142, 'mean_word_length': 3.272727272727273, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6787723', 'n_tokens_mistral': 482, 'n_tokens_neox': 474, 'n_words': 88}