dolibarr 21.0.0-alpha
modCaptchaStandard.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 * or see https://www.gnu.org/
18 */
19
26 require_once DOL_DOCUMENT_ROOT.'/core/modules/security/captcha/modules_captcha.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/modules/security/generate/modGeneratePassStandard.class.php';
28
29
34{
38 public $id;
39
40 public $picto = 'fa-shield-alt';
41
50 public function __construct($db, $conf, $langs, $user)
51 {
52 $this->id = "standard";
53
54 $this->db = $db;
55 $this->conf = $conf;
56 $this->langs = $langs;
57 $this->user = $user;
58 }
59
65 public function getDescription()
66 {
67 global $langs;
68 return $langs->trans("DolibarrStandardCaptcha");
69 }
70
76 public function getExample()
77 {
78 global $db, $conf, $langs, $user;
79
80 $generator = new modGeneratePassStandard($db, $conf, $langs, $user);
81 $example = $generator->getExample();
82 $img = imagecreate(80, 32);
83 if (!$img) {
84 return "Problem with GD creation";
85 }
86 $background_color = imagecolorallocate($img, 250, 250, 250);
87 $ecriture_color = imagecolorallocate($img, 0, 0, 0);
88 imagestring($img, 4, 15, 8, $example, $ecriture_color);
89
90 ob_start();
91 imagepng($img);
92 $image_data = ob_get_contents();
93 ob_end_clean();
94
95 return '<img class="inline-block valignmiddle" src="data:image/png;base64,' . base64_encode($image_data) . '" border="0" width="80" height="32" />';
96 }
97
98
106 {
107 return 1;
108 }
109}
Parent class for password rules/management modules.
Class to generate a password according to a dolibarr standard rule (12 random chars)
validateCodeAfterLoginSubmit()
Validate a captcha This function is called after a log to validate a captcha, before validating a pas...
__construct($db, $conf, $langs, $user)
Constructor.
getDescription()
Return description of module.
getExample()
Return an example of password generated by this module.
Class to generate a password according to a dolibarr standard rule (12 random chars)
conf($dolibarr_main_document_root)
Load conf file (file must exists)
Definition inc.php:420
$conf db user
Active Directory does not allow anonymous connections.
Definition repair.php:141