blob: 571f1898b4e8fdc243928695e43fe7de1d014281 [file] [log] [blame]
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +01001<?php
2require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/prerequisites.inc.php';
3
4if (isset($_SESSION['mailcow_cc_role']) && isset($_SESSION['oauth2_request'])) {
5 $oauth2_request = $_SESSION['oauth2_request'];
6 unset($_SESSION['oauth2_request']);
7 header('Location: ' . $oauth2_request);
8 exit();
9}
10elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == 'admin') {
11 header('Location: /admin');
12 exit();
13}
14elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == 'domainadmin') {
15 header('Location: /mailbox');
16 exit();
17}
18elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == 'user') {
19 header('Location: /user');
20 exit();
21}
22
23require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/header.inc.php';
24$_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
25$_SESSION['index_query_string'] = $_SERVER['QUERY_STRING'];
26
27?>
28<div class="container">
29 <div class="row">
30 <div class="col-md-offset-3 col-md-6">
31 <div class="panel panel-default">
32 <div class="panel-heading"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> <?= $lang['login']['login']; ?></div>
33 <div class="panel-body">
34 <div class="text-center mailcow-logo"><img src="<?=($main_logo = customize('get', 'main_logo')) ? $main_logo : '/img/cow_mailcow.svg';?>" alt="mailcow"></div>
35 <?php if (!empty($UI_TEXTS['ui_announcement_text']) && in_array($UI_TEXTS['ui_announcement_type'], array('info', 'warning', 'danger')) && $UI_TEXTS['ui_announcement_active'] == 1) { ?>
36 <div class="alert alert-<?=$UI_TEXTS['ui_announcement_type'];?> rot-enc"><?=str_rot13($UI_TEXTS['ui_announcement_text']);?></div>
37 <?php } ?>
38 <legend><?= isset($_SESSION['oauth2_request']) ? $lang['oauth2']['authorize_app'] : $UI_TEXTS['main_name'];?></legend>
39 <?php
40 if (strpos($_SESSION['index_query_string'], 'mobileconfig') !== false) {
41 ?>
42 <div class="alert alert-info"><?= $lang['login']['mobileconfig_info']; ?></div>
43 <?php
44 }
45 ?>
46 <form method="post" autofill="off">
47 <div class="form-group">
48 <label class="sr-only" for="login_user"><?= $lang['login']['username']; ?></label>
49 <div class="input-group">
50 <div class="input-group-addon"><i class="glyphicon glyphicon-user"></i></div>
51 <input name="login_user" autocorrect="off" autocapitalize="none" type="<?=(strpos($_SESSION['index_query_string'], 'mobileconfig') !== false) ? 'email' : 'text';?>" id="login_user" class="form-control" placeholder="<?= $lang['login']['username']; ?>" required="" autofocus="">
52 </div>
53 </div>
54 <div class="form-group">
55 <label class="sr-only" for="pass_user"><?= $lang['login']['password']; ?></label>
56 <div class="input-group">
57 <div class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></div>
58 <input name="pass_user" type="password" id="pass_user" class="form-control" placeholder="<?= $lang['login']['password']; ?>" required="">
59 </div>
60 </div>
61 <div class="form-group">
62 <div class="btn-group">
63 <button type="submit" class="btn btn-success" value="Login"><?= $lang['login']['login']; ?></button>
64 <div class="btn-group">
65 <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
66 <?= $lang['login']['other_logins']; ?> <span class="caret"></span></button>
67 <ul class="dropdown-menu" role="menu">
68 <li><a href="#" id="fido2-login"><?= $lang['login']['fido2_webauthn']; ?></a></li>
69 </ul>
70 </div>
71 </div>
72 <?php if(!isset($_SESSION['oauth2_request'])) { ?>
73 <div class="btn-group pull-right">
74 <button type="button" <?=(isset($_SESSION['mailcow_locale']) && count($AVAILABLE_LANGUAGES) === 1) ? 'disabled="true"' : '' ?> class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
75 <span class="lang-sm lang-lbl" lang="<?= $_SESSION['mailcow_locale']; ?>"></span> <span class="caret"></span>
76 </button>
77 <ul class="dropdown-menu">
78 <?php
79 foreach ($AVAILABLE_LANGUAGES as $language) {
80 ?>
81 <li<?= ($_SESSION['mailcow_locale'] == $language) ? ' class="active"' : ''; ?>><a href="?<?= http_build_query(array_merge($_GET, array('lang' => $language))) ?>"><span class="lang-xs lang-lbl-full" lang="<?= $language; ?>"></span></a></li>
82 <?php } ?>
83 </ul>
84 </div>
85 <?php } ?>
86 </div>
87 </form>
88 <?php
89 if (isset($_SESSION['ldelay']) && $_SESSION['ldelay'] != '0') {
90 ?>
91 <p><div class="alert alert-info"><?= sprintf($lang['login']['delayed'], $_SESSION['ldelay']); ?></b></div></p>
92 <?php } ?>
93 <div id="fido2-alerts"></div>
94 <?php if(!isset($_SESSION['oauth2_request'])) { ?>
95 <legend><span class="glyphicon glyphicon-link" aria-hidden="true"></span> <?=$UI_TEXTS['apps_name'];?></legend>
96 <?php
97 if (!empty($MAILCOW_APPS)) {
98 foreach ($MAILCOW_APPS as $app) {
99 if (getenv('SKIP_SOGO') == "y" && preg_match('/^\/SOGo/i', $app['link'])) { continue; }
100 ?>
101 <a href="<?= htmlspecialchars($app['link']); ?>" role="button" style="margin-bottom:3pt" title="<?= htmlspecialchars($app['description']); ?>" class="btn btn-primary"><?= htmlspecialchars($app['name']); ?></a>&nbsp;
102 <?php
103 }
104 }
105 $app_links = customize('get', 'app_links');
106 if (!empty($app_links)) {
107 foreach ($app_links as $row) {
108 foreach ($row as $key => $val) {
109 ?>
110 <a href="<?= htmlspecialchars($val); ?>" role="button" style="margin-bottom:3pt" class="btn btn-primary"><?= htmlspecialchars($key); ?></a>&nbsp;
111 <?php
112 }
113 }
114 }
115 }
116 ?>
117 </div>
118 </div>
119 </div>
120 <?php if(!isset($_SESSION['oauth2_request'])) { ?>
121 <div class="col-md-offset-3 col-md-6">
122 <div class="panel panel-default">
123 <div class="panel-heading">
124 <a data-toggle="collapse" href="#collapse1"><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span> <?= $lang['start']['help']; ?></a>
125 </div>
126 <div id="collapse1" class="panel-collapse collapse">
127 <div class="panel-body">
128 <?php if ($UI_TEXTS['help_text']) { ?>
129 <p><?=$UI_TEXTS['help_text'];?></p>
130 <?php } else { ?>
131 <p><span style="border-bottom: 1px dotted #999;"><?=$UI_TEXTS['main_name'];?></span></p>
132 <p><?= $lang['start']['mailcow_panel_detail']; ?></p>
133 <p><span style="border-bottom: 1px dotted #999;"><?=$UI_TEXTS['apps_name'];?></span></p>
134 <p><?= $lang['start']['mailcow_apps_detail']; ?></p>
135 <?php } ?>
136 </div>
137 </div>
138 </div>
139 </div>
140 <?php } ?>
141 </div>
142</div><!-- /.container -->
143<?php
144$js_minifier->add('/web/js/site/index.js');
145require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php';