dolibarr 24.0.0-beta
antispamimage.php
1<?php
2/* Copyright (C) 2005-2007 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2026 Charlene Benke <charlene@patas-monkey.com>
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
25// Define WEBPORTAL to ensure we use webportal session prefix
26define('WEBPORTAL', 1);
27define('NOLOGIN', 1);
28if (!defined('NOREQUIREUSER')) {
29 define('NOREQUIREUSER', 1);
30}
31if (!defined('NOREQUIREDB')) {
32 define('NOREQUIREDB', 1);
33}
34if (!defined('NOREQUIRETRAN')) {
35 define('NOREQUIRETRAN', 1);
36}
37if (!defined('NOREQUIREMENU')) {
38 define('NOREQUIREMENU', 1);
39}
40if (!defined('NOREQUIRESOC')) {
41 define('NOREQUIRESOC', 1);
42}
43if (!defined('NOTOKENRENEWAL')) {
44 define('NOTOKENRENEWAL', 1);
45}
46
47// Include webportal main to get the correct session name
48require_once 'webportal.main.inc.php';
49
50// Now generate the antispam image
51$length = 5;
52$letters = 'aAbBCDeEFgGhHJKLmMnNpPqQRsStTuVwWXYZz2345679';
53$number = strlen($letters);
54$string = '';
55for ($i = 0; $i < $length; $i++) {
56 $string .= $letters[mt_rand(0, $number - 1)];
57}
58
59$sessionkey = 'dol_antispam_value';
60$_SESSION[$sessionkey] = $string;
61
62$img = imagecreate(80, 32);
63if (empty($img)) {
64 dol_print_error(null, "Problem with GD creation");
65 exit;
66}
67
68// Define mime type
69top_httphead('image/png', 1);
70
71$background_color = imagecolorallocate($img, 250, 250, 250);
72$ecriture_color = imagecolorallocate($img, 0, 0, 0);
73imagestring($img, 4, 24, 8, $string, $ecriture_color);
74imagepng($img);
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.