$return['notice'] = '<h2>' . __('Setup admin account') . '</h2>' . '<br/>' . __('You can use <em>Pimp my Log</em> without authentication. You will be able to add this feature later from the debugger web interface.') . '<br/>' . '<br/>' . __('Setup an admin account will let you create other users later and give them access to certain log files only.') . '<br/>' . '<br/>' . __('Do you want to create an admin account now?') . '<br/>' . '<br/>' . '<br/>' . '<a href="javascript:process_authentication_yes()" class="btn btn-primary">' . __('Create an admin account') . '</a>' . ' ' . '<a href="javascript:process_authentication_no()" class="btn btn-default">' . __('No') . '</a>'; break; /* |-------------------------------------------------------------------------- | Auth 2. Touch auth file |-------------------------------------------------------------------------- | */ /* |-------------------------------------------------------------------------- | Auth 2. Touch auth file |-------------------------------------------------------------------------- | */ case 'authtouch': if (Sentinel::isAuthSet() === true) { $path = Sentinel::getAuthFilePath(); $return['notice'] = sprintf(__('File <code>%s</code> already exists!'), AUTH_CONFIGURATION_FILE) . '<br/><br/>' . __('Please remove it from the root directory:') . '<div class="row">' . ' <div class="col-md-10"><pre class="clipboardcontent">' . 'mv \'' . $path . '\' \'' . $path . '.bck\'</pre></div>' . ' <div class="col-md-2"><a class="btn btn-primary clipboard">' . __('Copy to clipboard') . '</a><script>clipboard_enable("a.clipboard","pre.clipboardcontent" , "top" , "' . __('Command copied!') . '");</script></div>' . '</div>'; $return['reload'] = true; } else { if (Sentinel::create() === true) { $return['authform'] = '<h2>' . __('Setup admin account') . '</h2>' . '<br/>' . __('Please choose a username and a password for the admin account.') . '<br/><br/>' . '<form id="authsave" autocomplete="off">' . '<div class="container">' . '<div class="row">' . '<div class="input-group col-sm-6 col-md-4" id="usernamegroup" data-toggle="tooltip" data-placement="top" title="' . htmlentities(__('Username is required')) . '"> <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span> <input type="text" id="username" class="form-control" placeholder="' . __('Username') . '" autofocus="autofocus"> </div>' . '<br/>' . '</div>' . '<div class="row">' . '<div class="input-group col-sm-6 col-md-4" id="passwordgroup" data-toggle="tooltip" data-placement="bottom" title="' . htmlentities(__('Password must contain at least 6 chars')) . '"> <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span> <input type="password" id="password" class="form-control" placeholder="' . __('Password') . '"> </div>' . '<br/>' . '</div>' . '<div class="row">' . '<div class="input-group col-sm-6 col-md-4" id="password2group" data-toggle="tooltip" data-placement="bottom" title="' . htmlentities(__('Password is not the same')) . '"> <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span> <input type="password" id="password2" class="form-control" placeholder="' . __('Password Confirmation') . '"> </div>' . '</div>' . '</div>' . '<br/><br/>' . '<input type="submit" class="btn btn-primary" value="' . __('Continue') . '"/>' . '</form>';
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> ' . __("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> ' . __("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> ' . __("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> ' . __("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()) {
/* * pimpmylog * http://pimpmylog.com * * Copyright (c) 2015 Potsky, contributors * Licensed under the GPLv3 license. */ include_once 'global.inc.php'; list($badges, $files) = config_load(); /* |-------------------------------------------------------------------------- | Login |-------------------------------------------------------------------------- | */ if (!Sentinel::isAuthSet()) { die; } $current_user = Sentinel::attempt($files); /* |-------------------------------------------------------------------------- | Error handling |-------------------------------------------------------------------------- | */ function myErrorHandler($errno, $errstr, $errfile, $errline) { global $return; if (!(error_reporting() & $errno)) { return; }
/** * Check the $files array and fix it with default values * If there is a problem, return an array of errors * If everything is ok, return true; * * @param array $files log files * * @return mixed true if ok, otherwise an array of errors */ function config_check($files) { $errors = array(); if (!is_array($files)) { if (Sentinel::isAuthSet()) { return false; } $errors[] = __('No file is defined in <code>files</code> array'); return $errors; } if (count($files) === 0) { if (Sentinel::isAuthSet()) { return false; } $errors[] = __('No file is defined in <code>files</code> array'); return $errors; } foreach ($files as $file_id => &$file) { // error foreach (array('display', 'path', 'format') as $mandatory) { if (!isset($file[$mandatory])) { $errors[] = sprintf(__('<code>%s</code> is mandatory for file ID <code>%s</code>'), $mandatory, $file_id); } } } if (count($errors) == 0) { return true; } else { return $errors; } }