2017-03-02 18:23:23 +08:00
|
|
|
<?php
|
2017-05-08 21:41:05 +08:00
|
|
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/vars.inc.php';
|
2017-05-17 00:11:58 +08:00
|
|
|
if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/inc/vars.local.inc.php')) {
|
|
|
|
include_once $_SERVER['DOCUMENT_ROOT'] . '/inc/vars.local.inc.php';
|
2017-03-02 18:23:23 +08:00
|
|
|
}
|
|
|
|
|
2017-05-30 03:51:06 +08:00
|
|
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/sessions.inc.php';
|
|
|
|
|
2017-06-07 03:58:48 +08:00
|
|
|
header_remove("X-Powered-By");
|
|
|
|
|
2017-03-02 18:23:23 +08:00
|
|
|
// Yubi OTP API
|
2017-05-08 21:41:05 +08:00
|
|
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/lib/Yubico.php';
|
2017-03-02 18:23:23 +08:00
|
|
|
|
2017-05-07 19:38:31 +08:00
|
|
|
// Autoload composer
|
2017-05-08 21:41:05 +08:00
|
|
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/lib/vendor/autoload.php';
|
2017-05-07 19:38:31 +08:00
|
|
|
|
|
|
|
// U2F API + T/HOTP API
|
|
|
|
$u2f = new u2flib_server\U2F('https://' . $_SERVER['HTTP_HOST']);
|
2017-05-27 05:02:04 +08:00
|
|
|
$tfa = new RobThree\Auth\TwoFactorAuth($OTP_LABEL);
|
2017-03-02 18:23:23 +08:00
|
|
|
|
2017-05-05 16:35:27 +08:00
|
|
|
// Redis
|
|
|
|
$redis = new Redis();
|
|
|
|
$redis->connect('redis-mailcow', 6379);
|
|
|
|
|
2017-03-02 18:23:23 +08:00
|
|
|
// PDO
|
2017-04-21 16:20:31 +08:00
|
|
|
// Calculate offset
|
|
|
|
$now = new DateTime();
|
|
|
|
$mins = $now->getOffset() / 60;
|
|
|
|
$sgn = ($mins < 0 ? -1 : 1);
|
|
|
|
$mins = abs($mins);
|
|
|
|
$hrs = floor($mins / 60);
|
|
|
|
$mins -= $hrs * 60;
|
|
|
|
$offset = sprintf('%+d:%02d', $hrs*$sgn, $mins);
|
|
|
|
|
|
|
|
$dsn = $database_type . ":host=" . $database_host . ";dbname=" . $database_name;
|
2017-03-02 18:23:23 +08:00
|
|
|
$opt = [
|
2017-05-17 00:11:58 +08:00
|
|
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
|
|
|
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
|
|
|
PDO::ATTR_EMULATE_PREPARES => false,
|
2017-07-06 23:34:51 +08:00
|
|
|
PDO::MYSQL_ATTR_INIT_COMMAND => "SET time_zone = '" . $offset . "', group_concat_max_len = 3423543543;",
|
2017-03-02 18:23:23 +08:00
|
|
|
];
|
|
|
|
try {
|
2017-05-17 00:11:58 +08:00
|
|
|
$pdo = new PDO($dsn, $database_user, $database_pass, $opt);
|
2017-03-02 18:23:23 +08:00
|
|
|
}
|
|
|
|
catch (PDOException $e) {
|
|
|
|
?>
|
2017-05-23 15:36:59 +08:00
|
|
|
<center style='font-family: "Lucida Sans Unicode", "Lucida Grande", Verdana, Arial, Helvetica, sans-serif;'>Connection failed, database may be in warm-up state, please try again later.<br /><br />The following error was reported:<br/> <?=$e->getMessage();?></center>
|
2017-03-02 18:23:23 +08:00
|
|
|
<?php
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2017-05-17 00:11:58 +08:00
|
|
|
// Set language
|
2017-05-23 15:36:59 +08:00
|
|
|
if (!isset($_SESSION['mailcow_locale'])) {
|
|
|
|
$_SESSION['mailcow_locale'] = strtolower(trim($DEFAULT_LANG));
|
|
|
|
}
|
2017-05-17 00:11:58 +08:00
|
|
|
if (isset($_GET['lang']) && in_array($_GET['lang'], $AVAILABLE_LANGUAGES)) {
|
|
|
|
$_SESSION['mailcow_locale'] = $_GET['lang'];
|
|
|
|
}
|
|
|
|
|
2017-05-08 21:41:05 +08:00
|
|
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/lang/lang.en.php';
|
|
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/lang/lang.'.$_SESSION['mailcow_locale'].'.php';
|
|
|
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/functions.inc.php';
|
2017-05-23 15:36:59 +08:00
|
|
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/functions.mailbox.inc.php';
|
2017-07-16 17:03:28 +08:00
|
|
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/functions.domain_admin.inc.php';
|
2017-05-23 15:36:59 +08:00
|
|
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/functions.policy.inc.php';
|
2017-05-27 05:02:04 +08:00
|
|
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/functions.dkim.inc.php';
|
|
|
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/functions.fwdhost.inc.php';
|
2017-07-23 02:39:54 +08:00
|
|
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/functions.relayhost.inc.php';
|
2017-06-29 16:29:56 +08:00
|
|
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/functions.fail2ban.inc.php';
|
2017-05-08 21:41:05 +08:00
|
|
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/init_db.inc.php';
|
|
|
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/triggers.inc.php';
|
2017-04-21 16:20:31 +08:00
|
|
|
init_db_schema();
|
2017-08-19 04:18:14 +08:00
|
|
|
if (isset($_SESSION['mailcow_cc_role'])) {
|
|
|
|
set_acl();
|
|
|
|
}
|