dbxapp 4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
Loading...
Searching...
No Matches
dbxForm_try_count_test.php
Go to the documentation of this file.
1<?php
2
3class dbxObj {
4}
5
7 public function replaces($content, $data) {
8 foreach ((array) $data as $key => $value) {
9 $content = str_replace('{' . $key . '}', (string) $value, (string) $content);
10 }
11
12 return $content;
13 }
14
15 public function get_tpl($tpl, $data = '', $type = 'htm', $i = 0) {
16 $data = is_array($data) ? $data : array();
17 return '<div class="alert alert-danger">' . ($data['msg'] ?? '') . '</div>';
18 }
19}
20
22 public $now = 1000.0;
23 public $tpl;
24
25 public function __construct() {
26 $this->tpl = new dbxFormTryCountTpl();
27 }
28
29 public function get_system_obj($name) {
30 return $name === 'dbxTPL' ? $this->tpl : new stdClass();
31 }
32
33 public function timestamp($addSec = 0) {
34 return $this->now + (int) $addSec;
35 }
36
37 public function time_diff($startTime = 0, $endTime = 0) {
38 return $endTime - $startTime;
39 }
40
41 public function get_self_url() {
42 return '/try-count-test';
43 }
44}
45
47
48function dbx() {
51}
52
53require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'dbxForm.class.php';
54
55$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
56
57$form = new dbxForm();
58$form->_try_max = 5;
59$form->_try_reset = 6;
60$form->_try_count_reset = 600;
61$form->_try_msg = 'Noch {sec} Sekunden gesperrt.';
62$form->_sys['_try_sys'] = array(
63 'dbx_try_ip' => '127.0.0.1',
64 'dbx_try_count' => 5,
65 'dbx_try_lock' => 3,
66 'dbx_try_first' => 100,
67 'dbx_try_last' => 399,
68 'dbx_try_stop' => 399,
69 'dbx_try_run' => 2000,
70);
71
72$content = $form->check_try_count(false, false, 1);
73$sys = $form->_sys['_try_sys'];
74
75if ($content !== ''
76 || (int) ($sys['dbx_try_count'] ?? -1) !== 0
77 || (int) ($sys['dbx_try_lock'] ?? -1) !== 0
78 || isset($sys['dbx_try_last'], $sys['dbx_try_stop'], $sys['dbx_try_run'])) {
79 fwrite(STDERR, "Try-Zaehler wurde nach mehr als 600 Sekunden ohne Fehlversuch nicht zurueckgesetzt.\n");
80 exit(1);
81}
82
83$form->_sys['_try_sys'] = array(
84 'dbx_try_ip' => '127.0.0.1',
85 'dbx_try_count' => 5,
86 'dbx_try_lock' => 1,
87 'dbx_try_first' => 500,
88 'dbx_try_last' => 500,
89 'dbx_try_stop' => 994,
90 'dbx_try_run' => 1006,
91);
92
93$content = $form->check_try_count(false, false, 1);
94
95if (strpos($content, 'Noch 6 Sekunden gesperrt.') === false
96 || (int) ($form->_sys['_try_sys']['dbx_try_count'] ?? 0) !== 5) {
97 fwrite(STDERR, "Eine aktive Try-Sperre wurde vor Ablauf des 600-Sekunden-Fensters aufgehoben.\n");
98 exit(1);
99}
100
101echo "OK: dbxForm Try-Zaehler wird nach 600 Sekunden Inaktivitaet neu gestartet.\n";
time_diff($startTime=0, $endTime=0)
get_tpl($tpl, $data='', $type='htm', $i=0)
Gemeinsame Basisklasse fuer dbXapp-System-, Modul- und Include-Objekte.
Definition dbxKernel.php:63
$_SERVER['REQUEST_METHOD']
if($web->content_permalink_redirect_target() !=='') $tpl
exit
Definition index.php:146