1 |
2
|
Manuela
|
<?php
|
2 |
|
|
|
3 |
|
|
// $Id$
|
4 |
|
|
|
5 |
|
|
/*
|
6 |
|
|
|
7 |
|
|
Website Baker Project <http://www.websitebaker.org/>
|
8 |
|
|
Copyright (C) 2004-2009, Ryan Djurovich
|
9 |
|
|
|
10 |
|
|
Website Baker is free software; you can redistribute it and/or modify
|
11 |
|
|
it under the terms of the GNU General Public License as published by
|
12 |
|
|
the Free Software Foundation; either version 2 of the License, or
|
13 |
|
|
(at your option) any later version.
|
14 |
|
|
|
15 |
|
|
Website Baker is distributed in the hope that it will be useful,
|
16 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
|
|
GNU General Public License for more details.
|
19 |
|
|
|
20 |
|
|
You should have received a copy of the GNU General Public License
|
21 |
|
|
along with Website Baker; if not, write to the Free Software
|
22 |
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
23 |
|
|
|
24 |
|
|
*/
|
25 |
|
|
|
26 |
|
|
require_once("../../../config.php");
|
27 |
|
|
require_once(WB_PATH.'/include/captcha/captcha.php');
|
28 |
|
|
|
29 |
|
|
if(!isset($_SESSION['captcha_time']))
|
30 |
|
|
exit;
|
31 |
|
|
//unset($_SESSION['captcha_time']);
|
32 |
|
|
|
33 |
|
|
// Captcha
|
34 |
|
|
srand((double)microtime()*100000);
|
35 |
|
|
$sec_id = '';
|
36 |
|
|
if(isset($_GET['s'])) $sec_id = $_GET['s'];
|
37 |
|
|
$_SESSION['captcha'.$sec_id] = rand(10000,99999);
|
38 |
|
|
|
39 |
|
|
// create reload-image
|
40 |
|
|
$reload = ImageCreateFromPNG(WB_PATH.'/include/captcha/reload_120_30.png'); // reload-overlay
|
41 |
|
|
|
42 |
|
|
$w=120;
|
43 |
|
|
$h=30;
|
44 |
|
|
$image = imagecreate($w, $h);
|
45 |
|
|
$white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
|
46 |
|
|
$gray = imagecolorallocate($image, 0xC0, 0xC0, 0xC0);
|
47 |
|
|
$darkgray = imagecolorallocate($image, 0x50, 0x50, 0x50);
|
48 |
|
|
|
49 |
|
|
srand((double)microtime()*1000000);
|
50 |
|
|
for($i = 0; $i < 30; $i++) {
|
51 |
|
|
$x1 = rand(0,$w);
|
52 |
|
|
$y1 = rand(0,$h);
|
53 |
|
|
$x2 = rand(0,$w);
|
54 |
|
|
$y2 = rand(0,$h);
|
55 |
|
|
imageline($image, $x1, $y1, $x2, $y2 , $gray);
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
$x = 0;
|
59 |
|
|
for($i = 0; $i < 5; $i++) {
|
60 |
|
|
$fnt = rand(3,5);
|
61 |
|
|
$x = $x + rand(12 , 20);
|
62 |
|
|
$y = rand(7 , 12);
|
63 |
|
|
imagestring($image, $fnt, $x, $y, substr($_SESSION['captcha'.$sec_id], $i, 1), $darkgray);
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
imagealphablending($reload, TRUE);
|
67 |
|
|
imagesavealpha($reload, TRUE);
|
68 |
|
|
|
69 |
|
|
// overlay
|
70 |
|
|
imagecopy($reload, $image, 0,0,0,0, 120,30);
|
71 |
|
|
imagedestroy($image);
|
72 |
|
|
$image = $reload;
|
73 |
|
|
|
74 |
|
|
captcha_header();
|
75 |
|
|
ob_start();
|
76 |
|
|
imagepng($image);
|
77 |
|
|
header("Content-Length: ".ob_get_length());
|
78 |
|
|
ob_end_flush();
|
79 |
|
|
imagedestroy($image);
|
80 |
|
|
|
81 |
|
|
?>
|