forked from web-cyradm/web-cyradm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
174 lines (144 loc) · 5.06 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<?php
if (file_exists("./config/special_defines.php")) {
require("./config/special_defines.php");
}
function getmicrotime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
function get_var_dump(&$var, $name = NULL){
ob_start();
echo '<pre class="varDump" style="color: black; background-color: silver; font-family: monospace; border: 2px dotted red; display: block;">';
if ($name !== NULL){
echo $name . ":\n";
}
var_dump($var);
echo '</pre>';
$ret = ob_get_contents();
ob_end_clean();
return $ret;
}
if (file_exists("./migrate.php")){
die(_("migrate.php exists! please delete or rename it"));
}
if ( !defined('WC_BASE') ) define('WC_BASE', dirname(__FILE__));
$wc_configured = @file_exists(WC_BASE . '/config/conf.php');
if ($wc_configured){
@include "DB.php";
if (!class_exists("DB")) {
die("Can't find PEAR:DB extension.");
}
#require "DB.php";
include WC_BASE . "/config/conf.php";
include WC_BASE . "/lib/nls.php";
include WC_BASE . "/lib/crypto.php";
include WC_BASE . "/lib/log.php";
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
$browserlang = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
} else {
$browserlang = 'en_EN';
}
require_once WC_BASE . "/session.php";
// 1nd) If there is a language setting in the session, use this instead
// 2st) Try to get the language from the browser
// 3rd) If none of the above is true, use the default language
if (isset($_SESSION['LANG'])){
// Use Language setting from session
$LANG = $_SESSION['LANG'];
}
elseif (isset($nls['aliases'][substr($browserlang[0], 0, 2)])){
// Get language from the browser
$LANG = $nls['aliases'][substr($browserlang[0], 0, 2)];
} else {
// Fall back to default language
//$LANG = $DEFAULTLANG;
$LANG = $nls['aliases'][substr($DEFAULTLANG,0,2)];
}
// For testing porpose, GET variable LANG overrides all
// $LANG = (! empty($_GET['LANG']))?($_GET['LANG']):($LANG);
if (isset($_GET['LANG'])){
$LANG=$_GET['LANG'];
}
if (isset($_SESSION['init'])) {
include WC_BASE . "/init.php";
}
include WC_BASE . "/header.inc.php";
setlocale(LC_MESSAGES, $LANG);
setlocale(LC_ALL, $LANG);
putenv("LANG=" . $LANG);
putenv("LANGUAGE=" . $LANG);
// Specify location of translation tables
bindtextdomain("web-cyradm", "./locale");
// Choose domain
textdomain("web-cyradm");
if ($_SESSION['session_ok'] === TRUE) {
require WC_BASE . "/validate.inc.php";
if (empty($_GET['action']) || $_GET['action'] != 'logout') {
require WC_BASE . "/menu.inc.php";
}
require WC_BASE . "/lib/cyradm.php";
// if (empty($_GET['domain']) && (empty($_GET['action']) || (! in_array($_GET['action'], array('logout', 'adminuser', 'newdomain', 'editadminuser', 'newadminuser', 'search'))))){
if (!isset($action) OR
empty($domain) AND !in_array($action, array('logout', 'adminuser', 'editadminuser',
'deleteadminuser', 'newadminuser',
'search', 'settings', 'changeadminpasswd',
'display','browse'))){
include WC_BASE . "/welcome.php";
} else {
# Only allow defined actions and include them
if (isset($_GET['action']) AND
in_array($_GET['action'], array('logout', 'browse', 'editdomain', 'manageaccount',
'newdomain', "deletedomain",
"adminuser", "newadminuser",
"editadminuser", "deleteadminuser",
"editaccount", "newaccount",
"deleteaccount", "vacation",
"forwardalias", "forwardaccount",
"newemail", "deleteemail",
"editemail", "aliases", "newalias",
"editalias", "deletealias", "search",
"delete_catchall", "settings",
"changeadminpasswd", "display"))){
include sprintf('%s/%s.php', WC_BASE, $_GET['action']);
}
# For password related stuff we also need to allow POST vars for some actions
else if (isset($_POST['action']) AND
in_array($_POST['action'], array('newaccount', 'manageaccount',
'newadminuser', 'editadminuser',
'changeadminpasswd'))){
include sprintf('%s/%s.php', WC_BASE, $_POST['action']);
}
else {
switch ($_GET['action']){
case "accounts":
include WC_BASE . "/browseaccounts.php";
break;
case "catch":
include WC_BASE . "/catchall.php";
break;
default:
include WC_BASE . "/browse.php";
break;
}
}
}
include WC_BASE . "/footer.inc.php";
} else {
include WC_BASE . "/login.php";
}
} else {
print "<h1>";
print _("web-cyradm has not yet been configured");
print "</h1>";
print "<p>";
print _("Configuration steps:");
print "<ul><li>";
print _("copy the config file that comes with the distribution: ");
print "<b>cp config/conf.php.dist config/conf.php</b>";
print "</li><li>";
print _("Edit the file config/conf.php to match your systems configuration");
print "</ul>";
print _("Further information about how to configure Web-cyradm can be found at the following website:");
print "<br><a href=\"http://www.delouw.ch/linux/Postfix-Cyrus-Web-cyradm-HOWTO/html/index.html\" target=_new>Postfix-Cyrus-Web-cyradm-HOWTO</a>";
die();
}