@@ -251,227 +251,230 @@ if ( $x_wsv_raw )
$vacation_body = $message_body;
$vacation_subject = header_field_body($vacation_headers, 'subject');
} else {
$vacation_parts = vacation_split($vacation_msg, True);
$vacation_subject = $vacation_parts[0];
$vacation_headers = $vacation_parts[1];
$vacation_body = $vacation_parts[2];
}
$vacation_refresh = isset($_REQUEST['refresh']);
$vacation_forward_to = '';
if ( !$vacation_refresh && !$vacation_clear && isset($_REQUEST['forward']) ) {
$vacation_forward_to = $_REQUEST['forward'];
$vacation_forward_to = $forward_settings[1];
$vacation_forward_to = preg_replace('/^\\\\/', '', $vacation_forward_to);
if (empty($vacation_forward_to)) {
$vacation_forward_to = vacation_find_forward($vacation_headers);
// remove domain suffix
$vacation_forward_to = preg_replace('/@.*$/', '', $vacation_forward_to);
// --------------------------------------------------
// |||:sec:||| Set vacation(1) parameters
$vacation_setup = isset($_REQUEST['save']);
if ( $vacation_setup ) {
// |:check:| redundant?
$vacation_setup_raw = False;
$vacation_del_log = isset($_REQUEST['delete']);
if ( $vacation_del_log ) {
if ( !isset($_REQUEST['subject']) ) {
$vacation_setup_raw = True;
if ($vacation_setup || $vacation_setup_raw || $vacation_del_log) {
$forward_active = isset($_REQUEST['active']);
// validate forward to
if ($vacation_forward_to == $user) {
$forward_settings = Array(
'\\'.$user, $vacation_forward_to,
sprintf($VACATION_FORWARD_ENTRY, implode(' ', $vacation_args)));
if ( $vacation_setup_raw ) {
$vacation_msg = isset($_REQUEST['message']) ? trim($_REQUEST['message']) : '';
$message_parts = message_split($vacation_msg);
$vacation_headers = header_clean($message_parts[0]);
$vacation_body = $message_parts[1];
header_set($vacation_headers, 'X-WSV-Format: raw');
$x_wsv_raw = True;
$vacation_subject = isset($_REQUEST['subject']) ? trim($_REQUEST['subject']) : '';
$vacation_body = isset($_REQUEST['body']) ? trim($_REQUEST['body']) : '';
$vacation_headers = Array();
$x_wsv_raw = False;
while (True) {
if ($vacation_del_log) {
$cmd = sprintf(
'%s -u %s %s %s %s',
$SUDO_CMD, $user, $SUDO_OPT_H, $VACATION_CMD, $VACATION_INIT_OPTS);
// fprintf($stderr, "\$cmd: %s<br>\n", $cmd);
system($cmd);
$pipe_cmd = sprintf(
$SUDO_CMD, $user, $SUDO_OPT_H, $VACATION_CMD, $VACATION_EXLCUDE_OPTS);
// fprintf($stderr, "\$pipe_cmd: %s<br>\n", $pipe_cmd);
$vacation_excl_pipe = popen($pipe_cmd, 'w');
fwrite($vacation_excl_pipe, sprintf("%s%s\n", $user, $DOMAIN_SUFFIX));
if (!empty($user_alias)) {
fwrite($vacation_excl_pipe, sprintf("%s%s\n", $user_alias, $DOMAIN_SUFFIX));
pclose($vacation_excl_pipe);
break;
if (empty ($vacation_subject)) {
error_msg(get_text('error_no_subject'));
if (!$is_admin && !empty($vacation_forward_to) && !in_array($vacation_forward_to, $user_names)) {
error_msg(sprintf('%s (%s)!', get_text('error_unknown_forward'), $vacation_forward_to));
// Actually set it
if (!$FOOTER || $vacation_setup_raw || $x_wsv_raw) {
$vacation_body_full = $vacation_body;
$vacation_body_full = str_replace("\n", "\r\n", str_replace("\r", "", rtrim(rtrim($vacation_body)."\n\n".$FOOTER)));
// Prepare vacation(1) message
if (!empty($vacation_forward_to)) {
header_set($vacation_headers, sprintf('X-WSV-Forward-To: %s', $vacation_forward_to));
$vacation_msg = message_join($vacation_headers, $vacation_body);
$vacation_msg_in = message_join($vacation_headers, $vacation_body);
$vacation_msg = message_join($vacation_headers, $vacation_body_full);
// echo "<pre>"; // |:debug:|
// var_dump($vacation_headers);
// var_dump($vacation_body);
// echo $vacation_msg;
// echo "</pre>";
$vacation_msg = vacation_join($vacation_subject, $vacation_body, $vacation_headers);
$vacation_msg_in = vacation_join($vacation_subject, $vacation_body, $vacation_headers);
$vacation_msg = vacation_join($vacation_subject, $vacation_body_full, $vacation_headers);
$SUDO_CMD, $user, $SUDO_OPT_H, $WRITE_TO_CMD, $vacation_msg_in_file);
$vacation_msg_pipe = popen($pipe_cmd, 'w');
fwrite($vacation_msg_pipe, $vacation_msg);
fwrite($vacation_msg_pipe, $vacation_msg_in);
pclose($vacation_msg_pipe);
$SUDO_CMD, $user, $SUDO_OPT_H, $WRITE_TO_CMD, $vacation_msg_file);
$full_msg = $vacation_msg;
$full_msg = rtrim(rtrim($vacation_msg)."\n".$FOOTER)."\n";
fwrite($vacation_msg_pipe, $full_msg);
// Initialize vacation(1) if necessary.
if (!test_readable($vacation_db_file, $user)) {
// Write or remove .forward file
if ($forward_active) {
$expanded_forward_settings = $forward_settings;
if (!empty($expanded_forward_settings[1])) {
$expanded_forward_settings[1] .= $DOMAIN_SUFFIX;
$use_fs = Array();
foreach ($expanded_forward_settings as $fs) {
if (empty($fs)) {
continue;
$use_fs[] = $fs;
$SUDO_CMD, $user, $SUDO_OPT_H, $WRITE_TO_CMD, $forward_file);
$forward_file_pipe = popen($pipe_cmd, 'w');
fwrite($forward_file_pipe, implode(", ", $use_fs)."\n");
pclose($forward_file_pipe);
if (!empty($VACATION_FORWARD_EXT_ENTRY)) {
foreach ($FORWARD_EXTENSIONS as $fe) {
'%s -u %s %s %s %s%s',
$SUDO_CMD, $user, $SUDO_OPT_H, $WRITE_TO_CMD, $forward_file, $fe);
fwrite($forward_file_pipe, $VACATION_FORWARD_EXT_ENTRY."\n");
$SUDO_CMD, $user, $SUDO_OPT_H, $RM_CMD, $forward_file);
$SUDO_CMD, $user, $SUDO_OPT_H, $RM_CMD, $forward_file, $fe);
// echo ('<pre>'."\n"); // |:debug:|
// echo ($vacation_forward_to);
// var_dump($forward_settings);
// echo ('</pre>'."\n");
// |||:sec:||| User Interface
$form = Array();
//$form[] = '<hr class="sep"/>';
$form[] = '<form action="index.php" method="post">';
$form[] = '<div>';
if ($_debug) {
$form[] = sprintf(
'<input type="hidden" name="_DEBUG_" value="%s" />', $_debug);
// Retrieval
$form[] = '<span class="label">';
$form[] = sprintf('<input type="submit" name="refresh" value="%s" />', get_text('refresh'));
$form[] = sprintf('<br /><input type="submit" name="clear" value="%s" />', get_text('clear'));
@@ -492,193 +495,193 @@ if ($_debug) {
if ($is_admin) {
$user_control[] = '<select name="user">';
foreach ($user_names as $sel_user) {
if ($sel_user == $user) {
$selected = ' selected="selected"';
$selected = '';
$user_control[] = sprintf('<option%s>%s</option>', $selected, $sel_user);
$user_control[] = '</select>';
$user_control = implode($user_control, "\n");
$user_control = sprintf(
'<input type="hidden" name="user" value="%s" />%s', $user, $user);
$trow[] = $user_control;
// forward
$user_control = Array();
$user_control[] = '<select name="forward">';
$user_control[] = sprintf('<option value="">%s</option>', get_text('none'));
if (!$is_admin && $sel_user == $user) {
if ($sel_user == $vacation_forward_to) {
// active checkbox
$active_checked = ' checked="checked"';
$active_checked = '';
$user_control[] = sprintf('<input type="checkbox" name="active" value="active"%s /><br />',
$active_checked);
$form[] = sprintf('<tr><td style="text-align: center;">%s</td></tr>', implode($trow, '</td><td style="text-align: center;">'));
$form[] = '</table></div><br />';
$text_rows = 10;
// $text_rows = 3; // |:debug:|
if ( !$x_wsv_raw )
{
$form[] = sshl(get_text('automatic_mode'));
// subject
$form[] = sprintf('<span class="label">%s<sup>*</sup>:</span>', get_text('subject'));
$form[] = (
'<input type="text" name="subject" value="' . htmlspecialchars($vacation_subject, ENT_COMPAT, "UTF-8")
.'" size="49" style="width: 440px;" /><br />');
// message
$form[] = sprintf('<span class="label">%s<sup>*</sup>:</span>', get_text('body'));
'<textarea name="body" cols="56" rows="'.$text_rows.'"'
.' style="vertical-align: top; width: 440px;">' . htmlspecialchars($vacation_body, ENT_NOQUOTES, "UTF-8") . '</textarea><br />');
// actions
$form[] = '<hr class="sep"/>';
$form[] = '<span class="label"> </span>';
$form[] = sprintf('<input type="submit" name="save" value="%s" />', get_text('save'));
//$form[] = ' ' . get_text('enable_encoding');
if ($x_wsv_raw || $EXPERT_ENABLED)
if ( $x_wsv_raw ) {
$text_rows = 15;
$id = null;
$text_rows = 5;
$id = 'expert-mode';
$form[] = sshl(get_text('expert_mode'), $id);
# $form[] = sshl('<a href="#">'.get_text('expert_mode').'</a>', 'expert-mode-head');
// raw message
$form[] = sprintf('<span class="label">%s<sup>*</sup>:</span>', get_text('message'));
'<textarea name="message" cols="56" rows="'.$text_rows.'"'
.' style="vertical-align: top; width: 440px;">' . htmlspecialchars($vacation_msg, ENT_NOQUOTES, "UTF-8") . '</textarea><br />');
.' style="vertical-align: top; width: 440px;">' . htmlspecialchars($vacation_msg_in, ENT_NOQUOTES, "UTF-8") . '</textarea><br />');
'<span style="display: inline-block; width: 440px; margin-top: 5px; font-size: 8pt;">'
. get_text('explain_expert')
.'</span><br />');
$form[] = sprintf('<input type="submit" name="raw" value="%s" />', get_text('save'));
//$form[] = ' ' . get_text('disable_encoding');
$form[] = '</div>';
//$form[] = '<span class="label"> </span>';
'<span style="display: inline-block; width: 550px;"><sup>*</sup>'
. get_text('explain_subject')
// |||:sec:||| Vacation History
$vacation_list_cmd = sprintf(
'%s -u %s %s %s -l', $SUDO_CMD, $user, $SUDO_OPT_H, $VACATION_CMD);
// echo ('<pre>'."\n");
// echo ($vacation_list_cmd);
// fprintf($stderr, "\$vacation_list_cmd: %s<br>\n", $vacation_list_cmd);
$vacation_ausgabe = popen ($vacation_list_cmd, 'r');
$vacation_list = stream_get_contents($vacation_ausgabe);
pclose($vacation_ausgabe);
if (!empty ($vacation_list)) {
$form[] = shl(get_text('reply_history'));
// $form[] = '<hr class="sep"/>';
$form[] = '<pre>';
$form[] = $vacation_list;
$form[] = '</pre>';
$form[] = sprintf('<input type="submit" name="delete" value="%s" /><br />', get_text('delete'));
$form[] = ('<hr class="sep"/>');
$form[] = shl(get_text('reply_history_empty'));
$form[] = '</form>';
echo implode($form, "\n");
// |||:sec:||| Administrator Manual
echo shl(get_text('manual_headline'));
echo (sprintf('<a href="%s">%s</a><br />'."\n", get_text('manual_link'), get_text('manual')));
// |||:sec:||| Debug
echo "<pre>\n"; // |:debug:|
echo "\$_REQUEST: \n";
var_dump($_REQUEST);
echo "</pre>\n";
echo "\$_SERVER: \n";
var_dump($_SERVER);
echo $FOOT;
//
// :ide-menu: Emacs IDE Menu - Buffer @BUFFER@
// . M-x `eIDE-menu' ()(eIDE-menu "z")
// :ide: COMPILE: PHP _DEBUG_=2 _DEBUG_TEST_=2
// . (compile (concat "php " (file-name-nondirectory (buffer-file-name)) " _DEBUG_=2 _DEBUG_TEST_=2"))
// :ide: QUO: $this->
// . (insert "$this->" )
// :ide: COMPILE: PHP w/o args
// . (compile (concat "php " (file-name-nondirectory (buffer-file-name)) ""))
// :ide: COMPILE: PHP _DEBUG_=1 _DEBUG_TEST_=1
Status change: