<?php
/*
- examples and test -
Require:
1. cellCaptcha Class
2. fontmatrix.php or whatever file your font matrix is in
Configure:
1. $c->fillColor = '#000': Set the cell background color or
$c->fillContent = '*' : fill it with some content.
2. Set cell width and height (in pixels) $c->cellW = 4, $c->cellH = 4
3. $c->setMessage() : Set the message. If left empty, a random string
of characters will be generated ( $c->randCharLen : default 5) characters long.
4. echo $c->draw() : Output to the screen.
5. Set how you want to verify captcha text $c->verifyCaseSensative (bool) true or false
6. Verify captcha using $c->verifyCaptcha( $_POST['user_Captcha_text_respons'] ) if you wish
***NOTE*** setMessage() SETS $_SESSION['captchaText'].
If you are submitting a page to itself,
Just be sure you verifyCaptcha() before you setMessage() else you
will change $_SESSION['captchaText'] before you can test the user input and the user
input will always be wrong regardless.
The other variables are up to you if you wish to use. This class
is simple enough that you can alter to your liking.
*/
require('cellCaptcha.php');
require('fontmatrix.php'); //require the matrix array
$c = new cellCaptcha($chars, $matrix,$rows);
//set some variables
$c->fillColor = 'transparent';
$c->tblBGColor = '';
$c->tblBorderSize = 0;
$c->cellH = 6;
$c->cellW = 6;
$c->addedTableStyle = 'padding:6px 13px 6px 6px;';
$c->tblID = 'cellCaptcha';
//$c->posClassName = 'blink';
$c->addedPosCellStyle = 'font-size:5em;padding:0;margin-top: -70px;';
//$c->addedPosCellStyle = '';
$c->addedNegCellStyle = '';
//$c->fillContent = '<blink>.</blink>';
$c->fillContent = '.';
$c->setMessage();
/* */
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title> Cell Captcha Test </title>
</head>
<body>
<table align="center" cellspacing="1" border="0">
<tr>
<td>Username:</td>
<td><input name="username" type="text" size="15" tabindex="1" maxlength="15" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input name="password" type="password" size="15" tabindex="1" maxlength="15" /></td>
</tr>
<tr>
<td>Captcha:</td>
<td style="border:2px solid #000000;margin:0 auto;">
<?php
echo $c->draw();
?>
</td>
</tr>
<tr><td colspan="2" align="center"><?php echo 'Captcha Text: '.$_SESSION['captchaText']; ?></td></tr>
<tr>
<td colspan="2" align="center"><input type="button" name="submit" value="Submit" /></td>
</tr>
</table>
<br /><br /><br />
<?php
//set some variables
$c->fillColor = '#996600';
$c->tblBGColor = '';
$c->tblBorderSize = 0;
$c->cellH = 4;
$c->cellW = 4;
$c->addedTableStyle = 'padding: 3px;';
$c->tblID = 'cellCaptcha';
$c->addedPosCellStyle = '';
$c->addedNegCellStyle = '';
$c->fillContent = '';
?>
<table align="center" cellspacing="1" border="0">
<tr>
<td>Username:</td>
<td><input name="username" type="text" size="15" tabindex="1" maxlength="15" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input name="password" type="password" size="15" tabindex="1" maxlength="15" /></td>
</tr>
<tr>
<td>Captcha:</td>
<td style="border:2px solid #000000;margin:0 auto;">
<?php
echo $c->draw();
?>
</td>
</tr>
<tr><td colspan="2" align="center"><?php echo 'Captcha Text: '.$_SESSION['captchaText']; ?></td></tr>
<tr>
<td colspan="2" align="center"><input type="button" name="submit" value="Submit" /></td>
</tr>
</table>
</body>
</html>