This repository has been archived by the owner on Jul 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase_function.php
77 lines (77 loc) · 2.15 KB
/
database_function.php
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
<?php
function retype_check($a, $b){
if ($a===null||$b===null) {
statusCode(2);
}
if($a==$b){
return false;
}else{
return true;
}
}
function login_check($member_id, $member_pw){
if ($member_id===null||$member_pw===null) {
statusCode(2);
}
$member_id=Mysqli_real_escape_string(conn(), $member_id);
$member_pw=Mysqli_real_escape_string(conn(), $member_pw);
$login_query = "SELECT * FROM members WHERE member_id='$member_id'";
$result = db($login_query);
if($result->num_rows==1){
global $row;
$row=$result->fetch_array(MYSQLI_ASSOC);
if($row['member_salt']==null){
if($row['member_pw']==hash('sha3-256', $member_pw)){
$_SESSION['member_reset']=$row['member_code'];
statusCode(21);
}
}
if($row['member_pw']==hash('sha3-256', $row['member_salt'].$member_pw)){
return true;
}
}
return false;
}
function overlap_check($table, $a, $b){
if ($table==null||$a==null||$b==null) {
statusCode(2);
}
$table=Mysqli_real_escape_string(conn(), $table);
$a=Mysqli_real_escape_string(conn(), $a);
$b=Mysqli_real_escape_string(conn(), $b);
$overlap_query = "SELECT * FROM `$table` WHERE $a='$b'";
$result = db($overlap_query);
if($result->num_rows){
return true;
}
return false;
}
function valid_check($table, $a, $b, $c, $d){
if ($table==null||$a==null||$b==null||$c==null||$d==null) {
statusCode(2);
}
$table=Mysqli_real_escape_string(conn(), $table);
$a=Mysqli_real_escape_string(conn(), $a);
$b=Mysqli_real_escape_string(conn(), $b);
$c=Mysqli_real_escape_string(conn(), $c);
$d=Mysqli_real_escape_string(conn(), $d);
$valid_query = "SELECT * FROM `$table` WHERE `$a`='$b' AND `$c`='$d'";
$result = db($valid_query);
if($result->num_rows){
return true;
}
return false;
}
function islogin(){
if(isset($_SESSION['member_code'])){
return true;
}else{
statusCode(19);
}
}
function statusCode($status_code){
$json = json_encode(array('status' => $status_code));
echo $json;
exit();
}
?>