// Sponsored by WIEDENMANN SEILE GMBH, http://www.wiedenmannseile.de
//
// This file is part of Wiedenmann Vacation.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see ,
// or write to Wolfgang Scherer,
// $_REQUEST['_DEBUG_'] = 1;
// --------------------------------------------------
// |||:sec:||| Configuration
// --------------------------------------------------
require_once(dirname(__FILE__) . '/lib/util.php');
require_once(dirname(__FILE__) . '/lib/template.php');
// _DEBUG_ = 1 normal debugging
// _DEBUG_ = 2 turn off administrator rights
// _DEBUG_ = 3 provoke error #1
// _DEBUG_ = 4 provoke error #2
if (isset($_REQUEST['_DEBUG_'])) {
$_debug = $_REQUEST['_DEBUG_'];
if (empty($_debug)) {
$_debug = 1;
}
} else {
$_debug = 0;
}
file_put_contents('/tmp/xxxxxxx', 'check');
system('touch /tmp/xxxxxx1');
// --------------------------------------------------
// |||:sec:||| Setup
// --------------------------------------------------
if (isset($_SERVER["REMOTE_USER"])) {
$remote_user = $_SERVER["REMOTE_USER"];
} else {
$remote_user = '';
}
if (isset($_REQUEST["user"])) {
$request_user = $_REQUEST["user"];
} else {
$request_user = '';
}
$is_admin = in_array($remote_user, $ADMIN_USERS);
if ($_debug > 1) {
$is_admin = False;
}
// $is_admin = False; // |:debug:|
$users = get_users();
$user_names = array_keys($users);
if (!$is_admin) {
$user = $remote_user;
} else {
$user = $request_user;
if (empty($user)) {
$user = $remote_user;
}
}
// --------------------------------------------------
// |||:sec:||| HTML Header
// --------------------------------------------------
$title = get_text('title');
$css = '
div.error {
margin-bottom: 10px;
}
span.label {
width: 100px;
display: inline-block;
vertical-align: top;
}
hr.sep {
width: 550px;
text-align: left;
margin-left: 0;
}
#body, #copyright-notice {
width: 550px;
margin: 10px auto;
position:relative;
}
#body {
text-align: left;
}
#copyright-notice {
text-align: center;
font-size: 8pt;
}
';
$script ='
';
echo substitute_elements(
$HEAD, Array(
'title' => trim($title),
'css' => trim($css),
'script' => trim($script),
));
hl($title);
// --------------------------------------------------
// |||:sec:||| Error handling (User)
// --------------------------------------------------
if ($_debug > 2) {
$user = ''; // error #1
}
if ($_debug > 3) {
$user = 'unknown'; // error #2
}
if (empty($user)) {
error_msg(get_text('error_no_user'));
echo $FOOT;
exit(0);
}
if (!$is_admin && !in_array($user, $user_names)) {
error_msg(sprintf('%s (%s)!', get_text('error_unknown_user'), $user));
echo $FOOT;
exit(0);
}
// --------------------------------------------------
// |||:sec:||| Setup HOME/vacation(1)
// --------------------------------------------------
$home = $users[$user][1];
if ($_debug) {
echo ('