Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
php
/
samsung-christmas
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
66d66036
authored
Dec 17, 2019
by
doszhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dos
parent
8e4e184b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
158 additions
and
0 deletions
+158
-0
Application/Home/Controller/IndexController.class.php
+158
-0
No files found.
Application/Home/Controller/IndexController.class.php
View file @
66d66036
...
...
@@ -25,12 +25,169 @@ class IndexController extends Controller
// $this->request_auth($this->get_url());
// return;
// }
session_start
();
$_SESSION
[
'joinTime'
]
=
time
();
$this
->
display
();
}
public
function
tryPrize
()
{
$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'
]
<
2
)
{
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
;
}
// if($user['chance'] <= 0)
// {
// $this->ajaxReturn(array(
// 'status' => -1,
// 'msg' => '机会用光了',
// 'step' => 1
// ));
// return false;
// }
// M('user')->where(array(
// 'id' => $user['id']
// ))->setDec('chance');
$count
=
M
(
'prize'
.
$_SESSION
[
'src'
])
->
where
(
array
(
'user_id'
=>
$user
[
'id'
]
))
->
count
();
if
(
$count
>
0
)
{
$this
->
ajaxReturn
(
array
(
'status'
=>
0
,
'msg'
=>
'很遗憾,没有中奖'
,
'step'
=>
5
,
));
return
false
;
}
$prize
=
$this
->
get_random_prize
(
$user
);
if
(
$prize
)
{
$this
->
ajaxReturn
(
array
(
'status'
=>
1
,
'msg'
=>
'恭喜您中奖了!'
,
'prize_type'
=>
$prize
[
'type'
],
'step'
=>
4
));
}
else
{
$this
->
ajaxReturn
(
array
(
'status'
=>
0
,
'msg'
=>
'很遗憾,没有中奖'
,
'step'
=>
6
,
));
}
}
private
function
get_random_prize
(
$user
)
{
session_start
();
$v
=
rand
(
0
,
1000000
)
/
1000000
;
$today_ratio
=
1
;
if
(
$v
>
$today_ratio
)
{
return
false
;
}
$now
=
time
();
$req_type
=
array
();
$type_list
=
array
(
1
,
2
,
3
);
foreach
(
$type_list
as
$type
)
{
$c
=
M
(
'prize'
)
->
where
(
array
(
'type'
=>
$type
,
'is_get'
=>
1
,
))
->
count
();
if
(
$type
==
1
)
{
if
(
$c
>=
25
)
{
continue
;
}
}
else
if
(
$type
==
2
)
{
if
(
$c
>=
500
)
{
continue
;
}
}
else
if
(
$type
==
3
)
{
if
(
$c
>=
1000
)
{
continue
;
}
}
$req_type
[]
=
$type
;
}
if
(
empty
(
$req_type
))
{
return
false
;
}
$prize
=
M
(
'prize'
)
->
where
(
array
(
'is_get'
=>
0
,
'user_id'
=>
0
,
'type'
=>
array
(
'in'
,
$req_type
),
))
->
order
(
'rand()'
)
->
limit
(
1
)
->
find
();
if
(
!
$prize
)
{
return
false
;
}
$status
=
M
(
'prize'
)
->
where
(
array
(
'id'
=>
$prize
[
'id'
],
'is_get'
=>
0
,
'user_id'
=>
0
,
))
->
save
(
array
(
'is_get'
=>
1
,
'user_id'
=>
$user
[
'id'
],
'take_time'
=>
time
(),
'last_ip'
=>
$this
->
getIP
()
));
if
(
$status
===
false
||
$status
===
0
)
{
return
false
;
}
else
{
return
$prize
;
}
}
public
function
cookie
()
{
SignedCookie
::
set_cookie
(
$this
->
cookie_uid_key
,
'oVsrlt0zUWMLvMx2-KPGVmY2I-Xc'
,
C
(
'cookie_sign'
),
86400
*
60
);
}
public
function
addprize
()
{
for
(
$i
=
0
;
$i
<
1000
;
$i
++
)
{
M
(
'prize'
)
->
add
(
array
(
'type'
=>
3
,
'prize_name'
=>
'1元全网手机话费'
));
if
(
$i
<
500
)
{
M
(
'prize'
)
->
add
(
array
(
'type'
=>
2
,
'prize_name'
=>
'2元全网手机话费'
));
}
if
(
$i
<
25
)
{
M
(
'prize'
)
->
add
(
array
(
'type'
=>
3
,
'prize_name'
=>
'优酷VIP视频月卡'
));
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment