<commit_before><?php
/*
    All Emoncms code is released under the GNU Affero General Public License.
    See COPYRIGHT.txt and LICENSE.txt.

    ---------------------------------------------------------------------
    Emoncms - open source energy visualisation
    Part of the OpenEnergyMonitor project:
    http://openenergymonitor.org
*/

// no direct access
defined('EMONCMS_EXEC') or die('Restricted access');

function admin_controller()
{
    global $mysqli,$session,$route,$updatelogin,$allow_emonpi_admin, $redis, $openenergymonitor_dir, $admin_show_update, $path;
    global $log, $log_location, $log_enabled, $log_level;
    
    $result = EMPTY_ROUTE;// display missing route message by default
    $message = _('406: Route not found');
    
    if(!$session['write']) {
        $result = ''; // empty result shows login page (now redirects once logged in)
        $message = _('Admin re-authentication required');
    }   

    // Allow for special admin session if updatelogin property is set to true in settings.php
    // Its important to use this with care and set updatelogin to false or remove from settings
    // after the update is complete.

    //put $update_logfile here so it can be referenced in other if statements
    //before it was only accesable in the update subaction
    //placed some other variables here as well so they are grouped
    //together for the emonpi action even though they might not be used
    //in the subaction
    $emoncms_logfile = "$log_location/emoncms.log";
    $update_logfile = "$log_location/emonpiupdate.log";
    $backup_logfile = "$log_location/emonpibackup.log";
    $update_flag = "/tmp/emoncms-flag-update";
    $backup_flag = "/tmp/emonpibackup";
    $update_script = "$openenergymonitor_dir/emonpi/service-runner-update.sh";
    $backup_file = "$openenergymonitor_dir/data/backup.tar.gz";<commit_msg>use EmonScripts update if present<commit_after><?php
/*
    All Emoncms code is released under the GNU Affero General Public License.
    See COPYRIGHT.txt and LICENSE.txt.

    ---------------------------------------------------------------------
    Emoncms - open source energy visualisation
    Part of the OpenEnergyMonitor project:
    http://openenergymonitor.org
*/

// no direct access
defined('EMONCMS_EXEC') or die('Restricted access');

function admin_controller()
{
    global $mysqli,$session,$route,$updatelogin,$allow_emonpi_admin, $redis, $openenergymonitor_dir, $admin_show_update, $path;
    global $log, $log_location, $log_enabled, $log_level;
    
    $result = EMPTY_ROUTE;// display missing route message by default
    $message = _('406: Route not found');
    
    if(!$session['write']) {
        $result = ''; // empty result shows login page (now redirects once logged in)
        $message = _('Admin re-authentication required');
    }   

    // Allow for special admin session if updatelogin property is set to true in settings.php
    // Its important to use this with care and set updatelogin to false or remove from settings
    // after the update is complete.

    //put $update_logfile here so it can be referenced in other if statements
    //before it was only accesable in the update subaction
    //placed some other variables here as well so they are grouped
    //together for the emonpi action even though they might not be used
    //in the subaction
    $emoncms_logfile = "$log_location/emoncms.log";
    $update_logfile = "$log_location/emonpiupdate.log";
    $backup_logfile = "$log_location/emonpibackup.log";
    $update_flag = "/tmp/emoncms-flag-update";
    $backup_flag = "/tmp/emonpibackup";
    if (file_exists("$openenergymonitor_dir/EmonScripts")) {
        $update_script = "$openenergymonitor_dir/EmonScripts/update/service-runner-update.sh";
    } else {
        $update_script = "$openenergymonitor_dir/emonpi/service-runner-update.sh";
    }
    $backup_file = "$openenergymonitor_dir/data/backup.tar.gz";
{'fraction_non_alphanumeric': 0.132013201320132, 'fraction_numerical': 0.0015232292460015233, 'mean_word_length': 3.0534979423868314, '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': '6795231', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1145, 'n_words': 354}