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 3.9 3.9-beta 3.9.1 3.9.2 3.9.3 4.0 4.0.1 4.0.2 4.0.3 4.1 4.1-beta 4.1.1 4.1.2 4.2 4.2-beta 4.2.1 4.2.2 4.3 4.3.1 4.4 4.4.1 4.4.2 4.5 4.5.1 4.6 4.6.1 4.7 4.8 4.8.1 4.9 4.9.1 4.9.2 5.0 5.0.1
contact-form-7 / captcha / captcha.php
contact-form-7 / captcha Last commit date
gentium 18 years ago tmp 18 years ago captcha.php 18 years ago
captcha.php
105 lines
1 <?php
2 /* Really Simple Captcha */
3
4 /* Copyright 2007 Takayuki Miyoshi (email: takayukister at gmail.com)
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 class tam_captcha {
22
23 function tam_captcha() {
24 $this->chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
25 $this->char_length = 4;
26 $this->fonts = array(
27 dirname(__FILE__) . '/gentium/GenAI102.TTF',
28 dirname(__FILE__) . '/gentium/GenAR102.TTF',
29 dirname(__FILE__) . '/gentium/GenI102.TTF',
30 dirname(__FILE__) . '/gentium/GenR102.TTF');
31 $this->tmp_dir = dirname(__FILE__) . '/tmp/';
32 $this->img_size = array(72, 24);
33 $this->bg = array(255, 255, 255);
34 $this->fg = array(0, 0, 0);
35 $this->base = array(6, 18);
36 $this->font_size = 14;
37 $this->font_char_width = 15;
38 $this->img_type = 'png';
39 }
40
41 function generate_random_word() {
42 $word = '';
43 for ($i = 0; $i < $this->char_length; $i++) {
44 $pos = mt_rand(0, strlen($this->chars) - 1);
45 $char = $this->chars[$pos];
46 $word .= $char;
47 }
48 return $word;
49 }
50
51 function generate_image($prefix, $captcha) {
52 $filename = null;
53 if ($im = imagecreatetruecolor($this->img_size[0], $this->img_size[1])) {
54 $bg = imagecolorallocate($im, $this->bg[0], $this->bg[1], $this->bg[2]);
55 $fg = imagecolorallocate($im, $this->fg[0], $this->fg[1], $this->fg[2]);
56 imagefill($im, 0, 0, $bg);
57 $x = $this->base[0] + mt_rand(-2, 2);
58 for ($i = 0; $i < strlen($captcha); $i++) {
59 $font = $this->fonts[array_rand($this->fonts)];
60 imagettftext($im, $this->font_size, mt_rand(-2, 2), $x, $this->base[1] + mt_rand(-2, 2), $fg, $font, $captcha[$i]);
61 $x += $this->font_char_width;
62 }
63 switch ($this->img_type) {
64 case 'jpeg':
65 $filename = $prefix . '.jpeg';
66 imagejpeg($im, $this->tmp_dir . $filename);
67 break;
68 case 'gif':
69 $filename = $prefix . '.gif';
70 imagegif($im, $this->tmp_dir . $filename);
71 break;
72 case 'png':
73 default:
74 $filename = $prefix . '.png';
75 imagepng($im, $this->tmp_dir . $filename);
76 }
77 imagedestroy($im);
78 }
79 if ($fh = fopen($this->tmp_dir . $prefix . '.php', 'w')) {
80 fwrite($fh, '<?php $captcha = "' . $captcha . '"; ?>');
81 fclose($fh);
82 }
83 return $filename;
84 }
85
86 function check($prefix, $response) {
87 if (is_readable($this->tmp_dir . $prefix . '.php')) {
88 include($this->tmp_dir . $prefix . '.php');
89 if (0 == strcasecmp($response, $captcha))
90 return true;
91 }
92 return false;
93 }
94
95 function remove($prefix) {
96 $suffixes = array('.jpeg', '.gif', '.png', '.php');
97 foreach ($suffixes as $suffix) {
98 $file = $this->tmp_dir . $prefix . $suffix;
99 if (is_file($file))
100 unlink($file);
101 }
102 }
103 }
104
105 ?>