<commit_before><?php 
/**
 * ChurchTools 2.0
 * http://www.churchtools.de
 *
 * Copyright (c) 2013 <NAME>
 * Licensed under the MIT license, located in LICENSE.txt 
 *
 */

$add_header="";
$q="";
$config=array();
$mapping=array();
$content="";
$embedded=false;
$user=null;
$files_dir="sites/default";
  
function handleShutdown() {
  $error = error_get_last();
  $info="";
  if($error !== NULL){
    $info = "[ERROR] file:".$error['file'].":".$error['line']." <br/><i>".$error['message'] .'</i>'.PHP_EOL;
    echo '<div class="alert alert-error">'.$info.'</div>';
  }
  db_close();
}

/**
 * Prfe auf Mulitsite-Installation. Hier gibt es eine Config fr subdomain
 * z.Bsp. mghh.churchtools.de muss es dann config/churchtools.mggh.config geben.
 * Gibt die Config als Array zurck oder null wenn es keine zu laden gibt.
 */
function loadConfig() {
    global $files_dir;
    // Unix default. Should have ".conf" extension as per standards.
    $cnf_location = "/etc/churchtools/default.conf";
    $config = parse_ini_file($cnf_location);

    // Package installed, per domain.
    // All possible virt-hosts in HTTP server has to be symlinked to it.
    if ($config == null) {
        $cnf_location = "/etc/churchtools/hosts/" . $_SERVER["SERVER_NAME"] . ".conf";
        $config = parse_ini_file($cnf_location);
    }

    // Config, based on subdomain.
    // WARNING: This code will break per IP address access and supports only last subdomain.
    if ($config == null && strpos($_SERVER["SERVER_NAME"],".") > 0) {
        $hostname=substr($_SERVER["SERVER_NAME"],0,strpos($_SERVER["SERVER_NAME"],"."));
        $cnf_location = "sites/$hostname/churchtools.config";
        if (file_exists($cnf_location)) {
            $config = parse_ini_file($cnf_location);
            $files_dir="sites/".$hostname;
        }
    }

    // Default domain
    if ($config == null) {
        $cnf_location = "sites/default/churchtools.config";
        $config = parse_ini_file($cnf_location);
    }
  
    if ($config == null) {
        $error_message = "<h3>" . "Error: Configuration file was not found." . "</h3>";
        $error_message .= "<p>" . "Expected locations are:
            <ul>
                <li>Default appliance: <code>/etc/churchtools/default.conf</code></li>
                <li>Per-domain appliance: <code>/etc/churchtools/hosts/" . $_SERVER["SERVER_NAME"] . ".conf</code></li>
                <li>Shared hosting per domain: <code><i>YOUR_INSTALLATION</i>/sites/" . $_SERVER["SERVER_NAME"] . "/churchtools.config</code></li>
                <li>Hosting per sub-domain: <code><i>YOUR_INSTALLATION</i>/sites/<b>&lt;subdomain&gt;.&lt;domain&gt;</b>/churchtools.config</code></li>
                <li>Shared hosting default (single installation): <code><i>YOUR_INSTALLATION</i>/sites/default/churchtools.config</code></li>
            </ul>
            <div class=\"alert alert-info\">You can also use <strong>example</strong> file in
            <code><i>INSTALLATION</i>/sites/default/churchtools.example.config</code> by renaming it to
            either one location that suits your setup and further editing it accordingly.</div>";
        addErrorMessage($error_message);
    } else {
        $config["_current_config_file"] = $cnf_location;
    }
  
    return $config;
}<commit_msg>Bugfixed backward compatibility.<commit_after><?php 
/**
 * ChurchTools 2.0
 * http://www.churchtools.de
 *
 * Copyright (c) 2013 <NAME>
 * Licensed under the MIT license, located in LICENSE.txt 
 *
 */

$add_header="";
$q="";
$config=array();
$mapping=array();
$content="";
$embedded=false;
$user=null;
$files_dir="sites/default";
  
function handleShutdown() {
  $error = error_get_last();
  $info="";
  if($error !== NULL){
    $info = "[ERROR] file:".$error['file'].":".$error['line']." <br/><i>".$error['message'] .'</i>'.PHP_EOL;
    echo '<div class="alert alert-error">'.$info.'</div>';
  }
  db_close();
}

/**
 * Prfe auf Mulitsite-Installation. Hier gibt es eine Config fr subdomain
 * z.Bsp. mghh.churchtools.de muss es dann config/churchtools.mggh.config geben.
 * Gibt die Config als Array zurck oder null wenn es keine zu laden gibt.
 */
function loadConfig() {
    global $files_dir;
    // Unix default. Should have ".conf" extension as per standards.
    $config = null;
    $cnf_location = "/etc/churchtools/default.conf";
    if (file_exists($cnf_location)) {
        $config = parse_ini_file($cnf_location);
    }

    // Package installed, per domain.
    // All possible virt-hosts in HTTP server has to be symlinked to it.
    $cnf_location = "/etc/churchtools/hosts/" . $_SERVER["SERVER_NAME"] . ".conf";
    if ($config == null && file_exists($cnf_location)) {
        $config = parse_ini_file($cnf_location);
    }

    // Config, based on subdomain.
    // WARNING: This code will break per IP address access and supports only last subdomain.
    if ($config == null && strpos($_SERVER["SERVER_NAME"],".") > 0) {
        $hostname=substr($_SERVER["SERVER_NAME"],0,strpos($_SERVER["SERVER_NAME"],"."));
        $cnf_location = "sites/$hostname/churchtools.config";
        if (file_exists($cnf_location)) {
            $config = parse_ini_file($cnf_location);
            $files_dir="sites/".$hostname;
        }
    }

    // Default domain
    $cnf_location = "sites/default/churchtools.config";
    if ($config == null && file_exists($cnf_location)) {
        $config = parse_ini_file($cnf_location);
    }
  
    if ($config == null) {
        $error_message = "<h3>" . "Error: Configuration file was not found." . "</h3>";
        $error_message .= "<p>" . "Expected locations are:
            <ul>
                <li>Default appliance: <code>/etc/churchtools/default.conf</code></li>
                <li>Per-domain appliance: <code>/etc/churchtools/hosts/" . $_SERVER["SERVER_NAME"] . ".conf</code></li>
                <li>Shared hosting per domain: <code><i>YOUR_INSTALLATION</i>/sites/" . $_SERVER["SERVER_NAME"] . "/churchtools.config</code></li>
                <li>Hosting per sub-domain: <code><i>YOUR_INSTALLATION</i>/sites/<b>&lt;subdomain&gt;.&lt;domain&gt;</b>/churchtools.config</code></li>
                <li>Shared hosting default (single installation): <code><i>YOUR_INSTALLATION</i>/sites/default/churchtools.config</code></li>
            </ul>
            <div class=\"alert alert-info\">You can also use <strong>example</strong> file in
            <code><i>INSTALLATION</i>/sites/default/churchtools.example.config</code> by renaming it to
            either one location that suits your setup and further editing it accordingly.</div>";
        addErrorMessage($error_message);
    } else {
        $config["_current_config_file"] = $cnf_location;
    }
  
    return $config;
}
{'fraction_non_alphanumeric': 0.1698617922425323, 'fraction_numerical': 0.002972209838014564, 'mean_word_length': 3.0812613705275926, 'pattern_counts': {'":': 2, '<': 99, '<?xml version=': 0, '>': 99, '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': '891936', 'n_tokens_mistral': 2191, 'n_tokens_neox': 2102, 'n_words': 468}