Skip to content

Commit 7142ade

Browse files
author
hooray
committed
更新clicaptcha
1 parent aeefc29 commit 7142ade

File tree

9 files changed

+63
-6
lines changed

9 files changed

+63
-6
lines changed

libs/clicaptcha/clicaptcha.class.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ function __construct(){
88
public function creat(){
99
$imagePathArr = array('image/1.jpg', 'image/2.jpg', 'image/3.jpg');
1010
$imagePath = $imagePathArr[rand(0, 2)];
11-
$fontPath = 'font/iYuanTi.ttf';
11+
$fontPath = 'font/SourceHanSansCN-Normal.otf';
1212
foreach($this->randChars() as $v){
13-
$fontSize = rand(20, 40);
13+
$fontSize = rand(15, 30);
1414
//字符串文本框宽度和长度
1515
$fontarea = imagettfbbox($fontSize, 0, $fontPath, $v);
16-
$textWidth = $fontarea[2] - $fontarea[0];
16+
$textWidth = $fontarea[2] - $fontarea[0];
1717
$textHeight = $fontarea[1] - $fontarea[7];
1818
$tmp['text'] = $v;
1919
$tmp['size'] = $fontSize;
@@ -209,4 +209,4 @@ private function getImageColor($img, $x, $y){
209209
return array($r, $g, $b);
210210
}
211211
}
212-
?>
212+
?>

libs/clicaptcha/clicaptcha.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
e.preventDefault();
4545
thisObj.off('mouseup').on('mouseup', function(e){
4646
$('#clicaptcha-box .clicaptcha-title span:eq('+xyArr.length+')').addClass('clicaptcha-clicked');
47-
xyArr.push((e.clientX - $(this).offset().left) + ',' + (e.clientY - $(this).offset().top));
47+
xyArr.push(($(document).scrollLeft() + e.clientX - $(this).offset().left) + ',' + ($(document).scrollTop() + e.clientY - $(this).offset().top));
4848
if(xyArr.length == text.length){
4949
var captchainfo = [xyArr.join('-'), thisObj.width(), thisObj.height()].join(';');
5050
$.ajax({

libs/clicaptcha/css/captcha.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
line-height: 40px;
2626
font-size: 14px;
2727
text-align: center;
28+
color: #333;
2829
}
2930
#clicaptcha-box .clicaptcha-title span{
3031
font-size: 16px;
@@ -71,4 +72,4 @@
7172
height: 100%;
7273
opacity: 0.5;
7374
background-color: rgb(0, 0, 0);
74-
}
75+
}

libs/clicaptcha/demo/action.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
require('../clicaptcha.class.php');
3+
4+
$clicaptcha = new clicaptcha();
5+
echo $clicaptcha->check($_POST['clicaptcha-submit-info']) ? '后端二次验证成功' : '后端二次验证失败';
6+
?>

libs/clicaptcha/demo/css/main.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#login{width:500px;padding:50px;border:1px solid #ccc;margin:10px auto;}
2+
.row{height:30px;line-height:30px;padding:5px 0;}
3+
.row .text{width:100px;float:left;}
4+
.row .input{width:350px;float:left;}
5+
.row .input input{width:200px;height:26px;padding:0;}
6+
button{width:100px;height:30px;}

libs/clicaptcha/demo/index.html

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>clicaptcha在线演示</title>
6+
<link rel="stylesheet" href="../css/captcha.css">
7+
<link rel="stylesheet" href="css/main.css">
8+
<script src="jquery-1.8.3.min.js"></script>
9+
<script src="../clicaptcha.js"></script>
10+
<script>
11+
$(function(){
12+
$('#sub').click(function(){
13+
$('#clicaptcha-submit-info').clicaptcha({
14+
src: '../clicaptcha.php',
15+
callback: function(){
16+
$('#form').submit();
17+
}
18+
});
19+
});
20+
});
21+
</script>
22+
</head>
23+
24+
<body>
25+
<div id="login">
26+
<form action="action.php" method="post" id="form" name="form">
27+
<div class="row">
28+
<div class="text">用户名:</div>
29+
<div class="input"><input type="text"></div>
30+
</div>
31+
<div class="row">
32+
<div class="text">密码:</div>
33+
<div class="input"><input type="password"></div>
34+
</div>
35+
<div class="row">
36+
<button type="button" id="sub">提交</button>
37+
</div>
38+
<input type="hidden" id="clicaptcha-submit-info" name="clicaptcha-submit-info">
39+
</form>
40+
</div>
41+
</body>
42+
</html>

libs/clicaptcha/demo/jquery-1.8.3.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
7.96 MB
Binary file not shown.

libs/clicaptcha/font/iYuanTi.ttf

-8.93 MB
Binary file not shown.

0 commit comments

Comments
 (0)