<commit_before><?php
require("header.php"); // Important includes

// Configuration
$AQUILON_URL = $CONFIG['URL']['AQUILON'];
$config = Array(
    "clickable" => true,
);

// Gets node data and formats it
$jsondata = file_get_contents("$AQUILON_URL/cgi-bin/report/host_personality_branch");
if ($jsondata === false) {
    error("No data returned from", "aquilon");
}
$all_nodes = json_decode($jsondata, true);
uksort($all_nodes, "strnatcmp");

$jsondata = file_get_contents("$AQUILON_URL/cgi-bin/report/branch_type_owner");
$branches = json_decode($jsondata, true);

// Gets notes for nodes
$all_notes = Array();
$notes = $SQL->query("select name, note from notes");
if ($notes and $notes->num_rows) {
    while ($note = $notes->fetch_assoc()) {
        $all_notes[$note['name']] = $note['note'];
    }
}

// Initialise all branches (even empty ones!)
$results = Array();
$results['config'] = $config;
foreach ($branches as $branch) {

    $group = $branch['branch_type'];
    $panel = $branch['branch_owner'];
    $cluster = $branch['branch_name'];

    $results[$group][$panel][$cluster] = Array();
}

// Generates main array
foreach ($all_nodes as $name => $panels) {

    $group = $panels["branch_type"];
    $panel = $panels["branch_owner"];
    $cluster = $panels["branch_name"];

    $results[$group][$panel][$cluster][$name] = Array();
    if (array_key_exists($name, $all_nodes)) {
        $results[$group][$panel][$cluster][$name] = $all_nodes[$name];
    };
    if (array_key_exists($name, $all_notes)) {
        $results[$group][$panel][$cluster][$name]['note'] = $all_notes[$name];
    };
    if (nagios($name) !== Null) {
        $results[$group][$panel][$cluster][$name]['nagios'] = nagios($name);
    };
}

foreach ($results as $group => $panel) {
    foreach ($panel as $owner => $nodes) {
        if ($group != "domain") {
            $realname = $owner;
            //Converts username to real name
            $username_lookup = $CONFIG['ID']['PATH'];
            if (file_exists($username_lookup)) {
                $realname = exec("$username_lookup $owner");
                $realname = explode(',', $realname);
                $realname = $realname[0];
                if (! $realname) {
                    $realname = $owner;
                }
            }
            if ($realname != $owner) {
                $results[$group][$realname] = $results[$group][$owner];
                unset($results[$group][$owner]);
            }
        } else {
            $results[$group]["Aquilon"] = $results[$group][$owner];
            unset($results[$group][$owner]);
        }
    }
}

ksort($results);
foreach ($results as $group => $panel) {
    asort($results[$group]);
}
<commit_msg>Display all domains in prod<commit_after><?php
require("header.php"); // Important includes

// Configuration
$AQUILON_URL = $CONFIG['URL']['AQUILON'];
$config = Array(
    "clickable" => true,
);

// Gets node data and formats it
$jsondata = file_get_contents("$AQUILON_URL/cgi-bin/report/host_personality_branch");
if ($jsondata === false) {
    error("No data returned from", "aquilon");
}
$all_nodes = json_decode($jsondata, true);
uksort($all_nodes, "strnatcmp");

$jsondata = file_get_contents("$AQUILON_URL/cgi-bin/report/branch_type_owner");
$branches = json_decode($jsondata, true);

// Gets notes for nodes
$all_notes = Array();
$notes = $SQL->query("select name, note from notes");
if ($notes and $notes->num_rows) {
    while ($note = $notes->fetch_assoc()) {
        $all_notes[$note['name']] = $note['note'];
    }
}

// Initialise all branches (even empty ones!)
$results = Array();
$results['config'] = $config;
foreach ($branches as $branch) {

    $group = $branch['branch_type'];
    $panel = $branch['branch_owner'];
    $cluster = $branch['branch_name'];

    $results[$group][$panel][$cluster] = Array();
}

// Generates main array
foreach ($all_nodes as $name => $panels) {

    $group = $panels["branch_type"];
    $panel = $panels["branch_owner"];
    $cluster = $panels["branch_name"];

    $results[$group][$panel][$cluster][$name] = Array();
    if (array_key_exists($name, $all_nodes)) {
        $results[$group][$panel][$cluster][$name] = $all_nodes[$name];
    };
    if (array_key_exists($name, $all_notes)) {
        $results[$group][$panel][$cluster][$name]['note'] = $all_notes[$name];
    };
    if (nagios($name) !== Null) {
        $results[$group][$panel][$cluster][$name]['nagios'] = nagios($name);
    };
}

foreach ($results as $group => $panel) {
    foreach ($panel as $owner => $nodes) {
        if ($group != "domain") {
            $realname = $owner;
            //Converts username to real name
            $username_lookup = $CONFIG['ID']['PATH'];
            if (file_exists($username_lookup)) {
                $realname = exec("$username_lookup $owner");
                $realname = explode(',', $realname);
                $realname = $realname[0];
                if (! $realname) {
                    $realname = $owner;
                }
            }
            if ($realname != $owner) {
                $results[$group][$realname] = $results[$group][$owner];
                unset($results[$group][$owner]);
            }
        } else {
            foreach ($results[$group][$owner] as $key => $value) {
                $results[$group]["Aquilon"][$key] = $value;
            }
            unset($results[$group][$owner]);
        }
    }
}

ksort($results);
foreach ($results as $group => $panel) {
    asort($results[$group]);
}

{'fraction_non_alphanumeric': 0.19516627294203162, 'fraction_numerical': 0.00036343812465927677, 'mean_word_length': 3.032234432234432, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, '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': '4206860', 'n_tokens_mistral': 1770, 'n_tokens_neox': 1755, 'n_words': 337}