dolibarr  7.0.0-beta
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 <http://www.gnu.org/licenses/>.
16  * or see http://www.gnu.org/
17  */
18 
24 define('NOLOGIN',1);
25 
26 if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER',1);
27 if (! defined('NOREQUIREDB')) define('NOREQUIREDB',1);
28 if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN',1);
29 if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1);
30 if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC',1);
31 if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1);
32 
33 require_once '../main.inc.php';
34 
35 
36 /*
37  * View
38  */
39 
40 $length=5;
41 $letters = 'aAbBCDeEFgGhHJKLmMnNpPqQRsStTuVwWXYZz2345679';
42 $number = strlen($letters);
43 $string = '';
44 for($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);
55 if (empty($img))
56 {
57  dol_print_error('',"Problem with GD creation");
58  exit;
59 }
60 
61 // Define mime type
62 top_httphead('image/png');
63 
64 $background_color = imagecolorallocate($img, 250, 250, 250);
65 $ecriture_color = imagecolorallocate($img, 0, 0, 0);
66 imagestring($img, 4, 24, 8, $string, $ecriture_color);
67 imagepng($img);
68 
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
if(!defined('NOREQUIREMENU')) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html')
Show HTTP header.
Definition: main.inc.php:1052