Changeset - r27:4d96cfceba10
[Not reviewed]
v0.7 default
0 2 0
Wolfgang Scherer (ws) - 13 years ago 2012-03-31 21:18:55
wolfgang.scherer@gmx.de
index.php: cut'n'paste error fixed.
2 files changed with 16 insertions and 2 deletions:
0 comments (0 inline, 0 general)
index.php
Show inline comments
 
@@ -367,193 +367,193 @@ if ($_debug) {
 

	
 
$trow = Array();
 

	
 
// user
 
$user_control = Array();
 
if ($is_admin) {
 
    $user_control[] = '<select name="user">';
 
    foreach ($user_names as $sel_user) {
 
        if ($sel_user == $user) {
 
            $selected = ' selected="selected"';
 
        } else {
 
            $selected = '';
 
        }
 
        $user_control[] = sprintf('<option%s>%s</option>', $selected, $sel_user);
 
    }
 
    $user_control[] = '</select>';
 
    $user_control = implode($user_control, "\n");
 
} else {
 
    $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'));
 
$selected = '';
 
foreach ($user_names as $sel_user) {
 
    if (!$is_admin && $sel_user == $user) {
 
        continue;
 
    }
 
    if ($sel_user == $vacation_forward_to) {
 
        $selected = ' selected="selected"';
 
    } else {
 
        $selected = '';
 
    }
 
    $user_control[] = sprintf('<option%s>%s</option>', $selected, $sel_user);
 
}
 
$user_control[] = '</select>';
 
$user_control = implode($user_control, "\n");
 
$trow[] = $user_control;
 

	
 
// active checkbox
 
$user_control = Array();
 
if ($forward_active) {
 
    $active_checked = ' checked="checked"';
 
} else {
 
    $active_checked = '';
 
}
 
$user_control[] = sprintf('<input type="checkbox" name="active" value="active"%s /><br />',
 
                          $active_checked);
 
$user_control = implode($user_control, "\n");
 
$trow[] = $user_control;
 

	
 
$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'));
 
    $form[] = (
 
        '<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">&nbsp;</span>';
 
    $form[] = sprintf('<input type="submit" name="save" value="%s" />', get_text('save'));
 
    //$form[] = ' ' . get_text('enable_encoding');
 
    $form[] = '<hr class="sep"/>';
 
}
 

	
 
if ($x_wsv_raw || $EXPERT_ENABLED)
 
{
 
    if ( $x_wsv_raw ) {
 
        $text_rows = 15;
 
    } else {
 
        $text_rows = 5;
 
    }
 
    $form[] = sshl(get_text('expert_mode'));
 
    // raw message
 
    $form[] = sprintf('<span class="label">%s<sup>*</sup>:</span>', get_text('message'));
 
    $form[] = (
 
        '<textarea name="body" cols="56" rows="'.$text_rows.'"'
 
        '<textarea name="message" cols="56" rows="'.$text_rows.'"'
 
        .' style="vertical-align: top; width: 440px;">' . htmlspecialchars($vacation_msg, ENT_NOQUOTES, "UTF-8") . '</textarea><br />');
 

	
 
    $form[] = '<span class="label">&nbsp;</span>';
 
    $form[] = (
 
        '<span style="display: inline-block; width: 440px; margin-top: 5px; font-size: 8pt;">'
 
        . get_text('explain_expert')
 
        .'</span><br />');
 

	
 
    $form[] = '<hr class="sep"/>';
 
    $form[] = '<span class="label">&nbsp;</span>';
 
    $form[] = sprintf('<input type="submit" name="raw" value="%s" />', get_text('save'));
 
    //$form[] = ' ' . get_text('disable_encoding');
 
    $form[] = '<hr class="sep"/>';
 

	
 
}
 

	
 
//$form[] = '<span class="label">&nbsp;</span>';
 
$form[] = (
 
    '<span style="display: inline-block; width: 550px;"><sup>*</sup>'
 
    . get_text('explain_subject')
 
    .'</span><br />');
 

	
 
// --------------------------------------------------
 
// |||: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);
 
// echo ('</pre>'."\n");
 
$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[] = '<hr class="sep"/>';
 
    $form[] = '<span class="label">&nbsp;</span>';
 
    $form[] = sprintf('<input type="submit" name="delete" value="%s" /><br />', get_text('delete'));
 
    if ($is_admin) {
 
        $form[] = ('<hr class="sep"/>');
 
    }
 
} else {
 
    $form[] = shl(get_text('reply_history_empty'));
 
}
 

	
 
$form[] = '</div>';
 
$form[] = '</form>';
 
echo implode($form, "\n");
 

	
 
// --------------------------------------------------
 
// |||:sec:||| Administrator Manual
 
// --------------------------------------------------
 

	
 
if ($is_admin) {
 
    echo shl(get_text('manual_headline'));
 
    echo (sprintf('<a href="%s">%s</a><br />'."\n", get_text('manual_link'), get_text('manual')));
 
}
 

	
 
// --------------------------------------------------
 
// |||:sec:||| Debug
 
// --------------------------------------------------
 

	
 
if ($_debug) {
 
    echo "<pre>\n";                 // |:debug:|
 
    echo "\$_REQUEST: \n";
 
    var_dump($_REQUEST);
 
    echo "</pre>\n";
 

	
 
    echo "\$_SERVER: \n";
 
    echo "<pre>\n";                 // |:debug:|
 
    var_dump($_SERVER);
 
    echo "</pre>\n";
 
}
 

	
 
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
 
// . (compile (concat "php " (file-name-nondirectory (buffer-file-name)) " _DEBUG_=1 _DEBUG_TEST_=1"))
lib/util.php
Show inline comments
 
@@ -205,194 +205,208 @@ if ( True && isset($_SERVER['HTTP_ACCEPT
 
    foreach ($preferred_languages as $plang) {
 
        if (array_key_exists($plang, $LC_LANGUAGES)) {
 
            $LC_MESSAGES = $LC_LANGUAGES[$plang];
 
            break;
 
        }
 
    }
 
}
 

	
 
function get_text($text)
 
{
 
    global $LC_MESSAGES_EN;
 
    global $LC_MESSAGES;
 
    if ( !array_key_exists($text, $LC_MESSAGES))
 
    {
 
        if ( array_key_exists($text, $LC_MESSAGES_EN) )
 
        {
 
            return $LC_MESSAGES_EN[$text];
 
        }
 
        return $text;
 
    }
 
    return $LC_MESSAGES[$text];
 
}
 

	
 
// --------------------------------------------------
 
// |||:sec:||| Überschrift/Fehlermeldung
 
// --------------------------------------------------
 

	
 
function shl($message)
 
{
 
    return sprintf('<h3>%s</h3>', $message);
 
}
 

	
 
function sshl($message)
 
{
 
    return sprintf('<h4>%s</h4>', $message);
 
}
 

	
 
function hl($message)
 
{
 
    echo shl($message)."\n";
 
}
 

	
 
function error_msg($message)
 
{
 
    echo sprintf('<div class="error"><strong>%s</strong></div>'."\n", $message);
 
}
 

	
 
// --------------------------------------------------
 
// |||:sec:||| vaccation(1) message
 
// --------------------------------------------------
 

	
 
// 2.2. Header Fields
 
//    Header fields are lines beginning with a field name, followed by a
 
//    colon (":"), followed by a field body, and terminated by CRLF.  A
 
//    field name MUST be composed of printable US-ASCII characters (i.e.,
 
//    characters that have values between 33 and 126, inclusive), except
 
//    colon.  A field body may be composed of printable US-ASCII characters
 
//    as well as the space (SP, ASCII value 32) and horizontal tab (HTAB,
 
//    ASCII value 9) characters (together known as the white space
 
//    characters, WSP).  A field body MUST NOT include CR and LF except
 
//    when used in "folding" and "unfolding", as described in section
 
//    2.2.3.  All field bodies MUST conform to the syntax described in
 
//    sections 3 and 4 of this specification.
 

	
 
function message_split($message)
 
{
 
    $lines = explode("\n", ltrim($message));
 
    $headers = Array();
 
    $body = '';
 
    $check_from = True;
 
    $current_field = '';
 
    while (True) {
 
        $line = array_shift($lines);
 
        $tline = trim($line);
 
        if (empty($tline)) {
 
            break;
 
        }
 
        if ($check_from) {
 
            $check_from = False;
 
            if ( preg_match('/^From /', $line) ) {
 
                continue;
 
            }
 
        }
 
        $matches = Array();
 
        if ( preg_match('/(^[!-~]+):/', $line, $matches)) {
 
            $current_field = strtolower($matches[1]);
 
            $headers[$current_field] = $line;
 
            continue;
 
        }
 
        if (!empty($current_field))
 
        {
 
            $headers[$current_field] .= "\n" . $line;
 
            continue;
 
        }
 
        $headers[] = $line;
 
    }
 
    $body = implode($lines, "\n");
 

	
 
    $body = implode($lines, "\n");
 
    global $_debug;
 
    if ( $_debug ) {
 
        echo "<pre>\n";
 
        echo "--------------------------------------------------\n";
 
        echo "headers\n";
 
        echo "--------------------------------------------------\n";
 
        var_dump($headers);
 
        echo "--------------------------------------------------\n";
 
        echo "body\n";
 
        echo "--------------------------------------------------\n";
 
        var_dump($body);
 
        echo "</pre>\n";
 
    }
 

	
 
    return Array($headers, $body);
 
}
 

	
 
function message_join($headers, $body)
 
{
 
    return sprintf("%s\n\n%s", implode($headers, "\n"), $body);
 
}
 

	
 
function header_set(&$headers, $header)
 
{
 
    $matches = Array();
 
    if (preg_match('/^([!-~]+):/', $header, $matches)) {
 
        $headers[$matches[1]] = trim($header);
 
    }
 
}
 

	
 
function header_field_body(&$headers, $field_name)
 
{
 
    if (array_key_exists($field_name, $headers)) {
 
        $field = $headers[$field_name];
 
        $field_body = preg_replace('/^[^:]+: */', '', $field);
 
    } else {
 
        $field_body = '';
 
    }
 
    return $field_body;
 
}
 

	
 
function header_clean(&$headers)
 
{
 
    global $HEADER_REMOVE;
 
    $clean_headers = Array();
 
    foreach ($headers as $field_name => $field) {
 
        if ( substr($field_name, 0 , 2) == 'x-' )
 
        {
 
            continue;
 
        }
 
        if (in_array($field_name, $HEADER_REMOVE))
 
        {
 
            continue;
 
        }
 
        $clean_headers[$field_name] = $field;
 
    }
 
    return $clean_headers;
 
}
 

	
 
if (!function_exists("quoted_printable_encode")) {
 
    // only available with PHP >= 5.3.0
 
    if (function_exists("imap_8bit")) {
 
        function quoted_printable_encode($string) {
 
            return imap_8bit($string);
 
        }
 
    } else {
 
        /**
 
         * Process a string to fit the requirements of RFC2045 section 6.7. Note that
 
         * this works, but replaces more characters than the minimum set. For readability
 
         * the spaces and CRLF pairs aren't encoded though.
 
         */
 
        function quoted_printable_encode($string) {
 
            $string = str_replace(array('%20', '%0D%0A', '%'), array(' ', "\r\n", '='), rawurlencode($string));
 
            $string = preg_replace('/[^\r\n]{73}[^=\r\n]{2}/', "$0=\r\n", $string);
 
            return $string;
 
        }
 
    }
 
}
 

	
 
// there should be no need ... quoted_printable_decode is around since PHP4
 
if (!function_exists("quoted_printable_decode")) {
 
    if (function_exists("imap_qprint")) {
 
        echo "imap_qprint";
 
        function quoted_printable_decode($string) {
 
            return imap_qprint($string);
 
        }
 
    }
 
}
 

	
 
// Difference between Q-encoding and quoted-printable
 

	
 
// The ASCII codes for the question mark ("?") and equals sign ("=")
 
// may not be represented directly as they are used to delimit the
 
// encoded-word. The ASCII code for space may not be represented
 
// directly because it could cause older parsers to split up the
 
// encoded word undesirably. To make the encoding smaller and easier
 
// to read the underscore is used to represent the ASCII code for
 
// space creating the side effect that underscore cannot be
 
// represented directly. Use of encoded words in certain parts of
 
// headers imposes further restrictions on which characters may be
 
// represented directly.
 

	
 
function Q_encode ($string)
 
{
 
    $estring = quoted_printable_encode($string);
 
    if ( $estring != $string ) {
 
        $estring = preg_replace('/[?]/', '=3F', $estring);
 
        $estring = preg_replace('/[_]/', '=5F', $estring);
 
        $estring = preg_replace('/[ ]/', '_', $estring);
 
        $estring = sprintf('=?utf-8?Q?%s?=', $estring);
0 comments (0 inline, 0 general)