7 private function logout_response($uid) {
8 dbx()->debug(
"dbxLogin run logout");
9 dbx()->sys_msg(
'security',
'login', $uid,
'lock out',
$_SERVER[
'REMOTE_ADDR'] ??
'');
10 $this->send_logout_mail($uid);
12 dbx()->set_modul_var(
'logout', 1);
13 dbx()->debug(
"dbxLogin logout redirect to fresh login form");
14 return dbx()->redirect(
'?dbx_modul=dbxLogin&dbx_run1=login&logout=1', 0);
17 private function mail_enabled($key) {
18 $value =
dbx()->get_config(
'dbxLogin', $key);
19 $value = strtolower(trim((
string)$value));
20 return !in_array($value, array(
'',
'0',
'false',
'off',
'no'),
true);
23 private function send_logout_mail($uid) {
24 if (!$uid || !$this->mail_enabled(
'logout_mail')) {
29 $db = dbx()->get_system_obj(
'dbxDB');
30 $rec =
$db->select1(
'dbxUser', (
int)$uid,
'*', 0);
31 if (!is_array($rec)) {
32 $rec = array(
'id' => $uid);
35 $browser = dbx()->get_system_obj(
'dbxBrowser');
36 $username = (string)($rec[
'uname'] ?? (
'uid-' . (
int)$uid));
37 $tpl = dbx()->get_system_obj(
'dbxTPL');
39 'Zeit' => date(
'Y-m-d H:i:s'),
40 'Benutzername' => $username,
41 'User-ID' => (
string)($rec[
'id'] ?? $uid),
42 'Name' => trim((
string)($rec[
'name'] ??
'') .
' ' . (
string)($rec[
'name2'] ??
'')),
43 'E-Mail' => (
string)($rec[
'email'] ??
''),
44 'Rollen' => (
string)($rec[
'roles'] ??
''),
45 'Request' => (
string)(
$_SERVER[
'REQUEST_URI'] ??
''),
46 'Referer' => (
string)(
$_SERVER[
'HTTP_REFERER'] ??
''),
50 'IP' => (
string)($browser->_ip ??
''),
51 'Host' => (
string)($browser->_host ??
''),
52 'Browser' => (
string)($browser->_name ??
''),
53 'Version' => (
string)($browser->_version ??
''),
54 'Plattform' => (
string)($browser->_platform ??
''),
55 'Geraet' => (
string)($browser->_device ??
''),
56 'Sprache' => (
string)($browser->_language ??
''),
57 'Mobile' => !empty($browser->_mobile) ?
'Ja' :
'Nein',
58 'Tablet/iPad' => !empty($browser->_ipad) ?
'Ja' :
'Nein',
59 'Robot' => !empty($browser->_robot) ?
'Ja' :
'Nein',
60 'Fenster' => (
string)($browser->_width ?? 0) .
' x ' . (
string)($browser->_height ?? 0),
61 'Cookies' => !empty($browser->_cookie) ?
'Ja' :
'Nein',
62 'JavaScript' => !empty($browser->_js) ?
'Ja' :
'Nein',
63 'User-Agent' => (
string)($browser->_agent ?? (
$_SERVER[
'HTTP_USER_AGENT'] ??
'')),
66 $html = $tpl->get_tpl(
'dbxLogin|mail-logout', array(
67 'username' => $this->h($username),
68 'logout_table' => $this->html_info_table($rows),
69 'browser_table' => $this->html_info_table($browserRows),
71 $text = $this->logout_mail_text($rows, $browserRows);
73 dbx()->send_mail(
'logout@dbxapp.de',
'leo4u@gmx.de',
'dbxApp Logout: ' . $username, $html,
'html', array(), array(
'text' => $text));
74 }
catch (\Throwable $e) {
75 dbx()->sys_msg(
'error',
'login', (
int)$uid,
'logout mail failed', $e->getMessage());
79 private function logout_mail_text($rows, $browserRows) {
80 $lines = array(
'dbxApp Logout');
81 foreach ($rows as $key => $value) {
82 $lines[] = $key .
': ' . $value;
85 $lines[] =
'Browser und Client:';
86 foreach ($browserRows as $key => $value) {
87 $lines[] = $key .
': ' . $value;
89 return implode(
"\n", $lines);
92 private function html_info_table($rows) {
93 $tpl = dbx()->get_system_obj(
'dbxTPL');
95 foreach ($rows as $key => $value) {
96 $rowHtml .= $tpl->get_tpl(
'dbxLogin|mail-info-row', array(
97 'label' => $this->h($key),
98 'value' => $this->h($value),
101 return $tpl->get_tpl(
'dbxLogin|mail-info-table', array(
'rows' => $rowHtml));
104 private function h($value) {
105 return htmlspecialchars((
string)$value, ENT_QUOTES,
'UTF-8');
109 public function run(): mixed {
111 $modul =dbx()->get_system_var(
'dbx_modul');
112 $run =dbx()->get_system_var(
'dbx_run1');
114 dbx()->set_system_var(
'dbx_title',
'dbxApp Login');
115 dbx()->load_content_cache_classes();
116 \dbx\dbxContent\dbxContentRenderer::resetSeoMeta();
121 if (!$uid) $run=
'login';
122 if ( $uid) $run=
'logout';
124 dbx()->debug(
"dbxLogin switch-action=($run)");
130 $content=$this->logout_response($uid);
134 dbx()->debug(
"dbxLogin run login ($run)");
135 $obj=dbx()->get_include_obj(
'login');
136 $content=$obj->run();
140 $run2 = dbx()->get_modul_var(
'dbx_run2',
'',
'parameter');
141 if ((
string)dbx()->get_config(
'dbxLogin',
'register') ===
'1' || in_array($run2, array(
'confirm',
'resend_confirm'),
true)) {
142 $obj=dbx()->get_include_obj(
'register');
143 $content=$obj->run();
145 $obj=dbx()->get_include_obj(
'login');
146 $content = $this->alert(
'warning',
'Registrierung ist deaktiviert.') . $obj->run();
151 $content = $this->alert(
'info',
'Verifizierung ist noch nicht aktiv.');
156 $content = $this->alert(
'danger',
'Modul ' . $modul .
' run=(' . $run .
') is undef.');
163 private function alert($type, $msg) {
164 $type = in_array($type, array(
'success',
'warning',
'info',
'danger'),
true) ? $type :
'info';
165 $tpl = dbx()->get_system_obj(
'dbxTPL');
167 return $tpl->get_tpl(
'dbx|alert-' . $type, array(
'msg' => $msg));
DBX schema administration.