-
Notifications
You must be signed in to change notification settings - Fork 21
/
index.php
148 lines (111 loc) · 3.75 KB
/
index.php
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
// +----------------------------------------------------------------+
// | index.php |
// | Function: Open the signup screen and newuser page |
// +----------------------------------------------------------------+
// | AtMail Open - Licensed under the Apache 2.0 Open-source License|
// | http://opensource.org/licenses/apache2.0.php |
// +----------------------------------------------------------------+
require_once('header.php');
// Check for system installation
if (!file_exists('libs/Atmail/Config.php'))
redirectToInstaller();
require_once('Global.php');
// Check again for system installation, just in case Config.php
// was manually created
if (!$pref['installed'])
redirectToInstaller();
/** For future use
if (isset($_REQUEST['mode']) && !empty($_REQUEST['mode'])) {
$file = $_REQUEST['mode'] . '.php';
if (file_exists($file)) {
include($file);
$atmail->end();
}
}
*/
$var = array();
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)
$var['browser'] = "ie";
else
$var['browser'] = "ns";
$atmail = new AtmailGlobal();
$var['func'] = $_REQUEST['func'];
$var['version'] = $pref['version'];
if (!$atmail->Language)
$atmail->Language = $atmail->param('Language');
// If the user if logging off, print a cookie header with
// a blank SessionID. Delete the Session for the DB too
if ( $var['func'] == "logout" )
{
require_once('Session.php');
session_start();
$auth =& $atmail->getAuthObj();
// Find the users current settings, if to delete the trash on logout
//$atmail->cookie_read($auth);
//$auth->getuser();
$atmail->username = $auth->username;
$atmail->pop3host = $auth->pop3host;
$atmail->SessionID = $auth->SessionID;
//$atmail->cookie_header_delete();
if (!$pref['opensource']) {
$var['ErrorHead'] = $atmail->parse("html/$atmail->Language/msg/logoff.html");
$var['ErrorHead'] .= "<script language='Javascript'>window.focus();</script>";
}
$atmail->clean_tmp();
// clear tmp directory
if ($handle = opendir($pref['install_dir'].'/tmp/')) {
while (false !== ($file_name = readdir($handle))) {
if ($file_name != "." && $file_name != ".." && $file_name != '.htaccess' && is_file($file_name)) {
if (strtotime("+ 180 seconds") > fileatime($file_name)) {
unlink($file_name);
}
}
}
closedir($handle);
}
// If we have expunge on logout ( e.g PDMF IMAP server)
if($pref['expunge_logout'] == '1') {
$atmail->status = $auth->getuser( $atmail->SessionID );
$atmail->loadprefs(1);
require_once('GetMail.php');
$mail = new GetMail(array(
'Username' => $atmail->username,
'Pop3host' => $atmail->pop3host,
'Password' => $auth->password,
'Mode' => $atmail->Mode,
'Type' => $atmail->MailType)
);
if($atmail->MailType == 'imap') {
$mail->login();
$folders = $mail->listfolders();
// Create a new folder-tree element
$mail->newfolder_tree();
// Loop through each of the folders
foreach ($folders as $folder)
{
$mail->expunge($folder);
}
}
}
session_destroy();
}
$var['Ajax'] = '1';
$var['error'] = $_REQUEST['error'];
$atmail->LoginType = "simple";
$atmail->Ajax = '1';
$atmail->Language = 'english';
$atmail->FontStyle = 'Verdana';
$var['atmailstyle'] = $atmail->parse("html/$atmail->Language/simple/atmailstyle.css" );
$var['mailstyle'] = $atmail->parse("html/$atmail->Language/simple/atmailstyle-mail.css");
$var['func'] = 'login';
$atmail->FromField = 'me';
print $atmail->parse("html/$atmail->Language/simple/showmail_interface.html", $var);
$atmail->end();
function redirectToInstaller()
{
if (!file_exists('install/index.php')) {
die('your @Mail system has not yet been configured');
}
header('Location: install/');
}