| Actions
|--------------------------------------------------------------------------
|
*/
switch (@$_POST['action']) {
    /*
    |--------------------------------------------------------------------------
    | Change password
    |--------------------------------------------------------------------------
    |
    */
    case 'change_password':
        $password1 = $_POST['password1'];
        $password2 = $_POST['password2'];
        $password3 = $_POST['password3'];
        $username = Sentinel::getCurrentUsername();
        $errors = array();
        $fields = array();
        $doit = true;
        if (!Sentinel::isValidPassword($username, $password1)) {
            $errors[] = __('Current password is not valid');
            $fields[] = 'password1';
            $doit = false;
        }
        if (mb_strlen($password2) < 6) {
            $errors[] = __('Password must contain at least 6 chars');
            $fields[] = 'password2';
            $doit = false;
        }
        if ($password2 !== $password3) {
            $errors[] = __('Password confirmation is not the same');
/**
 * Load config file
 *
 * @param   string   $path                         the configuration file path
 * @param   boolean  $load_user_configuration_dir  do we have to parse all user configuration files ? No for upgrade for example...
 *
 * @return  array    [ badges , files ]
 */
function config_load($load_user_configuration_dir = true)
{
    $badges = false;
    $files = false;
    // Read config file
    $config = get_config_file();
    if (is_null($config)) {
        return array($badges, $files);
    }
    // Get badges
    $badges = $config['badges'];
    // Set user constant
    foreach ($config['globals'] as $cst => $val) {
        if ($cst == strtoupper($cst)) {
            @define($cst, $val);
        }
    }
    // Set unset constants
    load_default_constants();
    // Set time limit
    @set_time_limit(MAX_SEARCH_LOG_TIME + 2);
    // Append files from the USER_CONFIGURATION_DIR
    if ($load_user_configuration_dir === true) {
        if (is_dir(PML_CONFIG_BASE . DIRECTORY_SEPARATOR . USER_CONFIGURATION_DIR)) {
            $dir = PML_CONFIG_BASE . DIRECTORY_SEPARATOR . USER_CONFIGURATION_DIR;
            $userfiles = new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD), '/^.+\\.(json|php)$/i', RecursiveRegexIterator::GET_MATCH);
            foreach ($userfiles as $userfile) {
                $filepath = realpath($userfile[0]);
                $c = get_config_file($filepath);
                if (!is_null($c)) {
                    foreach ($c as $k => $v) {
                        $fileid = get_slug(str_replace(PML_CONFIG_BASE, '', $filepath) . '/' . $k);
                        $config['files'][$fileid] = $v;
                        $config['files'][$fileid]['included_from'] = $filepath;
                    }
                }
            }
        }
    }
    // Oups, there is no file... abort
    if (!isset($config['files'])) {
        return array($badges, $files);
    }
    // Try to generate the files tree if there are globs...
    $files_tmp = $config['files'];
    $files = array();
    foreach ($files_tmp as $fileid => $file) {
        $path = $file['path'];
        $count = max(1, @(int) $file['count']);
        $gpaths = glob($path, GLOB_MARK | GLOB_NOCHECK);
        if (count($gpaths) == 0) {
        } else {
            if (count($gpaths) == 1) {
                $files[$fileid] = $file;
                $files[$fileid]['path'] = $gpaths[0];
            } else {
                $new_paths = array();
                $i = 1;
                foreach ($gpaths as $path) {
                    $new_paths[$path] = filemtime($path);
                }
                // The most recent file will be the first
                arsort($new_paths, SORT_NUMERIC);
                // The first file id is the ID of the configuration file then others files are suffixed with _2, _3, etc...
                foreach ($new_paths as $path => $lastmodified) {
                    $ext = $i > 1 ? '_' . $i : '';
                    $files[$fileid . $ext] = $file;
                    $files[$fileid . $ext]['oid'] = $fileid;
                    $files[$fileid . $ext]['odisplay'] = $files[$fileid . $ext]['display'];
                    $files[$fileid . $ext]['path'] = $path;
                    $files[$fileid . $ext]['display'] .= ' > ' . basename($path);
                    if ($i >= $count) {
                        break;
                    }
                    $i++;
                }
            }
        }
    }
    // Remove forbidden files
    if (Sentinel::isAuthSet()) {
        // authentication is enabled on this instance
        $username = Sentinel::getCurrentUsername();
        $final = array();
        // Anonymous access only
        if (is_null($username)) {
            foreach ($files as $fileid => $file) {
                $a = $fileid;
                // glob file
                if (isset($files[$fileid]['oid'])) {
                    $a = $files[$fileid]['oid'];
                }
                if (Sentinel::isLogAnonymous($a)) {
                    $final[$fileid] = $file;
                }
            }
        } else {
            foreach ($files as $fileid => $file) {
                $a = $fileid;
                // glob file
                if (isset($files[$fileid]['oid'])) {
                    $a = $files[$fileid]['oid'];
                }
                if (Sentinel::userCanOnLogs($a, 'r', true, $username) || Sentinel::isLogAnonymous($a)) {
                    $final[$fileid] = $file;
                }
            }
        }
        $files = $final;
    }
    // Fix missing values with defaults
    foreach ($files as $fileid => $file) {
        foreach (array('max' => LOGS_MAX, 'refresh' => LOGS_REFRESH, 'notify' => NOTIFICATION) as $fix => $value) {
            if (!isset($file[$fix])) {
                $files[$fileid][$fix] = $value;
            }
        }
    }
    // Finally sort files
    if (!function_exists('display_asc')) {
        function display_asc($a, $b)
        {
            return strcmp($a["display"], $b["display"]);
        }
    }
    if (!function_exists('display_desc')) {
        function display_desc($a, $b)
        {
            return strcmp($b["display"], $a["display"]);
        }
    }
    if (!function_exists('display_insensitive_asc')) {
        function display_insensitive_asc($a, $b)
        {
            return strcmp($a["display"], $b["display"]);
        }
    }
    if (!function_exists('display_insensitive_desc')) {
        function display_insensitive_desc($a, $b)
        {
            return strcmp($b["display"], $a["display"]);
        }
    }
    switch (trim(str_replace(array('-', '_', ' ', 'nsensitive'), '', SORT_LOG_FILES))) {
        case 'display':
        case 'displayasc':
            usort($files, 'display_asc');
            break;
        case 'displayi':
        case 'displayiasc':
            usort($files, 'display_insensitive_asc');
            break;
        case 'displaydesc':
            usort($files, 'display_desc');
            break;
        case 'displayidesc':
            usort($files, 'display_insensitive_desc');
            break;
        default:
            # do not sort
            break;
    }
    return array($badges, $files);
}
Beispiel #3
0
 if (upgrade_is_composer()) {
     $upgrade['alert'] .= __('Simply <code>composer update</code> in the installation directory');
     $upgrade['alert'] .= '<br/>';
     $upgrade['alert'] .= '<br/><pre id="composercontent">cd ' . escapeshellarg(realpath(PML_BASE . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR)) . '; composer update</pre>';
     $upgrade['alert'] .= '<div id="changelog" class="panel-collapse collapse"><br/><div class="panel-body panel panel-default">' . $html . '</div></div>';
     $upgrade['alert'] .= '<div class="row">';
     $upgrade['alert'] .= '<div class="col-xs-6 text-left">';
     $upgrade['alert'] .= '<button id="composercopy" class="btn btn-xs btn-primary clipboard"><span class="glyphicon glyphicon-cloud-download"></span>&nbsp;' . __("Copy to clipboard") . '</button>';
     $upgrade['alert'] .= '</div>';
     $upgrade['alert'] .= '<div class="col-xs-6 text-right">';
     $upgrade['alert'] .= '<button id="upgradestop" data-version="' . $upgrade['to'] . '" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-ok"></span>&nbsp;' . __("Skip this upgrade") . '</button>';
     $upgrade['alert'] .= '</div>';
     $upgrade['alert'] .= '</div>';
     $upgrade['alert'] .= '<script>clipboard_enable("#composercopy","#composercontent" , "right" , "' . __('Command copied!') . '");</script>';
 } else {
     if (AUTO_UPGRADE === false || Sentinel::isAuthSet() && !Sentinel::isAdmin(Sentinel::getCurrentUsername())) {
         $upgrade['alert'] .= sprintf(__('Simply <code>git pull</code> in your directory or follow instructions %shere%s'), '<a href="' . UPGRADE_MANUALLY_URL . '" target="doc" class="alert-link">', '</a>');
         $upgrade['alert'] .= '<br/>';
         $upgrade['alert'] .= '<br/><pre id="gitcontent">cd ' . PML_BASE . '; git pull</pre>';
         $upgrade['alert'] .= '<div id="changelog" class="panel-collapse collapse"><br/><div class="panel-body panel panel-default">' . $html . '</div></div>';
         $upgrade['alert'] .= '<div class="row">';
         $upgrade['alert'] .= '<div class="col-xs-6 text-left">';
         $upgrade['alert'] .= '<button id="gitcopy" class="btn btn-xs btn-primary clipboard"><span class="glyphicon glyphicon-cloud-download"></span>&nbsp;' . __("Copy to clipboard") . '</button>';
         $upgrade['alert'] .= '</div>';
         $upgrade['alert'] .= '<div class="col-xs-6 text-right">';
         $upgrade['alert'] .= '<button id="upgradestop" data-version="' . $upgrade['to'] . '" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-ok"></span>&nbsp;' . __("Skip this upgrade") . '</button>';
         $upgrade['alert'] .= '</div>';
         $upgrade['alert'] .= '</div>';
         $upgrade['alert'] .= '<script>clipboard_enable("#gitcopy","#gitcontent" , "right" , "' . __('Command copied!') . '");</script>';
     } else {
         if (upgrade_is_git()) {
Beispiel #4
0
    } else {
        echo 'configuration file does not exist';
    }
    ?>
</pre></div></div></div><div class="panel panel-default"><div class="panel-heading"><h4 class="panel-title"><a data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo2">Stats <code><?php 
    echo get_config_file_path();
    ?>
</code></a></h4></div><div id="collapseTwo2" class="panel-collapse collapse"><div class="panel-body"><pre><?php 
    if (file_exists(get_config_file_path())) {
        var_export(@stat(get_config_file_path()));
    } else {
        echo 'configuration file does not exist';
    }
    ?>
</pre></div></div></div><div class="panel panel-default"><div class="panel-heading"><h4 class="panel-title"><a data-toggle="collapse" data-parent="#accordion2" href="#collapseFive2"><?php 
    $current_user = Sentinel::getCurrentUsername();
    if (is_null($current_user)) {
        _e('Generated files with includes (no user logged in or no auth)');
    } else {
        echo sprintf(__('Generated files with includes for user %s'), '<code>' . $current_user . '</code>');
    }
    ?>
</a></h4></div><div id="collapseFive2" class="panel-collapse collapse"><div class="panel-body"><pre><?php 
    list($badges, $files) = config_load();
    if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
        echo json_encode($files, JSON_PRETTY_PRINT);
    } else {
        echo json_indent(json_encode($logs));
    }
    ?>
</pre></div></div></div><div class="panel panel-default"><div class="panel-heading"><h4 class="panel-title"><a data-toggle="collapse" data-parent="#accordion2" href="#collapseFour2"><?php