diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2024-05-08 12:56:34 +0000 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2024-05-08 12:56:34 +0000 |
| commit | 79a1564005f300ea9ee23a2769756e2e12001f96 (patch) | |
| tree | bdc67106dc370788efd9d725b46f2d08935540b1 /db | |
| parent | b56bb5506f46ae8f6ed249902cfcad2524c1f2af (diff) | |
introduce altcha/captcha, fixes #4113
Closes #4113
Merge request studip/studip!2965
Diffstat (limited to 'db')
| -rw-r--r-- | db/migrations/6.0.2_captcha_by_altcha.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/db/migrations/6.0.2_captcha_by_altcha.php b/db/migrations/6.0.2_captcha_by_altcha.php new file mode 100644 index 0000000..3749c71 --- /dev/null +++ b/db/migrations/6.0.2_captcha_by_altcha.php @@ -0,0 +1,39 @@ +<?php +return new class extends Migration +{ + public function description(): string + { + return 'Creates a config entry for the key used for captchas and ' + . 'db storage for solved challenges.'; + } + + protected function up(): void + { + $query = "INSERT INTO `config` (`field`, `value`, `type`, `range`, `mkdate`, `chdate`, `description`) + VALUES ('CAPTCHA_KEY', '', 'string', 'global', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), ?)"; + DBManager::get()->execute($query, [ + 'Speichert den für Captchas verwendeten Schlüssel (Wert leeren, um einen neuen zu generieren)', + ]); + + $query = "CREATE TABLE `captcha_challenges` ( + `challenge_id` int(11) NOT NULL AUTO_INCREMENT, + `salt` CHAR(32) COLLATE `latin1_bin` NOT NULL, + `number` INT(11) UNSIGNED NOT NULL, + `mkdate` INT(11) UNSIGNED NOT NULL, + PRIMARY KEY (`challenge_id`) + )"; + DBManager::get()->exec($query); + } + + protected function down(): void + { + $query = "DROP TABLE `captcha_challenges`"; + DBManager::get()->exec($query); + + $query = "DELETE `config`, `config_values` + FROM `config` + LEFT JOIN `config_values` USING (`field`) + WHERE `field` = 'CAPTCHA_KEY'"; + DBManager::get()->exec($query); + } +}; |
