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 19/** 20 * \file htdocs/core/antispamimage.php 21 * \brief Return antispam image 22 */ 23 24define('NOLOGIN', 1); 25 26if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', 1); 27if (!defined('NOREQUIREDB')) define('NOREQUIREDB', 1); 28if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', 1); 29if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); 30if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', 1); 31if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); 32 33require_once '../main.inc.php'; 34 35 36/* 37 * View 38 */ 39 40$length = 5; 41$letters = 'aAbBCDeEFgGhHJKLmMnNpPqQRsStTuVwWXYZz2345679'; 42$number = strlen($letters); 43$string = ''; 44for ($i = 0; $i < $length; $i++) 45{ 46 $string .= $letters[mt_rand(0, $number - 1)]; 47} 48//print $string; 49 50 51$sessionkey = 'dol_antispam_value'; 52$_SESSION[$sessionkey] = $string; 53 54$img = imagecreate(80, 32); 55if (empty($img)) 56{ 57 dol_print_error('', "Problem with GD creation"); 58 exit; 59} 60 61// Define mime type 62top_httphead('image/png', 1); 63 64$background_color = imagecolorallocate($img, 250, 250, 250); 65$ecriture_color = imagecolorallocate($img, 0, 0, 0); 66imagestring($img, 4, 24, 8, $string, $ecriture_color); 67imagepng($img); 68