<?php /*! pimpmylog - 1.7.10 - 65d6f147e509133fc5f09642ba82b149ef750ef2*/ /* * pimpmylog * http://pimpmylog.com * * Copyright (c) 2015 Potsky, contributors * Licensed under the GPLv3 license. */ if (realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"])) { header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); die; } include_once 'inc/global.inc.php'; load_default_constants(); ?> <!DOCTYPE html><!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7"><![endif]--><!--[if IE 7]><html class="no-js lt-ie9 lt-ie8"><![endif]--><!--[if IE 8]><html class="no-js lt-ie9"><![endif]--><!--[if gt IE 8]><!--><html class="no-js"><!--<![endif]--><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><meta name="description" content=""><meta name="pmltrick" content="Pimp My Log Login Match"><meta name="viewport" content="width=device-width"><title><?php echo TITLE; ?> </title><?php include_once 'inc/favicon.inc.php'; ?> <link rel="stylesheet" href="css/pml.min.css"></head><body><!--[if lt IE 7]><p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p><![endif]--><div class="navbar navbar-inverse navbar-fixed-top"><div class="logo"></div></div><div class="jumbotron"><center><div class="container"><div class="container"><div class="row"><div class="input-group col-sm-6 col-md-4"><?php if ((int) @$error === 1) { echo '<div class="alert alert-danger">'; echo __('Your username or password is not correct'); echo '</div>'; } else { if ((int) @$error === 2) { echo '<div class="alert alert-warning">';
/** * 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); }