Changeset - r30:de0b00cc9fec
[Not reviewed]
v0.8 default
0 3 0
Wolfgang Scherer (ws) - 13 years ago 2012-04-02 17:07:31
wolfgang.scherer@gmx.de
index.php: show/hide export mode (jQuery).
3 files changed with 47 insertions and 3 deletions:
0 comments (0 inline, 0 general)
index.php
Show inline comments
 
@@ -61,105 +61,138 @@ if (isset($_REQUEST["user"])) {
 
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;
 
}
 
h4._more, h4._less {
 
    cursor: pointer;
 
}
 
h4._more:after {
 
    content: "...";
 
    font-weight: bold;
 
    padding-left: 4px;
 
}
 
h4._less:before {
 
    content: "^";
 
    font-weight: bold;
 
    padding-right: 4px;
 
}
 
';
 

	
 
$headers = '<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>';
 

	
 
$script ='
 
jQuery(document).ready(function(){
 
    $("#expert-mode").click(function(ev) {
 
        ev.preventDefault();
 
        var jthis = $(this);
 
        var contents = jthis.next();
 
        if (contents.is(":visible")) {
 
            jthis.addClass("_more");
 
            jthis.removeClass("_less");
 
            contents.hide();
 
        } else {
 
            jthis.removeClass("_more");
 
            jthis.addClass("_less");
 
            contents.show();
 
        }
 
        return false;
 
    }).click();
 
});
 
';
 

	
 
echo substitute_elements(
 
    $HEAD, Array(
 
        'title' => trim($title),
 
        'css' => trim($css),
 
        'headers' => trim($headers),
 
        '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 ('<pre>'."\n");            // |:debug:|
 
    echo ('user: ' . $user . "\n");
 
    echo ('home: ' . $home . "\n");
 
    echo ('</pre>'."\n");
 
}
 

	
 
$vacation_msg_file = sprintf('%s/%s', $home, $VACATION_MSG_FILE);
 
$vacation_db_file = sprintf('%s/%s', $home, $VACATION_DB_FILE);
 
$forward_file = sprintf('%s/%s', $home, $FORWARD_FILE);
 
$forward_active = file_exists($forward_file);
 
$forward_settings = Array(
 
    '\\'.$user, '', sprintf($VACATION_FORWARD_ENTRY, $user));
 
if ($forward_active)
 
{
 
@@ -408,117 +441,122 @@ foreach ($user_names as $sel_user) {
 
$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;
 
        $id = null;
 
    } else {
 
        $text_rows = 5;
 
        $id = 'expert-mode';
 
    }
 
    $form[] = sshl(get_text('expert_mode'));
 
    $form[] = sshl(get_text('expert_mode'), $id);
 
#    $form[] = sshl('<a href="#">'.get_text('expert_mode').'</a>', 'expert-mode-head');
 
    $form[] = '<div>';
 
    // raw message
 
    $form[] = sprintf('<span class="label">%s<sup>*</sup>:</span>', get_text('message'));
 
    $form[] = (
 
        '<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[] = '</div>';
 

	
 
}
 

	
 
//$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'));
lib/template.php
Show inline comments
 
@@ -37,88 +37,89 @@
 

	
 
## 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 <http://www.gnu.org/licenses/>,
 
## or write to Wolfgang Scherer, Sudetenstr. 48, D-97340
 
## Marktbreit or <Wolfgang.Scherer at gmx.de>
 
-->
 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
 
  <head>
 
    <meta http-equiv="cache-control" content="no-cache" />
 
    <meta http-equiv="pragma" content="no-cache" />
 
    <meta http-equiv="expires" content="-1" />
 
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
 
    <meta http-equiv="content-style-type" content="text/css" />
 
    <title>@title@</title>
 
    <link rel="stylesheet" href="css/basic.css" type="text/css" />
 
    <link rel="stylesheet" href="css/ws-project.css" type="text/css" />
 
<!-- (progn (forward-line 1)(snip-insert-mode "html.h.script.file" t)) -->
 
<!-- (progn (forward-line 1)(snip-insert-mode "html.h.script" t)) -->
 
<!-- (progn (forward-line 1)(snip-insert-mode "html.h.style" t)) -->
 
    <style type="text/css"><!--
 
a, a:link, a:visited {
 
    text-decoration:none;
 
}
 
a:hover {
 
    background-color: #dddddd !important;
 
}
 
a:focus {
 
    background-color: #cccccc !important;
 
}
 
.light {
 
    color: #2e90ff;
 
}
 
.dark {
 
    color: #0e60ff;
 
}
 
.error {
 
    color: #dd0000;
 
}
 
.warning {
 
    color: #ff0e60;
 
}
 
@css@
 
      --></style>
 
@headers@
 
    <script type="text/javascript"><!--
 
@script@
 
      //--></script>
 
  </head>
 
  <body>
 
    <div id="body">
 
    <!-- |:here:| -->
 
';
 

	
 
$FOOT = '<!-- |:here:| -->
 
    </div>
 
    <div id="copyright-notice">
 
      Copyright (C) 2012, Wolfgang Scherer;
 
      Sponsored by <a href="http://www.wiedenmannseile.de">WIEDENMANN SEILE GMBH</a>
 
    </div>
 
  </body>
 
</html>
 
';
 

	
 
//
 
// :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"))
 

	
 
//
 
// Local Variables:
 
// mode: php
 
// snip-mode: html
 
// End:
 
?>
lib/util.php
Show inline comments
 
@@ -189,99 +189,104 @@ function substitute_elements (
 
// --------------------------------------------------
 

	
 
if (!array_key_exists($LANGUAGE, $LC_LANGUAGES)) {
 
    $LANGUAGE = 'en';
 
}
 
$LC_MESSAGES_EN = $LC_LANGUAGES['en'];
 
$LC_MESSAGES = $LC_LANGUAGES[$LANGUAGE];
 

	
 
if ( True && isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
 
{
 
    $accept_language = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
 
    $accept_language = preg_replace('/;[^,;]*/', '', $accept_language);
 
    $preferred_languages = explode(',', $accept_language);
 
    // if (isset($_REQUEST['_DEBUG_'])) {
 
    //     var_dump($preferred_languages);
 
    // }
 
    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)
 
function sshl($message, $id=null)
 
{
 
    return sprintf('<h4>%s</h4>', $message);
 
    if ( isset($id) ) {
 
        $id_fmt = sprintf(' id="%s"', $id);
 
    } else {
 
        $id_fmt = '';
 
    }
 
    return sprintf('<h4%s>%s</h4>', $id_fmt, $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;
 
            }
 
        }
0 comments (0 inline, 0 general)