| 2 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
// Make the page validate
|
|
|
4 |
ini_set('session.use_trans_sid', '0');
|
|
|
5 |
|
|
|
6 |
// Include the random string file
|
|
|
7 |
require 'rand.php';
|
|
|
8 |
|
|
|
9 |
// Begin the session
|
|
|
10 |
session_start();
|
|
|
11 |
|
|
|
12 |
// Set the session contents
|
|
|
13 |
$_SESSION['captcha_id'] = $str;
|
|
|
14 |
|
|
|
15 |
?>
|
|
|
16 |
<!doctype html>
|
|
|
17 |
<html lang="en">
|
|
|
18 |
<head>
|
|
|
19 |
<meta charset="utf-8">
|
|
|
20 |
<title>AJAX CAPTCHA</title>
|
|
|
21 |
<script src="../../lib/jquery.js"></script>
|
|
|
22 |
<script src="../../dist/jquery.validate.js"></script>
|
|
|
23 |
<script src="captcha.js"></script>
|
|
|
24 |
<link rel="stylesheet" href="style.css">
|
|
|
25 |
<style>
|
|
|
26 |
img {
|
|
|
27 |
border: 1px solid #eee;
|
|
|
28 |
}
|
|
|
29 |
p#statusgreen {
|
|
|
30 |
font-size: 1.2em;
|
|
|
31 |
background-color: #fff;
|
|
|
32 |
color: #0a0;
|
|
|
33 |
}
|
|
|
34 |
p#statusred {
|
|
|
35 |
font-size: 1.2em;
|
|
|
36 |
background-color: #fff;
|
|
|
37 |
color: #a00;
|
|
|
38 |
}
|
|
|
39 |
fieldset label {
|
|
|
40 |
display: block;
|
|
|
41 |
}
|
|
|
42 |
fieldset div#captchaimage {
|
|
|
43 |
float: left;
|
|
|
44 |
margin-right: 15px;
|
|
|
45 |
}
|
|
|
46 |
fieldset input#captcha {
|
|
|
47 |
width: 25%;
|
|
|
48 |
border: 1px solid #ddd;
|
|
|
49 |
padding: 2px;
|
|
|
50 |
}
|
|
|
51 |
fieldset input#submit {
|
|
|
52 |
display: block;
|
|
|
53 |
margin: 2% 0% 0% 0%;
|
|
|
54 |
}
|
|
|
55 |
#captcha.success {
|
|
|
56 |
border: 1px solid #49c24f;
|
|
|
57 |
background: #bcffbf;
|
|
|
58 |
}
|
|
|
59 |
#captcha.error {
|
|
|
60 |
border: 1px solid #c24949;
|
|
|
61 |
background: #ffbcbc;
|
|
|
62 |
}
|
|
|
63 |
</style>
|
|
|
64 |
</head>
|
|
|
65 |
<body>
|
|
|
66 |
<h1><acronym title="Asynchronous JavaScript And XML">AJAX</acronym> <acronym title="Completely Automated Public Turing test to tell Computers and Humans Apart">CAPTCHA</acronym></h1>
|
|
|
67 |
<form id="captchaform" action="">
|
|
|
68 |
<fieldset>
|
|
|
69 |
<div id="captchaimage"><a href="<?php echo htmlEntities($_SERVER['PHP_SELF'], ENT_QUOTES); ?>" id="refreshimg" title="Click to refresh image"><img src="images/image.php?<?php echo time(); ?>" width="132" height="46" alt="Captcha image"></a></div>
|
|
|
70 |
<label for="captcha">Enter the characters as seen on the image above (case insensitive):</label>
|
|
|
71 |
<input type="text" maxlength="6" name="captcha" id="captcha">
|
|
|
72 |
<input type="submit" name="submit" id="submit" value="Check">
|
|
|
73 |
</fieldset>
|
|
|
74 |
</form>
|
|
|
75 |
<p>If you can't decipher the text on the image, click it to dynamically generate a new one.</p>
|
|
|
76 |
</body>
|
|
|
77 |
</html>
|