-
Notifications
You must be signed in to change notification settings - Fork 50
/
index.php
executable file
·151 lines (128 loc) · 4.49 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php
session_start();
if(isset($_POST['changeOption']))
{
$disabledSubmit = $_POST['disabledSubmit'];
if($disabledSubmit == 1) $js = 'disabledSubmit:true';
else $js = 'disabledSubmit:false';
$autoRevert = $_POST['autoRevert'];
if($autoRevert == 1) $js .= ',autoRevert:true';
else $js .= ',autoRevert:false';
$autoSubmit = $_POST['autoSubmit'];
if($autoSubmit == 1) $js .= ',autoSubmit:true';
else $js .= ',autoSubmit:false';
}
else
{
$disabledSubmit = 2;
$autoRevert = 1;
$autoSubmit = 2;
$js = 'disabledSubmit:false,autoRevert:true,autoSubmit:false';
}
?>
<!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">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="favicon.ico" />
<link rel="stylesheet" href="jquery/QapTcha.jquery.css" type="text/css" />
<style type="text/css">
form{margin:30px;width:300px}
label{float:left;clear:both;width:100px;margin-top:10px}
select, input{float:left;margin-top:10px}
label.large{width:150px}
.clr{clear:both}
.notice {background-color:#d8e6fc;color:#35517c;border:1px solid #a7c3f0;padding:10px;margin-top:10px;}
.code {
margin:30px;
border:1px solid #F0F0F0;
background-color:#F8F8F8;
padding:10px;
color:#777;
}
</style>
</head>
<body>
<ul>
<li>Full documentation on <a href="http://www.myjqueryplugins.com/QapTcha">MyjQueryPlugins.com/QapTcha</a></li>
<li>Live demonstration on <a href="http://www.myjqueryplugins.com/QapTcha/demo">QapTcha demonstration page</a></li>
</ul>
<h1>QapTcha plugin</h1>
<?php
// if form is submit
if(isset($_POST['submit']))
{
$response = '<div class="notice">';
/** SESSION CONTROL **/
if(isset($_SESSION['qaptcha_key']) && !empty($_SESSION['qaptcha_key']))
{
$QaptChaInput = $_SESSION['qaptcha_key'];
/** we can control the random input grace to the QapTchaToTest intpu value **/
if(isset($_POST[''.$QaptChaInput.'']) && empty($_POST[''.$QaptChaInput.'']))
$response .= 'Form can be submited<br />First Name : '.$_POST['firstname'].'<br />Last Name : '.$_POST['lastname'];
else
$response .= '$_POST not empty or unexists';
}
else
$response .= 'No SESSION.. Form can not be submitted...';
$response .= '</div>';
echo $response;
/** Unset SESSION in all cases **/
unset($_SESSION['qaptcha_key']);
}
?>
<form method="post" action="">
<fieldset>
<label>First Name</label> <input type="text" name="firstname" />
<label>Last Name</label> <input type="text" name="lastname" />
<div class="clr"></div>
<div class="QapTcha"></div>
<input type="submit" name="submit" value="Submit form" />
</fieldset>
</form>
<form method="post" action="">
<fieldset>
<label class="large">Disabled submit button</label>
<select name="disabledSubmit">
<option value='1' <?php if($disabledSubmit == 1) echo 'selected="selected"';?>>Yes</option>
<option value='2' <?php if($disabledSubmit == 2) echo 'selected="selected"';?>>No</option>
</select>
<br /><br />
<label class="large">AutoRevert</label>
<select name="autoRevert">
<option value='1' <?php if($autoRevert == 1) echo 'selected="selected"';?>>Yes</option>
<option value='2' <?php if($autoRevert == 2) echo 'selected="selected"';?>>No</option>
</select>
<br /><br />
<label class="large">AutoSubmit</label>
<select name="autoSubmit">
<option value='1' <?php if($autoSubmit == 1) echo 'selected="selected"';?>>Yes</option>
<option value='2' <?php if($autoSubmit == 2) echo 'selected="selected"';?>>No</option>
</select><br /><br /><br />
<input type="submit" name="changeOption" value="change Option">
</fieldset>
</form>
<div class="code">
<pre>
<?php
echo htmlentities('<!-- JS -->
<script type="text/javascript">
$(document).ready(function(){
$(\'.QapTcha\').QapTcha({'.$js.'});
});
</script>');
?>
</pre>
</div>
<script type="text/javascript" src="jquery/jquery.js"></script>
<script type="text/javascript" src="jquery/jquery-ui.js"></script>
<script type="text/javascript" src="jquery/jquery.ui.touch.js"></script>
<script type="text/javascript" src="jquery/QapTcha.jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.QapTcha').QapTcha({<?php echo $js;?>});
});
</script>
</body>
</html>