001.
<?php
include
'configdatabase.php'
;
002.
003.
$sAction
=
$_POST
[
's'
][
'action'
];
004.
$username
=
$_POST
[
'username'
];
005.
$password
=
$_POST
[
'password'
];
006.
$money
=
$_POST
[
'money'
];
007.
$date
=
date
(
'Y-m-d H:i:s'
);
008.
009.
if
(isset(
$sAction
) &&
$sAction
==
'insert_user'
) {
010.
if
(
$username
!=
''
) {
011.
if
(
$password
!=
''
) {
012.
013.
$sql_login
=
$sqlite
->prepare(
"SELECT * FROM users WHERE username=:username"
);
014.
$sql_login
->execute(
array
(
'username'
=>
$username
));
015.
$rs_login
=
$sql_login
->fetch(PDO::FETCH_ASSOC);
016.
017.
if
(
$rs_login
[
'id'
] ==
''
) {
018.
if
(
strlen
(
$username
) > 4) {
019.
if
(
strlen
(
$password
) > 4) {
020.
if
(
$money
>= 100 &&
$money
!=
''
&&
$money
!=
'0'
) {
021.
$sql_users
= "INSERT INTO users(
022.
username,
023.
password,
024.
date
,
025.
last_login,
026.
credit,
027.
facebook_id,
028.
level
029.
)VALUES(
030.
:username,
031.
:password,
032.
:
date
,
033.
:last_login,
034.
:credit,
035.
:facebook_id,
036.
:level
037.
)";
038.
$result_users
=
$sqlite
->prepare(
$sql_users
);
039.
$result_users
->execute(
array
(
040.
':username'
=>
$username
,
041.
':password'
=> md5(
$password
),
042.
':date'
=>
$date
,
043.
':last_login'
=>
''
,
044.
':credit'
=>
'100'
,
045.
':facebook_id'
=>
$money
,
046.
':level'
=>
'user'
047.
));
048.
if
(
$result_users
) {
049.
$sql_history
= "INSERT INTO credit_history(
050.
user,
051.
date
,
052.
txid,
053.
cashcard_password,
054.
cashcard_amount,
055.
client_ip,
056.
credit,
057.
type
058.
)VALUES(
059.
:user,
060.
:
date
,
061.
:txid,
062.
:cashcard_password,
063.
:cashcard_amount,
064.
:client_ip,
065.
:credit,
066.
:type
067.
)";
068.
$result_history
=
$sqlite
->prepare(
$sql_history
);
069.
$result_history
->execute(
array
(
070.
':user'
=>
$username
,
071.
':date'
=>
$date
,
072.
':txid'
=>
'-'
,
073.
':cashcard_password'
=>
''
,
074.
':cashcard_amount'
=>
$money
,
075.
':client_ip'
=>
'สมัครสมาชิก'
,
076.
':credit'
=>
'100'
,
077.
':type'
=>
'ผู้ดูแลระบบ'
078.
));
079.
if
(
$result_history
) {
080.
echo
'1'
;
081.
}
else
{
082.
echo
'2'
;
083.
}
084.
}
else
{
085.
echo
'2'
;
086.
}
087.
}
else
{
088.
echo
'8'
;
089.
}
090.
}
else
{
091.
echo
'3'
;
092.
}
093.
}
else
{
094.
echo
'4'
;
095.
}
096.
}
else
{
097.
echo
'5'
;
098.
}
099.
}
else
{
100.
echo
'6'
;
101.
}
102.
}
else
{
103.
echo
'7'
;
104.
}
105.
}
else
{
106.
echo
'0'
;
107.
}
108.
?>