Commit ff42db25 by doszhang

dos

parent 2bfd5e62
...@@ -36,6 +36,41 @@ class IndexController extends Controller ...@@ -36,6 +36,41 @@ class IndexController extends Controller
$this->display(); $this->display();
} }
function commit() {
$referer = $_SERVER['HTTP_REFERER'];
$refererInfo = parse_url( $referer );
if( $refererInfo['host'] != $_SERVER['HTTP_HOST'] )
{
header("HTTP/1.0 404 Not Found");
exit;
}
session_start();
if(!$_SESSION['joinTime'] || time() - $_SESSION['joinTime'] < 5)
{
header("HTTP/1.0 404 Not Found");
exit;
}
$user = $this->get_user_info_from_cookie();
if (!$user) {
$this->ajaxReturn(array(
'status' => 404,
'msg' => '用户信息错误',
'step' => 0
));
return;
}
$name = $_POST['name'];
$tel = $_POST['tel'];
M('info')->add(array(
'uid' => $user['id'],
'name' => $name,
'tel' => $tel,
'submit_time' => time()
));
}
public function http_get_data($url) { public function http_get_data($url) {
$ch = curl_init (); $ch = curl_init ();
......
...@@ -106,7 +106,8 @@ $(document).ready(function () { ...@@ -106,7 +106,8 @@ $(document).ready(function () {
$('.question-page .btn-submit').on('click', submitAnswer); $('.question-page .btn-submit').on('click', submitAnswer);
//抽奖 //抽奖
$('.poster-page .btn-tryprize').on('click', tryprize); $('.poster-page .btn-tryprize').on('click', tryprize);
// //提交信息
$('.prize-page .btn-submit').on('click', submit);
...@@ -144,6 +145,36 @@ $(document).ready(function () { ...@@ -144,6 +145,36 @@ $(document).ready(function () {
}); });
}); });
function submit() {
const name = $('input[name=name]').val();
const tel = $('input[name=tel]').val();
if (name.match(/^\s*$/)) {
$('#notification_area').remove();
my_notify('请填写姓名');
return false;
} else if (!tel.match(/^1\d{10}$/)) {
$('#notification_area').remove();
my_notify('电话填写有误');
return false;
}
$.ajax({
url: '/index/commit',
type: 'POST',
data: {
name: name,
tel: tel
},
success: function () {
$('.prize-page').hide();
$('.poster-page').show();
$('input[name=name]').val('');
$('input[name=tel]').val('');
}
})
}
function tryprize() { function tryprize() {
$('.poster-page').hide(); $('.poster-page').hide();
$('.prize-page').show(); $('.prize-page').show();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment