File: status.php3

package info (click to toggle)
imp 3%3A2.2.6-5.2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 5,476 kB
  • ctags: 766
  • sloc: php: 4,253; sh: 831; makefile: 98; perl: 50; pascal: 15
file content (112 lines) | stat: -rw-r--r-- 4,555 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php

/*
 
 $Horde: imp/status.php3,v 2.7.2.23 2001/11/09 16:47:06 chuck Exp $
 $Author: chuck $
 $Revision: 2.7.2.23 $
 $Date: 2001/11/09 16:47:06 $
 
 IMP: Copyright 1998, 1999, 2000 by Charles J. Hagenbuch <chuck@horde.org>
 
 You should have received a copy of the GNU Public
 License along with this package; if not, write to the
 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.
 
*/

require '../lib/horde.lib';
require './lib/imp.lib';
require './config/defaults.php3';

/* Html styles configuration */
require './config/html.php3';
require './config/mailbox.php3';
require './lib/version.php';

/* get some locale stuff defined elsewhere to minimize locale impact */
require './config/lang.php3';
$language = select_lang();
require './lib/postconf.php3';
require "./locale/$language/message.lang";
require "./locale/local/message.lang";
$Lang_From = $lang->from;
$Lang_Subject = $lang->subject;
/* end relocatable stuff (for 2.1) */

require "./locale/$language/status.lang";
require './locale/local/status.lang';
require './config/lang.php3';
$sidebar = true;

/* can we log in? */
page_open(array('sess' => 'HordeSession'));
page_close();
if (isset($imp)) $imp->unpickle();
$title = $lang->status_title;
$message = htmlspecialchars($message);

/* doctype */
require "$default->include_dir/doctype.inc";

/* if we can log in, do so and get the mail stats for this mailbox */
if (!empty($default->refresh_delay) && isset($imp) && isset($imp->user) && $imp->user != '') {
    $imp->authenticate(OP_HALFOPEN);
    if ($imp->servtype == 'pop3') {
        $server_string = '{' . $imp->server . ':' . $imp->port . '}';
    } else {
        $server_string = '{' . $imp->server . ':' . $imp->port . '}' . $imp->mailbox;
    }
    $mailinfo = @imap_status($imp->stream, $server_string, SA_MESSAGES | SA_RECENT | SA_UNSEEN);
    if ($mailinfo) {
        $message = $lang->mailbox_status($message, $mailinfo->unseen, $mailinfo->recent);
        
        /* If they want it, we can give them a "new mail" popup */
        if ($default->newmail_popup) {
            // set the javascript to reload, so that we don't reload if there's been an alert popup already
            $script = '<script language="javascript">var alerted = false; window.setTimeout("if (!alerted) window.location.reload();", ' . ($default->refresh_delay * 1000) . ');</script>';
            if ($mailinfo->recent > 0) {
                /* reopen the stream to the current mailbox */
                imap_reopen($imp->stream, '{' . $imp->server . ':' . $imp->port . '}' . $imp->mailbox);
                /* Grab the From and Header of the most recent one */
                $h = imap_header($imp->stream, $mailinfo->messages);
                
                /* initialize the header fields */
                $frm = '';
                $sub = '';
                
                if (is_object($h)) {
                    if (isset($h->from[0])) {
                        $from = $h->from[0];
                        if (isset($from->personal)) {
                            $frm = trim(decode_mime_string($from->personal));
                        } else if (isset($from->mailbox) && isset($from->host))
                            $frm = $from->mailbox . '@' . $from->host;
                        else if (isset($h->fromaddress))
                            $frm = trim(decode_mime_string($h->fromaddress));
                    } else if (isset($h->fromaddress))
                        $frm = trim(decode_mime_string($h->fromaddress));
                    if (isset($h->subject)) $sub = trim(decode_mime_string($h->subject));
                }
                
                if (strlen($frm) > $default->max_frm_chars) $frm = substr($frm, 0, $default->max_frm_chars) . '...';
                if (strlen($sub) > $default->max_sub_chars) $sub = substr($sub, 0, $default->max_sub_chars) . '...';
                
                // make sure to set alerted to true, so we know not to reload anymore
                $script .= '<script language="javascript">window.alert("' . addslashes($lang->newmail_msg) . '\n\n' .
                    $Lang_From . ': ' .
                    addslashes($frm) . '\n' .
                    $Lang_Subject . ': ' .
                    addslashes($sub) . '");alerted = true;</script>';
            }
        }
    }
}

require "$default->include_dir/generic-header.inc";
require "$default->include_dir/status/body.inc";
require "$default->include_dir/generic-footer.inc";
if (!empty($script)) echo $script;

?>