-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvote.php
More file actions
executable file
·79 lines (74 loc) · 3.13 KB
/
Copy pathvote.php
File metadata and controls
executable file
·79 lines (74 loc) · 3.13 KB
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
<?php
/**
* Created by PhpStorm.
* User: Jerry
* Date: 2016/11/16
* Time: 上午8:15
*/
require_once "config.php";
require_once "data.php";
require_once "./captcha/lib/class.geetestlib.php";
require_once "localcaptcha.php";
session_start();
$GtSdk = new GeetestLib(CAPTCHA_ID, PRIVATE_KEY);
if (isset($_POST['vote_for'])) {
if ($_SESSION['gtserver'] == 1) {
$captcha_passed = $GtSdk->success_validate($_POST['geetest_challenge'], $_POST['geetest_validate'],
$_POST['geetest_seccode']); //验证码 SDK 要求的返回值
} else {
$captcha_passed = $GtSdk->fail_validate($_POST['geetest_challenge'], $_POST['geetest_validate'],
$_POST['geetest_seccode']);
}
$isSuccess = false;
$vote_for = 0;
if ($captcha_passed) {
$user_agent = $_SERVER['HTTP_USER_AGENT']; //获取 User Agent 信息
$remote_ip = $_SERVER['REMOTE_ADDR']; //获取客户端 IP 地址
$time = date("Y-m-d H:i:s"); //获取当前时间戳
$vote_for = $_POST['vote_for']; //投票对象
$screen_width = $_POST['screen_width']; //客户端屏幕宽度
$screen_height = $_POST['screen_height']; //客户端屏幕高度
$window_width = $_POST['window_width']; //客户端窗口宽度
$window_height = $_POST['window_height']; //客户端窗口高度
$click_x_axis = $_POST['click_x_axis']; //投票按钮点击的横轴坐标,按百分比计,double 类型,下同
$click_y_axis = $_POST['click_y_axis']; //投票按钮点击的纵轴坐标
//$captcha_verified = ($_SESSION['gtserver'] == 1 || $_SESSION['isPass'] == 1) ? 1 : 0; //验证码的验证状态,1 为通过
$captcha_verified = $_SESSION['gtserver'];
<<<<<<< HEAD
=======
>>>>>>> aad434a98a71d3e9641a0f147e7aa06e93b1211f
$db_mysqli = new mysqli($db_hostname, $db_username, $db_password, $db_database);
$sql = "insert into $db_table_list ('vote_for', 'user_agent', 'remote_ip', 'time', 'screen_width', " .
"'screen_height', 'window_width', 'window_height', 'click_x_axis', 'click_y_axis', 'verified') " .
"values(?,?,?,?,?,?,?,?,?,?,?)";
$stmt = $db_mysqli->prepare($sql);
$stmt->bind_param("isssiiiiddi", $vote_for, $user_agent, $remote_ip, $time, $screen_width, $screen_height,
$window_width, $window_height, $click_x_axis, $click_y_axis, $captcha_verified);
$isSuccess = $stmt->execute();
}
if ($isSuccess) {
echo json_encode(array("state" => true, "vote" => $vote_for));
} else {
echo json_encode(array("state" => false));
}
$_SESSION['gtserver'] = 0;
}
<<<<<<< HEAD
=======
>>>>>>> aad434a98a71d3e9641a0f147e7aa06e93b1211f
if (isset($_POST['get_data'])) {
if ($_POST['get_data'] == 1) {
$ret = json_encode($movies);
echo $ret;
}
}
<<<<<<< HEAD
=======
>>>>>>> aad434a98a71d3e9641a0f147e7aa06e93b1211f
?>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.12.3.min.js"></script>
<script src="http://static.geetest.com/static/tools/gt.js"></script>
</head>
</html>