1 |
596
|
thorn
|
// $Id$
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
Website Baker Project <http://www.websitebaker.org/>
|
5 |
915
|
Ruebenwurz
|
Copyright (C) 2004-2009, Ryan Djurovich
|
6 |
596
|
thorn
|
|
7 |
|
|
Website Baker is free software; you can redistribute it and/or modify
|
8 |
|
|
it under the terms of the GNU General Public License as published by
|
9 |
|
|
the Free Software Foundation; either version 2 of the License, or
|
10 |
|
|
(at your option) any later version.
|
11 |
|
|
|
12 |
|
|
Website Baker is distributed in the hope that it will be useful,
|
13 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
|
|
GNU General Public License for more details.
|
16 |
|
|
|
17 |
|
|
You should have received a copy of the GNU General Public License
|
18 |
|
|
along with Website Baker; if not, write to the Free Software
|
19 |
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
756
|
thorn
|
One can improve all CAPTCHA-types with varying fonts and backgrounds
|
24 |
596
|
thorn
|
- by adding backgrounds (PNG-images, 140x40 pixels) to backgrounds/
|
25 |
|
|
- and by adding TrueType-fonts to fonts/
|
26 |
|
|
|
27 |
|
|
|
28 |
615
|
thorn
|
How to use:
|
29 |
596
|
thorn
|
|
30 |
756
|
thorn
|
1.)
|
31 |
|
|
put
|
32 |
|
|
require_once(WB_PATH.'/include/captcha/captcha.php');
|
33 |
|
|
in your file.
|
34 |
615
|
thorn
|
|
35 |
|
|
|
36 |
756
|
thorn
|
2a.)
|
37 |
|
|
put
|
38 |
|
|
<?php call_captcha(); ?>
|
39 |
|
|
into your form.
|
40 |
|
|
This will output a table with varying columns (3 or 4) like this example:
|
41 |
615
|
thorn
|
<table class="captcha_table"><tr>
|
42 |
756
|
thorn
|
<td><img src="http://www.example.org/include/captcha/captchas/ttf.php?t=64241454" alt="Captcha" /></td>
|
43 |
615
|
thorn
|
<td><input type="text" name="captcha" maxlength="5" style="width:50px" /></td>
|
44 |
756
|
thorn
|
<td class="captcha_expl">Fill in the result</td>
|
45 |
615
|
thorn
|
</tr></table>
|
46 |
756
|
thorn
|
|
47 |
|
|
|
48 |
|
|
2b.)
|
49 |
|
|
If you want to use your own layout, use additional parameters to call_captcha():
|
50 |
|
|
call_captcha('all') will output the whole table as above.
|
51 |
|
|
|
52 |
|
|
call_captcha('image', $style); will output the <img>-tag for the image only (or the text for an text-style captcha):
|
53 |
|
|
Examples:
|
54 |
|
|
call_captcha('image', 'style="...; title="captcha"');
|
55 |
|
|
<img style="...; title="captcha" src="http://www.example.org/include/captcha/captchas/captcha.php?t=46784246" />
|
56 |
|
|
or
|
57 |
|
|
<span style="...; title="captcha">4 add 6</span>
|
58 |
|
|
call_captcha('image');
|
59 |
|
|
<img src="http://www.example.org/include/captcha/captchas/captcha.php?t=46784246" />
|
60 |
|
|
or
|
61 |
|
|
4 add 6
|
62 |
|
|
|
63 |
|
|
call_captcha('input', $style); will output the input-field:
|
64 |
|
|
call_captcha('input', 'style"...;"');
|
65 |
|
|
<input type="text" name="captcha" style="...;" />
|
66 |
|
|
call_captcha('input');
|
67 |
|
|
<input type="text" name="captcha" style="width:50px;" maxlength="10" />
|
68 |
|
|
|
69 |
|
|
call_captcha('text', $style); will output a short "what to do"-text
|
70 |
|
|
call_captcha('text', 'style="...;"');
|
71 |
|
|
<span style="...;">Fill in the result</span>
|
72 |
|
|
call_captcha('text');
|
73 |
|
|
Fill in the result
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
The CAPTCHA-code is allways stored in $_SESSION['captcha'] for verification with user-input.
|
78 |
|
|
The user-input is in $_POST['captcha'] (or maybe $_GET['captcha']).
|