dolibarr 21.0.0-alpha
antispamimage.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005-2007 Laurent Destailleur <eldy@users.sourceforge.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 * or see https://www.gnu.org/
17 */
18
24define('NOLOGIN', 1);
25
26if (!defined('NOREQUIREUSER')) {
27 define('NOREQUIREUSER', 1);
28}
29if (!defined('NOREQUIREDB')) {
30 define('NOREQUIREDB', 1);
31}
32if (!defined('NOREQUIRETRAN')) {
33 define('NOREQUIRETRAN', 1);
34}
35if (!defined('NOREQUIREMENU')) {
36 define('NOREQUIREMENU', 1);
37}
38if (!defined('NOREQUIRESOC')) {
39 define('NOREQUIRESOC', 1);
40}
41if (!defined('NOTOKENRENEWAL')) {
42 define('NOTOKENRENEWAL', 1);
43}
44
45require_once '../main.inc.php';
46
47
48/*
49 * View
50 */
51
52$length = 5;
53$letters = 'aAbBCDeEFgGhHJKLmMnNpPqQRsStTuVwWXYZz2345679';
54$number = strlen($letters);
55$string = '';
56for ($i = 0; $i < $length; $i++) {
57 $string .= $letters[mt_rand(0, $number - 1)];
58}
59//print $string;
60
61
62$sessionkey = 'dol_antispam_value';
63$_SESSION[$sessionkey] = $string;
64
65$img = imagecreate(80, 32);
66if (empty($img)) {
67 dol_print_error(null, "Problem with GD creation");
68 exit;
69}
70
71// Define mime type
72top_httphead('image/png', 1);
73
74$background_color = imagecolorallocate($img, 250, 250, 250);
75$ecriture_color = imagecolorallocate($img, 0, 0, 0);
76imagestring($img, 4, 24, 8, $string, $ecriture_color);
77imagepng($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.